Skip to content

Commit

Permalink
update cltest
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanTinianov committed Nov 27, 2023
1 parent 7510072 commit 969f50a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
18 changes: 7 additions & 11 deletions core/chains/evm/txmgr/evm_tx_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -795,15 +795,15 @@ func TestORM_IsTxFinalized(t *testing.T) {

t.Run("confirmed tx not past finality_depth", func(t *testing.T) {
confirmedAddr := cltest.MustGenerateRandomKey(t).Address
tx := cltest.MustInsertConfirmedEthTxWithReceipt(t, txStore, confirmedAddr, 123, 1)
tx := mustInsertConfirmedEthTxWithReceipt(t, txStore, confirmedAddr, 123, 1)
finalized, err := txStore.IsTxFinalized(testutils.Context(t), 2, tx.ID)
require.NoError(t, err)
require.False(t, finalized)
})

t.Run("confirmed tx past finality_depth", func(t *testing.T) {
confirmedAddr := cltest.MustGenerateRandomKey(t).Address
tx := cltest.MustInsertConfirmedEthTxWithReceipt(t, txStore, confirmedAddr, 123, 1)
tx := mustInsertConfirmedEthTxWithReceipt(t, txStore, confirmedAddr, 123, 1)
finalized, err := txStore.IsTxFinalized(testutils.Context(t), 10, tx.ID)
require.NoError(t, err)
require.True(t, finalized)
Expand Down Expand Up @@ -1406,18 +1406,14 @@ func TestORM_GetNonFatalTransactions(t *testing.T) {
})

t.Run("get in progress, unstarted, and unconfirmed eth transactions", func(t *testing.T) {
inProgressTx := cltest.MustInsertInProgressEthTxWithAttempt(t, txStore, 123, fromAddress)
unconfirmedTx := cltest.MustInsertUnconfirmedEthTx(t, txStore, 124, fromAddress)
unstartedTx := cltest.MustCreateUnstartedGeneratedTx(t, txStore, fromAddress, ethClient.ConfiguredChainID())
inProgressTx := mustInsertInProgressEthTxWithAttempt(t, txStore, 123, fromAddress)
unstartedTx := mustCreateUnstartedGeneratedTx(t, txStore, fromAddress, ethClient.ConfiguredChainID())

txes, err := txStore.GetNonFatalTransactions(testutils.Context(t))
require.NoError(t, err)

for _, tx := range txes {
require.True(t,
tx.ID == inProgressTx.ID ||
tx.ID == unconfirmedTx.ID ||
tx.ID == unstartedTx.ID)
require.True(t, tx.ID == inProgressTx.ID || tx.ID == unstartedTx.ID)
}
})
}
Expand All @@ -1438,7 +1434,7 @@ func TestORM_GetTxByID(t *testing.T) {
})

t.Run("get transaction by ID", func(t *testing.T) {
insertedTx := cltest.MustInsertInProgressEthTxWithAttempt(t, txStore, 123, fromAddress)
insertedTx := mustInsertInProgressEthTxWithAttempt(t, txStore, 123, fromAddress)
tx, err := txStore.GetTxByID(testutils.Context(t), insertedTx.ID)
require.NoError(t, err)
require.NotNil(t, tx)
Expand All @@ -1461,7 +1457,7 @@ func TestORM_GetFatalTransactions(t *testing.T) {
})

t.Run("get fatal transactions", func(t *testing.T) {
fatalTx := cltest.MustInsertFatalErrorEthTx(t, txStore, fromAddress)
fatalTx := mustInsertFatalErrorEthTx(t, txStore, fromAddress)
txes, err := txStore.GetFatalTransactions(testutils.Context(t))
require.NoError(t, err)
require.Equal(t, txes[0].ID, fatalTx.ID)
Expand Down
10 changes: 5 additions & 5 deletions core/chains/evm/txmgr/tracker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ func TestEthTracker_AddressTracking(t *testing.T) {
inProgressAddr := cltest.MustGenerateRandomKey(t).Address
unconfirmedAddr := cltest.MustGenerateRandomKey(t).Address
confirmedAddr := cltest.MustGenerateRandomKey(t).Address
_ = cltest.MustInsertInProgressEthTxWithAttempt(t, txStore, 123, inProgressAddr)
_ = mustInsertInProgressEthTxWithAttempt(t, txStore, 123, inProgressAddr)
_ = cltest.MustInsertUnconfirmedEthTx(t, txStore, 123, unconfirmedAddr)
_ = cltest.MustInsertConfirmedEthTxWithReceipt(t, txStore, confirmedAddr, 123, 1)
_ = mustInsertConfirmedEthTxWithReceipt(t, txStore, confirmedAddr, 123, 1)

err := tracker.Start(context.Background())
require.NoError(t, err)
Expand All @@ -91,7 +91,7 @@ func TestEthTracker_AddressTracking(t *testing.T) {
t.Run("stop tracking finalized tx", func(t *testing.T) {
tracker, txStore, _, _ := newTestEvmTrackerSetup(t)
confirmedAddr := cltest.MustGenerateRandomKey(t).Address
_ = cltest.MustInsertConfirmedEthTxWithReceipt(t, txStore, confirmedAddr, 123, 1)
_ = mustInsertConfirmedEthTxWithReceipt(t, txStore, confirmedAddr, 123, 1)

err := tracker.Start(context.Background())
require.NoError(t, err)
Expand All @@ -118,7 +118,7 @@ func TestEthTracker_ExceedingTTL(t *testing.T) {
t.Run("confirmed but unfinalized transaction still tracked", func(t *testing.T) {
tracker, txStore, _, _ := newTestEvmTrackerSetup(t)
addr1 := cltest.MustGenerateRandomKey(t).Address
_ = cltest.MustInsertConfirmedEthTxWithReceipt(t, txStore, addr1, 123, 1)
_ = mustInsertConfirmedEthTxWithReceipt(t, txStore, addr1, 123, 1)

err := tracker.Start(context.Background())
require.NoError(t, err)
Expand All @@ -134,7 +134,7 @@ func TestEthTracker_ExceedingTTL(t *testing.T) {
tracker, txStore, _, _ := newTestEvmTrackerSetup(t)
addr1 := cltest.MustGenerateRandomKey(t).Address
addr2 := cltest.MustGenerateRandomKey(t).Address
tx1 := cltest.MustInsertInProgressEthTxWithAttempt(t, txStore, 123, addr1)
tx1 := mustInsertInProgressEthTxWithAttempt(t, txStore, 123, addr1)
tx2 := cltest.MustInsertUnconfirmedEthTx(t, txStore, 123, addr2)

tracker.XXXTestSetTTL(time.Nanosecond)
Expand Down

0 comments on commit 969f50a

Please sign in to comment.