-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CCIP-2917] core/capabilities/ccip: use relayers instead of legacyevm (…
…#14611) * core/capabilities/ccip: use relayers instead of legacyevm * fix lint * address CR comments * fix * goimports
- Loading branch information
Showing
6 changed files
with
278 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
core/capabilities/ccip/configs/evm/chain_writer_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
package evm_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/ethereum/go-ethereum/common" | ||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/smartcontractkit/chainlink-ccip/pkg/consts" | ||
"github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/configs/evm" | ||
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets" | ||
) | ||
|
||
func TestChainWriterConfigRaw(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
fromAddress common.Address | ||
maxGasPrice *assets.Wei | ||
commitGasLimit uint64 | ||
execBatchGasLimit uint64 | ||
expectedError string | ||
}{ | ||
{ | ||
name: "valid input", | ||
fromAddress: common.HexToAddress("0x1234567890abcdef1234567890abcdef12345678"), | ||
maxGasPrice: assets.NewWeiI(1000000000), | ||
commitGasLimit: 21000, | ||
execBatchGasLimit: 42000, | ||
expectedError: "", | ||
}, | ||
{ | ||
name: "zero fromAddress", | ||
fromAddress: common.HexToAddress("0x0"), | ||
maxGasPrice: assets.NewWeiI(1000000000), | ||
commitGasLimit: 21000, | ||
execBatchGasLimit: 42000, | ||
expectedError: "fromAddress cannot be zero", | ||
}, | ||
{ | ||
name: "nil maxGasPrice", | ||
fromAddress: common.HexToAddress("0x1234567890abcdef1234567890abcdef12345678"), | ||
maxGasPrice: nil, | ||
commitGasLimit: 21000, | ||
execBatchGasLimit: 42000, | ||
expectedError: "maxGasPrice cannot be nil", | ||
}, | ||
{ | ||
name: "zero maxGasPrice", | ||
fromAddress: common.HexToAddress("0x1234567890abcdef1234567890abcdef12345678"), | ||
maxGasPrice: assets.NewWeiI(0), | ||
commitGasLimit: 21000, | ||
execBatchGasLimit: 42000, | ||
expectedError: "maxGasPrice must be greater than zero", | ||
}, | ||
{ | ||
name: "negative maxGasPrice", | ||
fromAddress: common.HexToAddress("0x1234567890abcdef1234567890abcdef12345678"), | ||
maxGasPrice: assets.NewWeiI(-1), | ||
commitGasLimit: 21000, | ||
execBatchGasLimit: 42000, | ||
expectedError: "maxGasPrice must be greater than zero", | ||
}, | ||
{ | ||
name: "zero commitGasLimit", | ||
fromAddress: common.HexToAddress("0x1234567890abcdef1234567890abcdef12345678"), | ||
maxGasPrice: assets.NewWeiI(1000000000), | ||
commitGasLimit: 0, | ||
execBatchGasLimit: 42000, | ||
expectedError: "commitGasLimit must be greater than zero", | ||
}, | ||
{ | ||
name: "zero execBatchGasLimit", | ||
fromAddress: common.HexToAddress("0x1234567890abcdef1234567890abcdef12345678"), | ||
maxGasPrice: assets.NewWeiI(1000000000), | ||
commitGasLimit: 21000, | ||
execBatchGasLimit: 0, | ||
expectedError: "execBatchGasLimit must be greater than zero", | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
config, err := evm.ChainWriterConfigRaw(tt.fromAddress, tt.maxGasPrice, tt.commitGasLimit, tt.execBatchGasLimit) | ||
if tt.expectedError != "" { | ||
assert.EqualError(t, err, tt.expectedError) | ||
} else { | ||
assert.NoError(t, err) | ||
assert.Equal(t, | ||
tt.fromAddress, | ||
config.Contracts[consts.ContractNameOffRamp].Configs[consts.MethodCommit].FromAddress) | ||
assert.Equal(t, | ||
tt.commitGasLimit, | ||
config.Contracts[consts.ContractNameOffRamp].Configs[consts.MethodCommit].GasLimit) | ||
assert.Equal(t, | ||
tt.execBatchGasLimit, | ||
config.Contracts[consts.ContractNameOffRamp].Configs[consts.MethodExecute].GasLimit) | ||
assert.Equal(t, | ||
tt.maxGasPrice, | ||
config.MaxGasPrice) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.