@@ -208,11 +208,14 @@ func TestByzPrimary(t *testing.T) {
208
208
repls [0 ].Request (r1 )
209
209
sys .Run ()
210
210
for _ , a := range adapters {
211
- if len (a .batches ) != 1 {
212
- t .Fatal ("expected execution of 1 batch " )
211
+ if len (a .batches ) != 2 {
212
+ t .Fatal ("expected execution of 2 batches " )
213
213
}
214
214
if ! reflect .DeepEqual ([][]byte {r2 }, a .batches [0 ].Payloads ) {
215
- t .Error ("wrong request executed" )
215
+ t .Error ("wrong request executed first" )
216
+ }
217
+ if ! reflect .DeepEqual ([][]byte {r1 }, a .batches [1 ].Payloads ) {
218
+ t .Error ("wrong request executed second" )
216
219
}
217
220
}
218
221
}
@@ -256,6 +259,45 @@ func TestViewChange(t *testing.T) {
256
259
}
257
260
}
258
261
262
+ func TestViewChangeWithRetransmission (t * testing.T ) {
263
+ N := uint64 (4 )
264
+ sys := newTestSystem (N )
265
+ var repls []* SBFT
266
+ var adapters []* testSystemAdapter
267
+ for i := uint64 (0 ); i < N ; i ++ {
268
+ a := sys .NewAdapter (i )
269
+ s , err := New (i , & Config {N : N , F : 1 , BatchDurationNsec : 2000000000 , BatchSizeBytes : 1 , RequestTimeoutNsec : 20000000000 }, a )
270
+ if err != nil {
271
+ t .Fatal (err )
272
+ }
273
+ repls = append (repls , s )
274
+ adapters = append (adapters , a )
275
+ }
276
+
277
+ // network outage after prepares are received
278
+ sys .filterFn = func (e testElem ) (testElem , bool ) {
279
+ if msg , ok := e .ev .(* testMsgEvent ); ok {
280
+ if c := msg .msg .GetPrepare (); c != nil && c .Seq .View == 0 {
281
+ return e , false
282
+ }
283
+ }
284
+ return e , true
285
+ }
286
+
287
+ connectAll (sys )
288
+ r1 := []byte {1 , 2 , 3 }
289
+ repls [0 ].Request (r1 )
290
+ sys .Run ()
291
+ for _ , a := range adapters {
292
+ if len (a .batches ) != 1 {
293
+ t .Fatal ("expected execution of 1 batch" )
294
+ }
295
+ if ! reflect .DeepEqual ([][]byte {r1 }, a .batches [0 ].Payloads ) {
296
+ t .Error ("wrong request executed (1)" )
297
+ }
298
+ }
299
+ }
300
+
259
301
func TestViewChangeXset (t * testing.T ) {
260
302
N := uint64 (4 )
261
303
sys := newTestSystem (N )
@@ -320,11 +362,14 @@ func TestViewChangeXset(t *testing.T) {
320
362
if i == 3 {
321
363
continue
322
364
}
323
- if len (a .batches ) != 1 {
365
+ if len (a .batches ) != 2 {
324
366
t .Fatalf ("expected execution of 1 batch: %v" , a .batches )
325
367
}
326
- if ! reflect .DeepEqual ([][]byte {r2 }, a .batches [0 ].Payloads ) {
327
- t .Error ("wrong request executed" )
368
+ if ! reflect .DeepEqual ([][]byte {r1 }, a .batches [0 ].Payloads ) {
369
+ t .Error ("wrong request executed first" )
370
+ }
371
+ if ! reflect .DeepEqual ([][]byte {r2 }, a .batches [1 ].Payloads ) {
372
+ t .Error ("wrong request executed second" )
328
373
}
329
374
}
330
375
}
0 commit comments