@@ -43,18 +43,18 @@ func TestCheckMessage(t *testing.T) {
43
43
current : newRoundState (& istanbul.View {
44
44
Sequence : big .NewInt (2 ),
45
45
Round : big .NewInt (2 ),
46
- }, valSet , valSet .GetByIndex (0 ), false ),
46
+ }, valSet , valSet .GetByIndex (0 )),
47
47
}
48
48
49
49
t .Run ("invalid view format" , func (t * testing.T ) {
50
- err := c .checkMessage (istanbul .MsgPreprepare , nil )
50
+ err := c .checkMessage (istanbul .MsgPreprepareV2 , nil )
51
51
if err != errInvalidMessage {
52
52
t .Errorf ("error mismatch: have %v, want %v" , err , errInvalidMessage )
53
53
}
54
54
})
55
55
56
56
testStates := []State {StateAcceptRequest , StatePreprepared , StatePrepared , StateCommitted , StateWaitingForNewRound }
57
- testCodes := []uint64 {istanbul .MsgPreprepare , istanbul .MsgPrepare , istanbul .MsgCommit , istanbul .MsgRoundChange }
57
+ testCodes := []uint64 {istanbul .MsgPreprepareV2 , istanbul .MsgPrepare , istanbul .MsgCommit , istanbul .MsgRoundChangeV2 }
58
58
59
59
// accept Commits from sequence, round matching LastSubject
60
60
t .Run ("Rejects all other older rounds" , func (t * testing.T ) {
@@ -116,7 +116,7 @@ func TestCheckMessage(t *testing.T) {
116
116
for _ , testCode := range testCodes {
117
117
c .current .(* roundStateImpl ).state = testState
118
118
err := c .checkMessage (testCode , v )
119
- if testCode == istanbul .MsgRoundChange {
119
+ if testCode == istanbul .MsgRoundChangeV2 {
120
120
if err != nil {
121
121
t .Errorf ("error mismatch: have %v, want nil" , err )
122
122
}
@@ -133,11 +133,11 @@ func TestCheckMessage(t *testing.T) {
133
133
134
134
for _ , testCode := range testCodes {
135
135
err := c .checkMessage (testCode , v )
136
- if testCode == istanbul .MsgRoundChange {
136
+ if testCode == istanbul .MsgRoundChangeV2 {
137
137
if err != nil {
138
138
t .Errorf ("error mismatch: have %v, want nil" , err )
139
139
}
140
- } else if testCode == istanbul .MsgPreprepare {
140
+ } else if testCode == istanbul .MsgPreprepareV2 {
141
141
if err != nil {
142
142
t .Errorf ("error mismatch: have %v, want nil" , err )
143
143
}
@@ -154,7 +154,7 @@ func TestCheckMessage(t *testing.T) {
154
154
c .current .(* roundStateImpl ).state = StatePreprepared
155
155
for _ , testCode := range testCodes {
156
156
err := c .checkMessage (testCode , v )
157
- if testCode == istanbul .MsgRoundChange {
157
+ if testCode == istanbul .MsgRoundChangeV2 {
158
158
if err != nil {
159
159
t .Errorf ("error mismatch: have %v, want nil" , err )
160
160
}
@@ -169,7 +169,7 @@ func TestCheckMessage(t *testing.T) {
169
169
c .current .(* roundStateImpl ).state = StatePrepared
170
170
for _ , testCode := range testCodes {
171
171
err := c .checkMessage (testCode , v )
172
- if testCode == istanbul .MsgRoundChange {
172
+ if testCode == istanbul .MsgRoundChangeV2 {
173
173
if err != nil {
174
174
t .Errorf ("error mismatch: have %v, want nil" , err )
175
175
}
@@ -184,7 +184,7 @@ func TestCheckMessage(t *testing.T) {
184
184
c .current .(* roundStateImpl ).state = StateCommitted
185
185
for _ , testCode := range testCodes {
186
186
err := c .checkMessage (testCode , v )
187
- if testCode == istanbul .MsgRoundChange {
187
+ if testCode == istanbul .MsgRoundChangeV2 {
188
188
if err != nil {
189
189
t .Errorf ("error mismatch: have %v, want nil" , err )
190
190
}
@@ -199,7 +199,7 @@ func TestCheckMessage(t *testing.T) {
199
199
c .current .(* roundStateImpl ).state = StateWaitingForNewRound
200
200
for _ , testCode := range testCodes {
201
201
err := c .checkMessage (testCode , v )
202
- if testCode == istanbul .MsgRoundChange || testCode == istanbul .MsgPreprepare {
202
+ if testCode == istanbul .MsgRoundChangeV2 || testCode == istanbul .MsgPreprepareV2 {
203
203
if err != nil {
204
204
t .Errorf ("error mismatch: have %v, want nil" , err )
205
205
}
@@ -231,8 +231,8 @@ func TestStoreBacklog(t *testing.T) {
231
231
p1 := validator .New (common .BytesToAddress ([]byte ("12345667890" )), blscrypto.SerializedPublicKey {})
232
232
p2 := validator .New (common .BytesToAddress ([]byte ("47324349949" )), blscrypto.SerializedPublicKey {})
233
233
234
- mPreprepare := istanbul .NewPreprepareMessage (
235
- & istanbul.Preprepare {View : v10 , Proposal : makeBlock (10 )},
234
+ mPreprepare := istanbul .NewPreprepareV2Message (
235
+ & istanbul.PreprepareV2 {View : v10 , Proposal : makeBlock (10 )},
236
236
p1 .Address (),
237
237
)
238
238
backlog .store (mPreprepare )
@@ -246,8 +246,8 @@ func TestStoreBacklog(t *testing.T) {
246
246
& istanbul.Subject {View : v10 , Digest : common .BytesToHash ([]byte ("1234567890" ))},
247
247
p1 .Address (),
248
248
)
249
- mPreprepare2 := istanbul .NewPreprepareMessage (
250
- & istanbul.Preprepare {View : v11 , Proposal : makeBlock (11 )},
249
+ mPreprepare2 := istanbul .NewPreprepareV2Message (
250
+ & istanbul.PreprepareV2 {View : v11 , Proposal : makeBlock (11 )},
251
251
p2 .Address (),
252
252
)
253
253
@@ -300,8 +300,8 @@ func TestClearBacklogForSequence(t *testing.T) {
300
300
// The backlog's state is sequence number 1, round 0. Store future messages with sequence number 2
301
301
p1 := validator .New (common .BytesToAddress ([]byte ("12345667890" )), blscrypto.SerializedPublicKey {})
302
302
303
- mPreprepare := istanbul .NewPreprepareMessage (
304
- & istanbul.Preprepare {
303
+ mPreprepare := istanbul .NewPreprepareV2Message (
304
+ & istanbul.PreprepareV2 {
305
305
View : & istanbul.View {Round : big .NewInt (0 ), Sequence : big .NewInt (2 )},
306
306
Proposal : makeBlock (2 ),
307
307
},
@@ -360,15 +360,21 @@ func TestProcessFutureBacklog(t *testing.T) {
360
360
backlog .store (mFuture )
361
361
362
362
// push a message from the past and check we expire it
363
- mPast := istanbul .NewRoundChangeMessage (& istanbul.RoundChange {
364
- View : & istanbul.View {
365
- Round : big .NewInt (0 ),
366
- Sequence : oldSequence ,
367
- },
368
- PreparedCertificate : istanbul.PreparedCertificate {
369
- Proposal : makeBlock (0 ),
363
+ addr := valSet .GetByIndex (1 ).Address ()
364
+ roundChangeV2 := & istanbul.RoundChangeV2 {
365
+ Request : istanbul.RoundChangeRequest {
366
+ Address : addr ,
367
+ View : istanbul.View {
368
+ Round : big .NewInt (0 ),
369
+ Sequence : oldSequence ,
370
+ },
371
+ PreparedCertificateV2 : istanbul .PCV2FromPCV1 (istanbul.PreparedCertificate {
372
+ Proposal : makeBlock (0 ),
373
+ }),
370
374
},
371
- }, valSet .GetByIndex (1 ).Address ())
375
+ }
376
+ // No need to sign the RoundChangeRequest for this test
377
+ mPast := istanbul .NewRoundChangeV2Message (roundChangeV2 , addr )
372
378
373
379
backlog .store (mPast )
374
380
@@ -404,17 +410,18 @@ func TestProcessBacklog(t *testing.T) {
404
410
address := common .BytesToAddress ([]byte ("0xce10ce10" ))
405
411
406
412
msgs := []* istanbul.Message {
407
- istanbul .NewPreprepareMessage (
408
- & istanbul.Preprepare {View : v , Proposal : makeBlock (1 )},
413
+ istanbul .NewPreprepareV2Message (
414
+ & istanbul.PreprepareV2 {View : v , Proposal : makeBlock (1 )},
409
415
address ,
410
416
),
411
417
istanbul .NewPrepareMessage (subject , address ),
412
418
istanbul .NewCommitMessage (
413
419
& istanbul.CommittedSubject {Subject : subject , CommittedSeal : []byte {0x63 , 0x65 , 0x6C , 0x6F }},
414
420
address ,
415
421
),
416
- istanbul .NewRoundChangeMessage (
417
- & istanbul.RoundChange {View : v , PreparedCertificate : istanbul .EmptyPreparedCertificate ()},
422
+ istanbul .NewRoundChangeV2Message (
423
+ & istanbul.RoundChangeV2 {
424
+ Request : istanbul.RoundChangeRequest {View : * v }, PreparedProposal : makeBlock (1 )},
418
425
address ,
419
426
),
420
427
}
0 commit comments