network: add MPT-related P2P payloads
This commit is contained in:
parent
20f190ef69
commit
edcfdb3bde
5 changed files with 155 additions and 1 deletions
51
pkg/network/payload/state_root_test.go
Normal file
51
pkg/network/payload/state_root_test.go
Normal file
|
@ -0,0 +1,51 @@
|
|||
package payload
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"testing"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||
"github.com/nspcc-dev/neo-go/pkg/internal/random"
|
||||
"github.com/nspcc-dev/neo-go/pkg/internal/testserdes"
|
||||
)
|
||||
|
||||
func TestStateRoots_Serializable(t *testing.T) {
|
||||
expected := &StateRoots{
|
||||
Roots: []state.MPTRoot{
|
||||
{
|
||||
MPTRootBase: state.MPTRootBase{
|
||||
Index: rand.Uint32(),
|
||||
PrevHash: random.Uint256(),
|
||||
Root: random.Uint256(),
|
||||
},
|
||||
Witness: &transaction.Witness{
|
||||
InvocationScript: random.Bytes(10),
|
||||
VerificationScript: random.Bytes(11),
|
||||
},
|
||||
},
|
||||
{
|
||||
MPTRootBase: state.MPTRootBase{
|
||||
Index: rand.Uint32(),
|
||||
PrevHash: random.Uint256(),
|
||||
Root: random.Uint256(),
|
||||
},
|
||||
Witness: &transaction.Witness{
|
||||
InvocationScript: random.Bytes(10),
|
||||
VerificationScript: random.Bytes(11),
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
testserdes.EncodeDecodeBinary(t, expected, new(StateRoots))
|
||||
}
|
||||
|
||||
func TestGetStateRoots_Serializable(t *testing.T) {
|
||||
expected := &GetStateRoots{
|
||||
Start: rand.Uint32(),
|
||||
Count: rand.Uint32(),
|
||||
}
|
||||
|
||||
testserdes.EncodeDecodeBinary(t, expected, new(GetStateRoots))
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue