Skip to content

Commit

Permalink
fixing unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
0xnogo committed Jul 29, 2024
1 parent 5b88076 commit 7af85ab
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions core/services/ocr2/plugins/ccip/transmitter/transmitter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"testing"

"github.com/ethereum/go-ethereum/common"
"github.com/pkg/errors"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"

Expand All @@ -22,7 +23,6 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey"
"github.com/smartcontractkit/chainlink/v2/core/services/ocrcommon"

"github.com/smartcontractkit/chainlink/v2/core/services/relay/evm/statuschecker/mocks"
"github.com/smartcontractkit/chainlink/v2/core/utils"
)

Expand Down Expand Up @@ -197,7 +197,6 @@ func Test_Transmitter_With_StatusChecker_CreateEthTransaction(t *testing.T) {
effectiveTransmitterAddress := fromAddress
txm := txmmocks.NewMockEvmTxManager(t)
strategy := newMockTxStrategy(t)
statusChecker := mocks.NewCCIPTransactionStatusChecker(t)
toAddress := testutils.NewAddress()
payload := []byte{1, 2, 3}
idempotencyKey := "1-0"
Expand All @@ -212,11 +211,11 @@ func Test_Transmitter_With_StatusChecker_CreateEthTransaction(t *testing.T) {
txmgr.TransmitCheckerSpec{},
chainID,
ethKeyStore,
statusChecker,
)
require.NoError(t, err)

statusChecker.On("CheckMessageStatus", mock.Anything, "1").Return([]types.TransactionStatus{}, -1, nil).Once()
// This case is for when the message ID was not found in the status checker
txm.On("GetTransactionStatus", mock.Anything, idempotencyKey).Return(types.Unknown, errors.New("dummy")).Once()

txm.On("CreateTransaction", mock.Anything, txmgr.TxRequest{
IdempotencyKey: &idempotencyKey,
Expand All @@ -230,8 +229,7 @@ func Test_Transmitter_With_StatusChecker_CreateEthTransaction(t *testing.T) {
}).Return(txmgr.Tx{}, nil).Once()

require.NoError(t, transmitter.CreateEthTransaction(testutils.Context(t), toAddress, payload, txMeta))
// check that the status checker was called
statusChecker.AssertExpectations(t)
txm.AssertExpectations(t)
}

func NewKeyStore(t testing.TB, ds sqlutil.DataSource) keystore.Master {
Expand Down

0 comments on commit 7af85ab

Please sign in to comment.