From ddf1048792e4f2358ef665726530d445bc2e1914 Mon Sep 17 00:00:00 2001 From: Awbrey Hughlett Date: Thu, 12 Dec 2024 09:31:49 -0600 Subject: [PATCH] add more slots to test to ensure ordered delivery --- pkg/solana/logpoller/loader_test.go | 36 +++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/pkg/solana/logpoller/loader_test.go b/pkg/solana/logpoller/loader_test.go index 166ed9b24..b4a0b6215 100644 --- a/pkg/solana/logpoller/loader_test.go +++ b/pkg/solana/logpoller/loader_test.go @@ -128,7 +128,7 @@ func TestEncodedLogCollector_MultipleEventOrdered(t *testing.T) { latest.Store(uint64(40)) - slots := []uint64{43, 42} + slots := []uint64{44, 43, 42, 41} sigs := make([]solana.Signature, len(slots)) hashes := make([]solana.Hash, len(slots)) @@ -162,8 +162,10 @@ func TestEncodedLogCollector_MultipleEventOrdered(t *testing.T) { } } - if slot == 42 { - // force slot 42 to return after 43 + // imitate loading block data out of order + if slot == 43 || slot == 41 { + // force slot 43 to return after 44 + // same for 41 after 42 time.Sleep(1 * time.Second) } @@ -197,12 +199,24 @@ func TestEncodedLogCollector_MultipleEventOrdered(t *testing.T) { tests.AssertEventually(t, func() bool { return reflect.DeepEqual(parser.Events(), []logpoller.ProgramEvent{ + { + BlockData: logpoller.BlockData{ + SlotNumber: 41, + BlockHeight: 40, + BlockHash: hashes[3], + TransactionHash: sigs[3], + TransactionIndex: 0, + TransactionLogIndex: 0, + }, + Prefix: ">", + Data: "HDQnaQjSWwkNAAAASGVsbG8sIFdvcmxkISoAAAAAAAAA", + }, { BlockData: logpoller.BlockData{ SlotNumber: 42, BlockHeight: 41, - BlockHash: hashes[1], - TransactionHash: sigs[1], + BlockHash: hashes[2], + TransactionHash: sigs[2], TransactionIndex: 0, TransactionLogIndex: 0, }, @@ -213,6 +227,18 @@ func TestEncodedLogCollector_MultipleEventOrdered(t *testing.T) { BlockData: logpoller.BlockData{ SlotNumber: 43, BlockHeight: 42, + BlockHash: hashes[1], + TransactionHash: sigs[1], + TransactionIndex: 0, + TransactionLogIndex: 0, + }, + Prefix: ">", + Data: "HDQnaQjSWwkNAAAASGVsbG8sIFdvcmxkISoAAAAAAAAA", + }, + { + BlockData: logpoller.BlockData{ + SlotNumber: 44, + BlockHeight: 43, BlockHash: hashes[0], TransactionHash: sigs[0], TransactionIndex: 0,