Skip to content

Commit

Permalink
Add TestCCIPReader_GetLatestPriceSeqNr
Browse files Browse the repository at this point in the history
  • Loading branch information
asoliman92 committed Nov 27, 2024
1 parent 2c6c21b commit 687a3df
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 4 deletions.
12 changes: 12 additions & 0 deletions contracts/src/v0.8/ccip/test/helpers/CCIPReaderTester.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ contract CCIPReaderTester {
mapping(uint64 sourceChainSelector => OffRamp.SourceChainConfig sourceChainConfig) internal s_sourceChainConfigs;
mapping(uint64 destChainSelector => uint64 sequenceNumber) internal s_destChainSeqNrs;
mapping(uint64 sourceChainSelector => mapping(bytes sender => uint64 nonce)) internal s_senderNonce;
uint64 private s_latestPriceSequenceNumber;

/// @notice Gets the next sequence number to be used in the onRamp
/// @param destChainSelector The destination chain selector
Expand Down Expand Up @@ -52,6 +53,17 @@ contract CCIPReaderTester {
s_sourceChainConfigs[sourceChainSelector] = sourceChainConfig;
}

/// @notice sets the sequence number of the last price update.
function setLatestPriceSequenceNumber(uint64 seqNr) external {
s_latestPriceSequenceNumber = seqNr;
}

/// @notice Returns the sequence number of the last price update.
/// @return sequenceNumber The latest price update sequence number.
function getLatestPriceSequenceNumber() external view returns (uint64) {
return s_latestPriceSequenceNumber;
}

function emitCCIPMessageSent(uint64 destChainSelector, Internal.EVM2AnyRampMessage memory message) external {
emit OnRamp.CCIPMessageSent(destChainSelector, message.header.sequenceNumber, message);
}
Expand Down
43 changes: 43 additions & 0 deletions core/capabilities/ccip/ccip_integration_tests/ccipreader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,49 @@ func TestCCIPReader_CommitReportsGTETimestamp_RespectsFinality(t *testing.T) {
assert.Equal(t, uint64(90), reports[0].Report.PriceUpdates.GasPriceUpdates[0].GasPrice.Uint64())
}

func TestCCIPReader_GetLatestPriceSeqNr(t *testing.T) {
ctx := tests.Context(t)

cfg := evmtypes.ChainReaderConfig{
Contracts: map[string]evmtypes.ChainContractReader{
consts.ContractNameOffRamp: {
ContractABI: ccip_reader_tester.CCIPReaderTesterABI,
Configs: map[string]*evmtypes.ChainReaderDefinition{
consts.MethodNameGetLatestPriceSequenceNumber: {
ChainSpecificName: "getLatestPriceSequenceNumber",
ReadType: evmtypes.Method,
},
},
},
},
}

sb, auth := setupSimulatedBackendAndAuth(t)
s := testSetup(ctx, t, testSetupParams{
ReaderChain: chainD,
DestChain: chainD,
OnChainSeqNums: nil,
Cfg: cfg,
ToBindContracts: nil,
ToMockBindings: nil,
BindTester: true,
SimulatedBackend: sb,
Auth: auth,
})

seqNr, err := s.reader.GetLatestPriceSeqNr(ctx)
require.NoError(t, err)
require.Equal(t, uint64(0), seqNr)

_, err = s.contract.SetLatestPriceSequenceNumber(s.auth, 10)
require.NoError(t, err)
s.sb.Commit()

seqNr, err = s.reader.GetLatestPriceSeqNr(ctx)
require.NoError(t, err)
require.Equal(t, uint64(10), seqNr)
}

func TestCCIPReader_ExecutedMessageRanges(t *testing.T) {
ctx := tests.Context(t)
cfg := evmtypes.ChainReaderConfig{
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ burn_mint_token_pool: ../../../contracts/solc/v0.8.24/BurnMintTokenPool/BurnMint
burn_with_from_mint_token_pool: ../../../contracts/solc/v0.8.24/BurnWithFromMintTokenPool/BurnWithFromMintTokenPool.abi ../../../contracts/solc/v0.8.24/BurnWithFromMintTokenPool/BurnWithFromMintTokenPool.bin e136c9f7a1d7af46ed5bd5bb836317c97715a71ee024868251abd0c462f1f115
ccip_encoding_utils: ../../../contracts/solc/v0.8.24/ICCIPEncodingUtils/ICCIPEncodingUtils.abi ../../../contracts/solc/v0.8.24/ICCIPEncodingUtils/ICCIPEncodingUtils.bin 9971fc93c34442a0989570d3dab90a125de31e6e60754ad972807ce6ad4dfba0
ccip_home: ../../../contracts/solc/v0.8.24/CCIPHome/CCIPHome.abi ../../../contracts/solc/v0.8.24/CCIPHome/CCIPHome.bin 02cb75b4274a5be7f4006cf2b72cc09e77eb6dba4c1a9c720af86668ff8ea1df
ccip_reader_tester: ../../../contracts/solc/v0.8.24/CCIPReaderTester/CCIPReaderTester.abi ../../../contracts/solc/v0.8.24/CCIPReaderTester/CCIPReaderTester.bin 893c9930e874fe5235db24e28a22650c37f562da94fac93618566bcd84839fdc
ccip_reader_tester: ../../../contracts/solc/v0.8.24/CCIPReaderTester/CCIPReaderTester.abi ../../../contracts/solc/v0.8.24/CCIPReaderTester/CCIPReaderTester.bin b368699ae7dbee7c21d049a641642837f18ce2cc8d4ece69509f205de673108e
ether_sender_receiver: ../../../contracts/solc/v0.8.24/EtherSenderReceiver/EtherSenderReceiver.abi ../../../contracts/solc/v0.8.24/EtherSenderReceiver/EtherSenderReceiver.bin 09510a3f773f108a3c231e8d202835c845ded862d071ec54c4f89c12d868b8de
fee_quoter: ../../../contracts/solc/v0.8.24/FeeQuoter/FeeQuoter.abi ../../../contracts/solc/v0.8.24/FeeQuoter/FeeQuoter.bin 8a0869d14bb5247fbc6d836fc20d123358373ed688e0d3b387d59e7d05496fea
lock_release_token_pool: ../../../contracts/solc/v0.8.24/LockReleaseTokenPool/LockReleaseTokenPool.abi ../../../contracts/solc/v0.8.24/LockReleaseTokenPool/LockReleaseTokenPool.bin b30d5520449d57a4fffa3c3675e46d50ad29b066e09c16971153538a38ab25f7
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ require (
github.com/shopspring/decimal v1.4.0
github.com/smartcontractkit/chain-selectors v1.0.30
github.com/smartcontractkit/chainlink-automation v0.8.1
github.com/smartcontractkit/chainlink-ccip v0.0.0-20241118091009-43c2b4804cec
github.com/smartcontractkit/chainlink-ccip v0.0.0-20241127182333-50dbe05c45d1
github.com/smartcontractkit/chainlink-common v0.3.1-0.20241120111740-a6a70ec7692b
github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241017133723-5277829bd53f
github.com/smartcontractkit/chainlink-data-streams v0.1.1-0.20241114154055-8d29ea018b57
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1405,6 +1405,8 @@ github.com/smartcontractkit/chainlink-automation v0.8.1 h1:sTc9LKpBvcKPc1JDYAmgB
github.com/smartcontractkit/chainlink-automation v0.8.1/go.mod h1:Iij36PvWZ6blrdC5A/nrQUBuf3MH3JvsBB9sSyc9W08=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20241118091009-43c2b4804cec h1:5vS1k8Qn09p8SQ3JzvS8iy4Pve7s3aVq+UPIdl74smY=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20241118091009-43c2b4804cec/go.mod h1:4adKaHNaxFsRvV/lYfqtbsWyyvIPUMLR0FdOJN/ljis=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20241127182333-50dbe05c45d1 h1:I4WzhoYHfU4kF90LQihWqPbkIw+hRuV9Ee/zMZDuufE=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20241127182333-50dbe05c45d1/go.mod h1:4adKaHNaxFsRvV/lYfqtbsWyyvIPUMLR0FdOJN/ljis=
github.com/smartcontractkit/chainlink-common v0.3.1-0.20241120111740-a6a70ec7692b h1:mm46AlaafEhvGjJvuAb0VoLLM3NKAVnwKZ+iUCNL/sg=
github.com/smartcontractkit/chainlink-common v0.3.1-0.20241120111740-a6a70ec7692b/go.mod h1:ny87uTW6hLjCTLiBqBRNFEhETSXhHWevYlPclT5lSco=
github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241017133723-5277829bd53f h1:BwrIaQIx5Iy6eT+DfLhFfK2XqjxRm74mVdlX8gbu4dw=
Expand Down

0 comments on commit 687a3df

Please sign in to comment.