From bd2a850b37d8c6d61c59c246cc27c960e16428cd Mon Sep 17 00:00:00 2001 From: "valerii.kabisov" Date: Mon, 23 Sep 2024 21:11:01 +0900 Subject: [PATCH] [CCIP-3376] fix test --- .../interceptors/mantle/interceptor_test.go | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/core/services/ocr2/plugins/ccip/estimatorconfig/interceptors/mantle/interceptor_test.go b/core/services/ocr2/plugins/ccip/estimatorconfig/interceptors/mantle/interceptor_test.go index 8a8845345d..a555ffcc42 100644 --- a/core/services/ocr2/plugins/ccip/estimatorconfig/interceptors/mantle/interceptor_test.go +++ b/core/services/ocr2/plugins/ccip/estimatorconfig/interceptors/mantle/interceptor_test.go @@ -17,22 +17,28 @@ func TestInterceptor(t *testing.T) { ethClient := mocks.NewClient(t) ctx := context.Background() - tokenRatio := big.NewInt(10) + tokenRatio := big.NewInt(100) + decimals := big.NewInt(1) interceptor := NewInterceptor(ctx, ethClient) + // request token ratio ethClient.On("CallContract", ctx, mock.IsType(ethereum.CallMsg{}), mock.IsType(&big.Int{})). - Return(common.BigToHash(tokenRatio).Bytes(), nil) + Return(common.BigToHash(tokenRatio).Bytes(), nil).Once() + + // request decimals + ethClient.On("CallContract", ctx, mock.IsType(ethereum.CallMsg{}), mock.IsType(&big.Int{})). + Return(common.BigToHash(decimals).Bytes(), nil).Once() modExecGasPrice, modDAGasPrice, err := interceptor.ModifyGasPriceComponents(ctx, big.NewInt(1), big.NewInt(1)) require.NoError(t, err) - require.Equal(t, modExecGasPrice.Int64(), int64(10)) - require.Equal(t, modDAGasPrice.Int64(), int64(10)) + require.Equal(t, int64(10), modExecGasPrice.Int64()) + require.Equal(t, int64(10), modDAGasPrice.Int64()) // second call won't invoke eth client modExecGasPrice, modDAGasPrice, err = interceptor.ModifyGasPriceComponents(ctx, big.NewInt(2), big.NewInt(1)) require.NoError(t, err) - require.Equal(t, modExecGasPrice.Int64(), int64(20)) - require.Equal(t, modDAGasPrice.Int64(), int64(10)) + require.Equal(t, int64(20), modExecGasPrice.Int64()) + require.Equal(t, int64(10), modDAGasPrice.Int64()) } func TestModifyGasPriceComponents(t *testing.T) { @@ -101,9 +107,11 @@ func TestModifyGasPriceComponents(t *testing.T) { interceptor := NewInterceptor(ctx, ethClient) + // request token ratio ethClient.On("CallContract", ctx, mock.IsType(ethereum.CallMsg{}), mock.IsType(&big.Int{})). Return(common.BigToHash(tc.tokenRatio).Bytes(), nil).Once() + // request decimals ethClient.On("CallContract", ctx, mock.IsType(ethereum.CallMsg{}), mock.IsType(&big.Int{})). Return(common.BigToHash(tc.decimals).Bytes(), nil).Once()