From 484985cf9abb412dcd562f252bb321d6315017bd Mon Sep 17 00:00:00 2001 From: Domino Valdano <2644901+reductionista@users.noreply.github.com> Date: Wed, 11 Dec 2024 11:59:36 -0800 Subject: [PATCH] Update loader tests for interface --- pkg/solana/logpoller/loader_test.go | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/pkg/solana/logpoller/loader_test.go b/pkg/solana/logpoller/loader_test.go index d8e1acf7d..9b3fe6071 100644 --- a/pkg/solana/logpoller/loader_test.go +++ b/pkg/solana/logpoller/loader_test.go @@ -63,7 +63,7 @@ func TestEncodedLogCollector_ParseSingleEvent(t *testing.T) { latest.Store(uint64(40)) client.EXPECT(). - GetLatestBlockhash(mock.Anything, rpc.CommitmentFinalized). + LatestBlockhash(mock.Anything). RunAndReturn(latestBlockhashReturnFunc(&latest)) client.EXPECT(). @@ -71,7 +71,6 @@ func TestEncodedLogCollector_ParseSingleEvent(t *testing.T) { mock.Anything, mock.MatchedBy(getBlocksStartValMatcher), mock.MatchedBy(getBlocksEndValMatcher(&latest)), - rpc.CommitmentFinalized, ). RunAndReturn(getBlocksReturnFunc(false)) @@ -138,7 +137,7 @@ func TestEncodedLogCollector_MultipleEventOrdered(t *testing.T) { } client.EXPECT(). - GetLatestBlockhash(mock.Anything, rpc.CommitmentFinalized). + LatestBlockhash(mock.Anything). RunAndReturn(latestBlockhashReturnFunc(&latest)) client.EXPECT(). @@ -146,7 +145,6 @@ func TestEncodedLogCollector_MultipleEventOrdered(t *testing.T) { mock.Anything, mock.MatchedBy(getBlocksStartValMatcher), mock.MatchedBy(getBlocksEndValMatcher(&latest)), - rpc.CommitmentFinalized, ). RunAndReturn(getBlocksReturnFunc(false)) @@ -255,7 +253,7 @@ func TestEncodedLogCollector_BackfillForAddress(t *testing.T) { // GetLatestBlockhash might be called at start-up; make it take some time because the result isn't needed for this test client.EXPECT(). - GetLatestBlockhash(mock.Anything, rpc.CommitmentFinalized). + LatestBlockhash(mock.Anything). RunAndReturn(latestBlockhashReturnFunc(&latest)). After(2 * time.Second). Maybe() @@ -265,7 +263,6 @@ func TestEncodedLogCollector_BackfillForAddress(t *testing.T) { mock.Anything, mock.MatchedBy(getBlocksStartValMatcher), mock.MatchedBy(getBlocksEndValMatcher(&latest)), - rpc.CommitmentFinalized, ). RunAndReturn(getBlocksReturnFunc(true)) @@ -412,7 +409,7 @@ func (p *testBlockProducer) Count() uint64 { return p.count } -func (p *testBlockProducer) GetLatestBlockhash(_ context.Context, _ rpc.CommitmentType) (out *rpc.GetLatestBlockhashResult, err error) { +func (p *testBlockProducer) LatestBlockhash(_ context.Context) (out *rpc.GetLatestBlockhashResult, err error) { p.b.Helper() p.mu.Lock() @@ -431,7 +428,7 @@ func (p *testBlockProducer) GetLatestBlockhash(_ context.Context, _ rpc.Commitme }, nil } -func (p *testBlockProducer) GetBlocks(_ context.Context, startSlot uint64, endSlot *uint64, _ rpc.CommitmentType) (out rpc.BlocksResult, err error) { +func (p *testBlockProducer) GetBlocks(_ context.Context, startSlot uint64, endSlot *uint64) (out rpc.BlocksResult, err error) { p.b.Helper() p.mu.Lock() @@ -443,7 +440,7 @@ func (p *testBlockProducer) GetBlocks(_ context.Context, startSlot uint64, endSl blocks[idx] = startSlot + uint64(idx) } - return rpc.BlocksResult(blocks), nil + return blocks, nil } func (p *testBlockProducer) GetBlockWithOpts(_ context.Context, block uint64, opts *rpc.GetBlockOpts) (*rpc.GetBlockResult, error) { @@ -546,8 +543,8 @@ func (p *testParser) Events() []logpoller.ProgramEvent { return p.events } -func latestBlockhashReturnFunc(latest *atomic.Uint64) func(context.Context, rpc.CommitmentType) (*rpc.GetLatestBlockhashResult, error) { - return func(ctx context.Context, ct rpc.CommitmentType) (*rpc.GetLatestBlockhashResult, error) { +func latestBlockhashReturnFunc(latest *atomic.Uint64) func(context.Context) (*rpc.GetLatestBlockhashResult, error) { + return func(ctx context.Context) (*rpc.GetLatestBlockhashResult, error) { defer func() { latest.Store(latest.Load() + 2) }() @@ -565,8 +562,8 @@ func latestBlockhashReturnFunc(latest *atomic.Uint64) func(context.Context, rpc. } } -func getBlocksReturnFunc(empty bool) func(context.Context, uint64, *uint64, rpc.CommitmentType) (rpc.BlocksResult, error) { - return func(_ context.Context, u1 uint64, u2 *uint64, _ rpc.CommitmentType) (rpc.BlocksResult, error) { +func getBlocksReturnFunc(empty bool) func(context.Context, uint64, *uint64) (rpc.BlocksResult, error) { + return func(_ context.Context, u1 uint64, u2 *uint64) (rpc.BlocksResult, error) { blocks := []uint64{} if !empty { @@ -576,7 +573,7 @@ func getBlocksReturnFunc(empty bool) func(context.Context, uint64, *uint64, rpc. } } - return rpc.BlocksResult(blocks), nil + return blocks, nil } }