diff --git a/common/txmgr/inmemory_store.go b/common/txmgr/inmemory_store.go index 88905f463b0..3272780517d 100644 --- a/common/txmgr/inmemory_store.go +++ b/common/txmgr/inmemory_store.go @@ -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 @@ -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() diff --git a/core/chains/evm/txmgr/evm_inmemory_store_test.go b/core/chains/evm/txmgr/evm_inmemory_store_test.go index a8d1c2f4745..c36da4d3929 100644 --- a/core/chains/evm/txmgr/evm_inmemory_store_test.go +++ b/core/chains/evm/txmgr/evm_inmemory_store_test.go @@ -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()) @@ -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)) } @@ -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)