Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
poopoothegorilla committed Mar 21, 2024
1 parent d6051a9 commit 94b9c6b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
5 changes: 3 additions & 2 deletions common/txmgr/inmemory_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func (ms *inMemoryStore[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) Close
// Abandon removes all transactions for a given address
func (ms *inMemoryStore[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) Abandon(ctx context.Context, chainID CHAIN_ID, addr ADDR) error {
if ms.chainID.String() != chainID.String() {
return fmt.Errorf("abandon: %w", ErrInvalidChainID)
panic("invalid chain ID")
}

// Mark all persisted transactions as abandoned
Expand All @@ -218,7 +218,8 @@ func (ms *inMemoryStore[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) Aband
defer ms.addressStatesLock.RUnlock()
as, ok := ms.addressStates[addr]
if !ok {
return fmt.Errorf("abandon: %w", ErrAddressNotFound)
as = newAddressState[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE](ms.lggr, chainID, addr, ms.maxUnstarted, nil)
ms.addressStates[addr] = as
}
as.abandon()

Expand Down
9 changes: 4 additions & 5 deletions core/chains/evm/txmgr/evm_inmemory_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestInMemoryStore_Abandon(t *testing.T) {

db := pgtest.NewSqlxDB(t)
_, dbcfg, evmcfg := evmtxmgr.MakeTestConfigs(t)
persistentStore := cltest.NewTestTxStore(t, db, dbcfg)
persistentStore := cltest.NewTestTxStore(t, db)
kst := cltest.NewKeyStore(t, db, dbcfg)
_, fromAddress := cltest.MustInsertRandomKey(t, kst.Eth())

Expand All @@ -44,13 +44,12 @@ func TestInMemoryStore_Abandon(t *testing.T) {
](ctx, lggr, chainID, kst.Eth(), persistentStore, evmcfg.Transactions())
require.NoError(t, err)

t.Run("saves new in_progress attempt if attempt is new", func(t *testing.T) {
t.Run("Abandon transactions successfully", func(t *testing.T) {
nTxs := 3
// Insert a transaction into persistent store
for i := 0; i < nTxs; i++ {
inTx := cltest.NewEthTx(fromAddress)
// insert the transaction into the persistent store
require.NoError(t, persistentStore.InsertTx(&inTx))
require.NoError(t, persistentStore.InsertTx(ctx, &inTx))
// insert the transaction into the in-memory store
require.NoError(t, inMemoryStore.XXXTestInsertTx(fromAddress, &inTx))
}
Expand All @@ -65,7 +64,7 @@ func TestInMemoryStore_Abandon(t *testing.T) {
require.NotNil(t, expTxs)
require.Equal(t, nTxs, len(expTxs))

// Check that the in-memory store has the new attempt
// Check the in-memory store
fn := func(tx *evmtxmgr.Tx) bool { return true }
actTxs := inMemoryStore.XXXTestFindTxs(nil, fn)
require.NotNil(t, actTxs)
Expand Down

0 comments on commit 94b9c6b

Please sign in to comment.