@@ -7,8 +7,10 @@ import (
77 "github.com/ethereum/go-ethereum/common"
88 "github.com/stretchr/testify/assert"
99 "github.com/stretchr/testify/require"
10+ "go.uber.org/zap"
1011
1112 "github.com/smartcontractkit/chainlink-common/pkg/logger"
13+ "github.com/smartcontractkit/chainlink-common/pkg/utils/tests"
1214 "github.com/smartcontractkit/chainlink-evm/pkg/assets"
1315 "github.com/smartcontractkit/chainlink-evm/pkg/gas"
1416 "github.com/smartcontractkit/chainlink-evm/pkg/testutils"
@@ -21,6 +23,7 @@ func TestMetaErrorHandler(t *testing.T) {
2123 require .NotNil (t , errorHandler )
2224
2325 t .Run ("handles no bids error for first attempt" , func (t * testing.T ) {
26+ lggr , observedLogs := logger .TestObserved (t , zap .InfoLevel )
2427 nonce := uint64 (1 )
2528 address := testutils .NewAddress ()
2629 txRequest := & types.TxRequest {
@@ -29,7 +32,7 @@ func TestMetaErrorHandler(t *testing.T) {
2932 ToAddress : testutils .NewAddress (),
3033 }
3134 setNonce := func (address common.Address , nonce uint64 ) {}
32- txStoreManager := storage .NewInMemoryStoreManager (logger . Test ( t ) , testutils .FixtureChainID )
35+ txStoreManager := storage .NewInMemoryStoreManager (lggr , testutils .FixtureChainID )
3336 require .NoError (t , txStoreManager .Add (address ))
3437 txStore := txStoreManager .InMemoryStoreMap [address ]
3538 _ = txStore .CreateTransaction (txRequest )
@@ -44,9 +47,10 @@ func TestMetaErrorHandler(t *testing.T) {
4447 _ , err = txStore .AppendAttemptToTransaction (* tx .Nonce , attempt )
4548 require .NoError (t , err )
4649 tx , _ = txStore .FetchUnconfirmedTransactionAtNonceWithCount (nonce )
47- err = errorHandler .HandleError (t .Context (), tx , ErrNoBids , txStoreManager , setNonce , false )
48- require .Error (t , err )
49- require .ErrorContains (t , err , "transaction with txID: 0 marked as fatal" )
50+ noTransmission , err := errorHandler .HandleError (t .Context (), lggr , tx , ErrNoBids , txStoreManager , setNonce )
51+ require .NoError (t , err )
52+ require .True (t , noTransmission )
53+ tests .AssertLogEventually (t , observedLogs , "transaction marked as fatal" )
5054 _ , unconfirmedCount := txStore .FetchUnconfirmedTransactionAtNonceWithCount (nonce )
5155 assert .Equal (t , 0 , unconfirmedCount )
5256 })
@@ -78,14 +82,15 @@ func TestMetaErrorHandler(t *testing.T) {
7882 _ , err = txStore .AppendAttemptToTransaction (* tx .Nonce , attempt )
7983 require .NoError (t , err )
8084 tx , _ = txStore .FetchUnconfirmedTransactionAtNonceWithCount (nonce )
81- err = errorHandler .HandleError (t .Context (), tx , txErr , txStoreManager , setNonce , false )
82- require .Error (t , err )
83- require .ErrorIs (t , err , txErr )
85+ noTransmission , err : = errorHandler .HandleError (t .Context (), logger . Test ( t ), tx , txErr , txStoreManager , setNonce )
86+ require .NoError (t , err )
87+ require .False (t , noTransmission )
8488 _ , unconfirmedCount := txStore .FetchUnconfirmedTransactionAtNonceWithCount (nonce )
8589 assert .Equal (t , 1 , unconfirmedCount )
8690 })
8791
8892 t .Run ("handles auction error for first attempt" , func (t * testing.T ) {
93+ lggr , observedLogs := logger .TestObserved (t , zap .InfoLevel )
8994 nonce := uint64 (1 )
9095 address := testutils .NewAddress ()
9196 txRequest := & types.TxRequest {
@@ -95,7 +100,7 @@ func TestMetaErrorHandler(t *testing.T) {
95100 }
96101 txErr := ErrAuction
97102 setNonce := func (address common.Address , nonce uint64 ) {}
98- txStoreManager := storage .NewInMemoryStoreManager (logger . Test ( t ) , testutils .FixtureChainID )
103+ txStoreManager := storage .NewInMemoryStoreManager (lggr , testutils .FixtureChainID )
99104 require .NoError (t , txStoreManager .Add (address ))
100105 txStore := txStoreManager .InMemoryStoreMap [address ]
101106 _ = txStore .CreateTransaction (txRequest )
@@ -110,9 +115,10 @@ func TestMetaErrorHandler(t *testing.T) {
110115 _ , err = txStore .AppendAttemptToTransaction (* tx .Nonce , attempt )
111116 require .NoError (t , err )
112117 tx , _ = txStore .FetchUnconfirmedTransactionAtNonceWithCount (nonce )
113- err = errorHandler .HandleError (t .Context (), tx , txErr , txStoreManager , setNonce , false )
114- require .Error (t , err )
115- require .ErrorContains (t , err , "transaction with txID: 0 marked as fatal" )
118+ noTransmission , err := errorHandler .HandleError (t .Context (), lggr , tx , txErr , txStoreManager , setNonce )
119+ require .NoError (t , err )
120+ require .True (t , noTransmission )
121+ tests .AssertLogEventually (t , observedLogs , "transaction marked as fatal" )
116122 _ , unconfirmedCount := txStore .FetchUnconfirmedTransactionAtNonceWithCount (nonce )
117123 assert .Equal (t , 0 , unconfirmedCount )
118124 })
0 commit comments