Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
rianhughes committed Jan 8, 2025
1 parent 99d1b43 commit 4f1107c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
5 changes: 5 additions & 0 deletions mempool/init_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package mempool_test

import (
_ "github.com/NethermindEth/juno/encoder/registry"
)
16 changes: 12 additions & 4 deletions mempool/mempool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"testing"
"time"

"github.com/NethermindEth/juno/blockchain"
"github.com/NethermindEth/juno/core"
"github.com/NethermindEth/juno/core/felt"
"github.com/NethermindEth/juno/db"
Expand Down Expand Up @@ -49,7 +48,6 @@ func TestMempool(t *testing.T) {
pool, closer, err := mempool.New(*testDB, state, 4)
defer closer()
require.NoError(t, err)
blockchain.RegisterCoreTypesToEncoder()

l := pool.Len()
assert.Equal(t, uint16(0), l)
Expand Down Expand Up @@ -118,7 +116,6 @@ func TestMempool(t *testing.T) {
}

func TestRestoreMempool(t *testing.T) {
blockchain.RegisterCoreTypesToEncoder()
mockCtrl := gomock.NewController(t)
t.Cleanup(mockCtrl.Finish)
state := mocks.NewMockStateHistoryReader(mockCtrl)
Expand Down Expand Up @@ -187,7 +184,6 @@ func TestWait(t *testing.T) {
state := mocks.NewMockStateHistoryReader(mockCtrl)
pool, _, err := mempool.New(testDB, state, 1024)
require.NoError(t, err)
blockchain.RegisterCoreTypesToEncoder()

select {
case <-pool.Wait():
Expand All @@ -196,22 +192,34 @@ func TestWait(t *testing.T) {
}

// One transaction.
state.EXPECT().ContractNonce(new(felt.Felt).SetUint64(1)).Return(new(felt.Felt).SetUint64(0), nil)
require.NoError(t, pool.Push(&mempool.BroadcastedTransaction{
Transaction: &core.InvokeTransaction{
TransactionHash: new(felt.Felt).SetUint64(1),
Nonce: new(felt.Felt).SetUint64(1),
SenderAddress: new(felt.Felt).SetUint64(1),
Version: new(core.TransactionVersion).SetUint64(1),
},
}))
<-pool.Wait()

// Two transactions.
state.EXPECT().ContractNonce(new(felt.Felt).SetUint64(2)).Return(new(felt.Felt).SetUint64(0), nil)
require.NoError(t, pool.Push(&mempool.BroadcastedTransaction{
Transaction: &core.InvokeTransaction{
TransactionHash: new(felt.Felt).SetUint64(2),
Nonce: new(felt.Felt).SetUint64(1),
SenderAddress: new(felt.Felt).SetUint64(2),
Version: new(core.TransactionVersion).SetUint64(1),
},
}))
state.EXPECT().ContractNonce(new(felt.Felt).SetUint64(3)).Return(new(felt.Felt).SetUint64(0), nil)
require.NoError(t, pool.Push(&mempool.BroadcastedTransaction{
Transaction: &core.InvokeTransaction{
TransactionHash: new(felt.Felt).SetUint64(3),
Nonce: new(felt.Felt).SetUint64(1),
SenderAddress: new(felt.Felt).SetUint64(3),
Version: new(core.TransactionVersion).SetUint64(1),
},
}))
<-pool.Wait()
Expand Down

0 comments on commit 4f1107c

Please sign in to comment.