Skip to content

Commit

Permalink
move back to core/capabilities until ./integration-tests is ready wit…
Browse files Browse the repository at this point in the history
…h postgres setup
  • Loading branch information
asoliman92 committed Nov 27, 2024
1 parent 188945a commit 2c6c21b
Show file tree
Hide file tree
Showing 6 changed files with 689 additions and 37 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package ccipdeployment
package ccip_integration_tests

import (
"context"
"github.com/google/uuid"
"github.com/jmoiron/sqlx"
"github.com/scylladb/go-reflectx"
"github.com/smartcontractkit/chainlink-ccip/plugintypes"
"github.com/smartcontractkit/chainlink/deployment/ccip/changeset"
"github.com/smartcontractkit/chainlink/deployment/environment/memory"
"github.com/smartcontractkit/chainlink/v2/core/store/dialects"
"math/big"
Expand Down Expand Up @@ -513,15 +514,16 @@ func TestCCIPReader_NextSeqNum(t *testing.T) {

func TestCCIPReader_GetExpectedNextSequenceNumber(t *testing.T) {
ctx := tests.Context(t)
env := NewMemoryEnvironmentContractsOnly(t, logger.TestLogger(t), 2, 4)
state, err := LoadOnchainState(env.Env)
//env := NewMemoryEnvironmentContractsOnly(t, logger.TestLogger(t), 2, 4, nil)
env := changeset.NewMemoryEnvironmentWithJobsAndContracts(t, logger.TestLogger(t), 2, 4, nil)
state, err := changeset.LoadOnchainState(env.Env)
require.NoError(t, err)

selectors := env.Env.AllChainSelectors()
destChain, srcChain := selectors[0], selectors[1]

require.NoError(t, AddLaneWithDefaultPrices(env.Env, state, destChain, srcChain))
require.NoError(t, AddLaneWithDefaultPrices(env.Env, state, srcChain, destChain))
require.NoError(t, changeset.AddLaneWithDefaultPrices(env.Env, state, destChain, srcChain))
require.NoError(t, changeset.AddLaneWithDefaultPrices(env.Env, state, srcChain, destChain))

reader := testSetupRealContracts(
ctx,
Expand All @@ -541,8 +543,8 @@ func TestCCIPReader_GetExpectedNextSequenceNumber(t *testing.T) {

maxExpectedSeqNum := 10
for i := 1; i < maxExpectedSeqNum; i++ {
msg := DefaultRouterMessage(state.Chains[destChain].Receiver.Address())
msgSentEvent := TestSendRequest(t, env.Env, state, srcChain, destChain, false, msg)
msg := changeset.DefaultRouterMessage(state.Chains[destChain].Receiver.Address())
msgSentEvent := changeset.TestSendRequest(t, env.Env, state, srcChain, destChain, false, msg)
require.Equal(t, uint64(i), msgSentEvent.SequenceNumber)
require.Equal(t, uint64(i), msgSentEvent.Message.Header.Nonce) // check outbound nonce incremented
seqNum, err2 := reader.GetExpectedNextSequenceNumber(ctx, cs(srcChain), cs(destChain))
Expand Down Expand Up @@ -619,15 +621,15 @@ func TestCCIPReader_Nonces(t *testing.T) {

func Test_GetChainFeePriceUpdates(t *testing.T) {
ctx := tests.Context(t)
env := NewMemoryEnvironmentContractsOnly(t, logger.TestLogger(t), 2, 4)
state, err := LoadOnchainState(env.Env)
env := changeset.NewMemoryEnvironmentWithJobsAndContracts(t, logger.TestLogger(t), 2, 4, nil)
state, err := changeset.LoadOnchainState(env.Env)
require.NoError(t, err)

selectors := env.Env.AllChainSelectors()
chain1, chain2 := selectors[0], selectors[1]

require.NoError(t, AddLaneWithDefaultPrices(env.Env, state, chain1, chain2))
require.NoError(t, AddLaneWithDefaultPrices(env.Env, state, chain2, chain1))
require.NoError(t, changeset.AddLaneWithDefaultPrices(env.Env, state, chain1, chain2))
require.NoError(t, changeset.AddLaneWithDefaultPrices(env.Env, state, chain2, chain1))

// Change the gas price for chain2
feeQuoter := state.Chains[chain1].FeeQuoter
Expand Down Expand Up @@ -673,15 +675,15 @@ func Test_GetChainFeePriceUpdates(t *testing.T) {

func Test_LinkPriceUSD(t *testing.T) {
ctx := tests.Context(t)
env := NewMemoryEnvironmentContractsOnly(t, logger.TestLogger(t), 2, 4)
state, err := LoadOnchainState(env.Env)
env := changeset.NewMemoryEnvironmentWithJobsAndContracts(t, logger.TestLogger(t), 2, 4, nil)
state, err := changeset.LoadOnchainState(env.Env)
require.NoError(t, err)

selectors := env.Env.AllChainSelectors()
chain1, chain2 := selectors[0], selectors[1]

require.NoError(t, AddLaneWithDefaultPrices(env.Env, state, chain1, chain2))
require.NoError(t, AddLaneWithDefaultPrices(env.Env, state, chain2, chain1))
require.NoError(t, changeset.AddLaneWithDefaultPrices(env.Env, state, chain1, chain2))
require.NoError(t, changeset.AddLaneWithDefaultPrices(env.Env, state, chain2, chain1))

reader := testSetupRealContracts(
ctx,
Expand All @@ -702,26 +704,26 @@ func Test_LinkPriceUSD(t *testing.T) {
linkPriceUSD, err := reader.LinkPriceUSD(ctx)
require.NoError(t, err)
require.NotNil(t, linkPriceUSD.Int)
require.Equal(t, DefaultInitialPrices.LinkPrice, linkPriceUSD.Int)
require.Equal(t, changeset.DefaultInitialPrices.LinkPrice, linkPriceUSD.Int)
}

func Test_GetMedianDataAvailabilityGasConfig(t *testing.T) {
ctx := tests.Context(t)
env := NewMemoryEnvironmentContractsOnly(t, logger.TestLogger(t), 4, 4)
state, err := LoadOnchainState(env.Env)
env := changeset.NewMemoryEnvironmentWithJobsAndContracts(t, logger.TestLogger(t), 4, 4, nil)
state, err := changeset.LoadOnchainState(env.Env)
require.NoError(t, err)

selectors := env.Env.AllChainSelectors()
destChain, chain1, chain2, chain3 := selectors[0], selectors[1], selectors[2], selectors[3]

require.NoError(t, AddLaneWithDefaultPrices(env.Env, state, chain1, destChain))
require.NoError(t, AddLaneWithDefaultPrices(env.Env, state, chain2, destChain))
require.NoError(t, AddLaneWithDefaultPrices(env.Env, state, chain3, destChain))
require.NoError(t, changeset.AddLaneWithDefaultPrices(env.Env, state, chain1, destChain))
require.NoError(t, changeset.AddLaneWithDefaultPrices(env.Env, state, chain2, destChain))
require.NoError(t, changeset.AddLaneWithDefaultPrices(env.Env, state, chain3, destChain))

boundContracts := map[cciptypes.ChainSelector][]types.BoundContract{}
for i, selector := range env.Env.AllChainSelectorsExcluding([]uint64{destChain}) {
feeQuoter := state.Chains[selector].FeeQuoter
destChainCfg := DefaultFeeQuoterDestChainConfig()
destChainCfg := changeset.DefaultFeeQuoterDestChainConfig()
//nolint:gosec // disable G115
destChainCfg.DestDataAvailabilityOverheadGas = uint32(100 + i)
//nolint:gosec // disable G115
Expand Down Expand Up @@ -765,15 +767,15 @@ func Test_GetMedianDataAvailabilityGasConfig(t *testing.T) {

func Test_GetWrappedNativeTokenPriceUSD(t *testing.T) {
ctx := tests.Context(t)
env := NewMemoryEnvironmentContractsOnly(t, logger.TestLogger(t), 2, 4)
state, err := LoadOnchainState(env.Env)
env := changeset.NewMemoryEnvironmentWithJobsAndContracts(t, logger.TestLogger(t), 2, 4, nil)
state, err := changeset.LoadOnchainState(env.Env)
require.NoError(t, err)

selectors := env.Env.AllChainSelectors()
chain1, chain2 := selectors[0], selectors[1]

require.NoError(t, AddLaneWithDefaultPrices(env.Env, state, chain1, chain2))
require.NoError(t, AddLaneWithDefaultPrices(env.Env, state, chain2, chain1))
require.NoError(t, changeset.AddLaneWithDefaultPrices(env.Env, state, chain1, chain2))
require.NoError(t, changeset.AddLaneWithDefaultPrices(env.Env, state, chain2, chain1))

reader := testSetupRealContracts(
ctx,
Expand All @@ -799,7 +801,7 @@ func Test_GetWrappedNativeTokenPriceUSD(t *testing.T) {

// Only chainD has reader contracts bound
require.Len(t, prices, 1)
require.Equal(t, DefaultInitialPrices.WethPrice, prices[cciptypes.ChainSelector(chain1)].Int)
require.Equal(t, changeset.DefaultInitialPrices.WethPrice, prices[cciptypes.ChainSelector(chain1)].Int)
}

func setupSimulatedBackendAndAuth(t *testing.T) (*simulated.Backend, *bind.TransactOpts) {
Expand All @@ -825,7 +827,7 @@ func testSetupRealContracts(
destChain uint64,
toBindContracts map[cciptypes.ChainSelector][]types.BoundContract,
toMockBindings map[cciptypes.ChainSelector][]types.BoundContract,
env DeployedEnv,
env changeset.DeployedEnv,
) ccipreaderpkg.CCIPReader {
db := NewSqlxDB(t)
lpOpts := logpoller.Opts{
Expand Down
10 changes: 10 additions & 0 deletions deployment/ccip/changeset/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -958,3 +958,13 @@ func deployTransferTokenOneEnd(

return tokenContract.Contract, tokenPool.Contract, nil
}

func DefaultRouterMessage(receiverAddress common.Address) router.ClientEVM2AnyMessage {
return router.ClientEVM2AnyMessage{
Receiver: common.LeftPadBytes(receiverAddress.Bytes(), 32),
Data: []byte("hello world"),
TokenAmounts: nil,
FeeToken: common.HexToAddress("0x0"),
ExtraArgs: nil,
}
}
4 changes: 2 additions & 2 deletions deployment/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@ require (
github.com/google/uuid v1.6.0
github.com/hashicorp/consul/sdk v0.16.1
github.com/hashicorp/go-multierror v1.1.1
github.com/jmoiron/sqlx v1.4.0
github.com/pelletier/go-toml/v2 v2.2.3
github.com/pkg/errors v0.9.1
github.com/rs/zerolog v1.33.0
github.com/scylladb/go-reflectx v1.0.1
github.com/sethvargo/go-retry v0.2.4
github.com/smartcontractkit/ccip-owner-contracts v0.0.0-20240926212305-a6deabdfce86
github.com/smartcontractkit/chain-selectors v1.0.30
Expand Down Expand Up @@ -304,6 +302,7 @@ require (
github.com/jackpal/go-nat-pmp v1.0.2 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/jmoiron/sqlx v1.4.0 // indirect
github.com/joho/godotenv v1.5.1 // indirect
github.com/jonboulle/clockwork v0.4.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
Expand Down Expand Up @@ -393,6 +392,7 @@ require (
github.com/sanity-io/litter v1.5.5 // indirect
github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 // indirect
github.com/sasha-s/go-deadlock v0.3.1 // indirect
github.com/scylladb/go-reflectx v1.0.1 // indirect
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 // indirect
github.com/sercand/kuberesolver/v5 v5.1.1 // indirect
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
Expand Down
8 changes: 4 additions & 4 deletions deployment/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,8 @@ github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg=
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
github.com/cncf/xds/go v0.0.0-20240723142845-024c85f92f20 h1:N+3sFI5GUjRKBi+i0TxYVST9h4Ie192jJWpHvthBBgg=
github.com/cncf/xds/go v0.0.0-20240723142845-024c85f92f20/go.mod h1:W+zGtBO5Y1IgJhy4+A9GOqVhqLpfZi+vwmdNXUehLA8=
github.com/cncf/xds/go v0.0.0-20240905190251-b4127c9b8d78 h1:QVw89YDxXxEe+l8gU8ETbOasdwEV+avkR75ZzsVV9WI=
github.com/cncf/xds/go v0.0.0-20240905190251-b4127c9b8d78/go.mod h1:W+zGtBO5Y1IgJhy4+A9GOqVhqLpfZi+vwmdNXUehLA8=
github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I=
github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ=
github.com/cockroachdb/apd/v2 v2.0.2 h1:weh8u7Cneje73dDh+2tEVLUvyBc89iwepWCD8b8034E=
Expand Down Expand Up @@ -480,8 +480,8 @@ github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymF
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
github.com/envoyproxy/go-control-plane v0.13.0 h1:HzkeUz1Knt+3bK+8LG1bxOO/jzWZmdxpwC51i202les=
github.com/envoyproxy/go-control-plane v0.13.0/go.mod h1:GRaKG3dwvFoTg4nj7aXdZnvMg4d7nvT/wl9WgVXn3Q8=
github.com/envoyproxy/go-control-plane v0.13.1 h1:vPfJZCkob6yTMEgS+0TwfTUfbHjfy/6vOJ8hUWX/uXE=
github.com/envoyproxy/go-control-plane v0.13.1/go.mod h1:X45hY0mufo6Fd0KW3rqsGvQMw58jvjymeCzBU3mWyHw=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/envoyproxy/protoc-gen-validate v1.1.0 h1:tntQDh69XqOCOZsDz0lVJQez/2L6Uu2PdjCQwWCJ3bM=
github.com/envoyproxy/protoc-gen-validate v1.1.0/go.mod h1:sXRDRVmzEbkM7CVcM06s9shE/m23dg3wzjl0UWqJ2q4=
Expand Down
Loading

0 comments on commit 2c6c21b

Please sign in to comment.