mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-07 23:10:32 +00:00
Merge pull request #859 from nspcc-dev/neo3/partial_consensus_message_decoding
consensus: added partial message decoding
This commit is contained in:
commit
e150bd7bb0
7 changed files with 63 additions and 17 deletions
|
@ -22,6 +22,7 @@ func TestRecoveryMessage_Setters(t *testing.T) {
|
|||
|
||||
r := &recoveryMessage{}
|
||||
p := new(Payload)
|
||||
p.message = &message{}
|
||||
p.SetType(payload.RecoveryMessageType)
|
||||
p.SetPayload(r)
|
||||
// sign payload to have verification script
|
||||
|
@ -35,6 +36,7 @@ func TestRecoveryMessage_Setters(t *testing.T) {
|
|||
nextConsensus: util.Uint160{1, 2},
|
||||
}
|
||||
p1 := new(Payload)
|
||||
p1.message = &message{}
|
||||
p1.SetType(payload.PrepareRequestType)
|
||||
p1.SetPayload(req)
|
||||
p1.SetValidatorIndex(0)
|
||||
|
@ -42,6 +44,7 @@ func TestRecoveryMessage_Setters(t *testing.T) {
|
|||
|
||||
t.Run("prepare response is added", func(t *testing.T) {
|
||||
p2 := new(Payload)
|
||||
p2.message = &message{}
|
||||
p2.SetType(payload.PrepareResponseType)
|
||||
p2.SetPayload(&prepareResponse{
|
||||
preparationHash: p1.Hash(),
|
||||
|
@ -67,6 +70,7 @@ func TestRecoveryMessage_Setters(t *testing.T) {
|
|||
r.AddPayload(p1)
|
||||
pr = r.GetPrepareRequest(p, pubs, p1.ValidatorIndex())
|
||||
require.NotNil(t, pr)
|
||||
require.Equal(t, p1.Hash(), pr.Hash())
|
||||
require.Equal(t, p1, pr)
|
||||
|
||||
pl := pr.(*Payload)
|
||||
|
@ -75,6 +79,7 @@ func TestRecoveryMessage_Setters(t *testing.T) {
|
|||
|
||||
t.Run("change view is added", func(t *testing.T) {
|
||||
p3 := new(Payload)
|
||||
p3.message = &message{}
|
||||
p3.SetType(payload.ChangeViewType)
|
||||
p3.SetPayload(&changeView{
|
||||
newViewNumber: 1,
|
||||
|
@ -95,6 +100,7 @@ func TestRecoveryMessage_Setters(t *testing.T) {
|
|||
|
||||
t.Run("commit is added", func(t *testing.T) {
|
||||
p4 := new(Payload)
|
||||
p4.message = &message{}
|
||||
p4.SetType(payload.CommitType)
|
||||
p4.SetPayload(randomMessage(t, commitType))
|
||||
p4.SetValidatorIndex(4)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue