@@ -311,6 +311,58 @@ func TestMsgReordering(t *testing.T) {
311311 }
312312}
313313
314+ func TestBacklogReordering (t * testing.T ) {
315+ N := uint64 (4 )
316+ sys := newTestSystem (N )
317+ var repls []* SBFT
318+ var adapters []* testSystemAdapter
319+ for i := uint64 (0 ); i < N ; i ++ {
320+ a := sys .NewAdapter (i )
321+ s , err := New (i , & Config {N : N , F : 1 , BatchDurationNsec : 2000000000 , BatchSizeBytes : 1 , RequestTimeoutNsec : 20000000000 }, a )
322+ if err != nil {
323+ t .Fatal (err )
324+ }
325+ repls = append (repls , s )
326+ adapters = append (adapters , a )
327+ }
328+
329+ var preprep * testMsgEvent
330+
331+ // forcing pre-prepare from primary 0 to reach replica 1 after some delay
332+ // effectivelly delivering pre-prepare instead of checkpoint
333+ sys .filterFn = func (e testElem ) (testElem , bool ) {
334+ if msg , ok := e .ev .(* testMsgEvent ); ok {
335+ if msg .src == 0 && msg .dst == 1 {
336+ c := msg .msg .GetPreprepare ()
337+ if c != nil && c .Seq .View == 0 {
338+ preprep = msg //memorizing pre-prepare
339+ return e , false // but dropping it
340+ }
341+ d := msg .msg .GetCheckpoint ()
342+ if d != nil {
343+ msg .msg = & Msg {& Msg_Preprepare {preprep .msg .GetPreprepare ()}}
344+ return e , true //and delivering it
345+ }
346+ return e , true //letting prepare and commit from 0 to 1 pass
347+ }
348+ }
349+ return e , true
350+ }
351+
352+ connectAll (sys )
353+ r1 := []byte {1 , 2 , 3 }
354+ repls [0 ].Request (r1 )
355+ sys .Run ()
356+ for _ , a := range adapters {
357+ if len (a .batches ) != 1 {
358+ t .Fatal ("expected execution of 1 batch" )
359+ }
360+ if ! reflect .DeepEqual ([][]byte {r1 }, a .batches [0 ].Payloads ) {
361+ t .Error ("wrong request executed (1)" )
362+ }
363+ }
364+ }
365+
314366func TestViewChangeWithRetransmission (t * testing.T ) {
315367 N := uint64 (4 )
316368 sys := newTestSystem (N )
0 commit comments