Skip to content

Commit

Permalink
additional users in test environment
Browse files Browse the repository at this point in the history
  • Loading branch information
AnieeG committed Dec 3, 2024
1 parent af50c13 commit 1d93e3b
Show file tree
Hide file tree
Showing 25 changed files with 524 additions and 213 deletions.
8 changes: 7 additions & 1 deletion deployment/ccip/changeset/accept_ownership_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/smartcontractkit/chainlink/deployment"
commonchangeset "github.com/smartcontractkit/chainlink/deployment/common/changeset"
commontypes "github.com/smartcontractkit/chainlink/deployment/common/types"
"github.com/smartcontractkit/chainlink/deployment/environment/memory"

"github.com/stretchr/testify/require"
"golang.org/x/exp/maps"
Expand All @@ -21,7 +22,12 @@ import (
)

func Test_NewAcceptOwnershipChangeset(t *testing.T) {
e := NewMemoryEnvironmentWithJobs(t, logger.TestLogger(t), 2, 4)
e := NewMemoryEnvironmentWithJobs(t, logger.TestLogger(t), memory.MemoryEnvironmentConfig{
Chains: 2,
NumOfUsersPerChain: 1,
Nodes: 4,
Bootstraps: 1,
})
state, err := LoadOnchainState(e.Env)
require.NoError(t, err)

Expand Down
8 changes: 7 additions & 1 deletion deployment/ccip/changeset/active_candidate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/smartcontractkit/chainlink-testing-framework/lib/utils/testcontext"

"github.com/smartcontractkit/chainlink/deployment/ccip/changeset/internal"
"github.com/smartcontractkit/chainlink/deployment/environment/memory"
cctypes "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/types"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/router"

Expand All @@ -29,7 +30,12 @@ func TestActiveCandidate(t *testing.T) {
t.Skipf("to be enabled after latest cl-ccip is compatible")

lggr := logger.TestLogger(t)
tenv := NewMemoryEnvironmentWithJobsAndContracts(t, lggr, 3, 5, nil)
tenv := NewMemoryEnvironmentWithJobsAndContracts(t, lggr, memory.MemoryEnvironmentConfig{
Chains: 3,
NumOfUsersPerChain: 1,
Nodes: 5,
Bootstraps: 1,
}, nil)
e := tenv.Env
state, err := LoadOnchainState(tenv.Env)
require.NoError(t, err)
Expand Down
9 changes: 8 additions & 1 deletion deployment/ccip/changeset/add_chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ import (
"time"

"github.com/smartcontractkit/ccip-owner-contracts/pkg/gethwrappers"

"github.com/smartcontractkit/chainlink/deployment/ccip/changeset/internal"
commonchangeset "github.com/smartcontractkit/chainlink/deployment/common/changeset"
commontypes "github.com/smartcontractkit/chainlink/deployment/common/types"
"github.com/smartcontractkit/chainlink/deployment/environment/memory"
"github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/types"

"github.com/ethereum/go-ethereum/common"
Expand All @@ -32,7 +34,12 @@ import (

func TestAddChainInbound(t *testing.T) {
// 4 chains where the 4th is added after initial deployment.
e := NewMemoryEnvironmentWithJobs(t, logger.TestLogger(t), 4, 4)
e := NewMemoryEnvironmentWithJobs(t, logger.TestLogger(t), memory.MemoryEnvironmentConfig{
Chains: 4,
NumOfUsersPerChain: 1,
Nodes: 4,
Bootstraps: 1,
})
state, err := LoadOnchainState(e.Env)
require.NoError(t, err)
// Take first non-home chain as the new chain.
Expand Down
13 changes: 11 additions & 2 deletions deployment/ccip/changeset/add_lane_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,18 @@ import (
"github.com/smartcontractkit/chainlink-testing-framework/lib/utils/testcontext"

"github.com/smartcontractkit/chainlink/deployment"
"github.com/smartcontractkit/chainlink/deployment/environment/memory"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/offramp"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/router"
"github.com/smartcontractkit/chainlink/v2/core/logger"
)

func TestAddLanesWithTestRouter(t *testing.T) {
e := NewMemoryEnvironmentWithJobsAndContracts(t, logger.TestLogger(t), 2, 4, nil)
e := NewMemoryEnvironmentWithJobsAndContracts(t, logger.TestLogger(t), memory.MemoryEnvironmentConfig{
Chains: 2,
Nodes: 4,
Bootstraps: 1,
}, nil)
// Here we have CR + nodes set up, but no CCIP contracts deployed.
state, err := LoadOnchainState(e.Env)
require.NoError(t, err)
Expand Down Expand Up @@ -66,7 +71,11 @@ func TestAddLane(t *testing.T) {

t.Parallel()
// We add more chains to the chainlink nodes than the number of chains where CCIP is deployed.
e := NewMemoryEnvironmentWithJobsAndContracts(t, logger.TestLogger(t), 2, 4, nil)
e := NewMemoryEnvironmentWithJobsAndContracts(t, logger.TestLogger(t), memory.MemoryEnvironmentConfig{
Chains: 2,
Nodes: 4,
Bootstraps: 1,
}, nil)
// Here we have CR + nodes set up, but no CCIP contracts deployed.
state, err := LoadOnchainState(e.Env)
require.NoError(t, err)
Expand Down
7 changes: 6 additions & 1 deletion deployment/ccip/changeset/deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@ import (

"github.com/stretchr/testify/require"

"github.com/smartcontractkit/chainlink/deployment/environment/memory"
"github.com/smartcontractkit/chainlink/v2/core/logger"
)

func TestDeployCCIPContracts(t *testing.T) {
lggr := logger.TestLogger(t)
e := NewMemoryEnvironmentWithJobsAndContracts(t, lggr, 2, 4, nil)
e := NewMemoryEnvironmentWithJobsAndContracts(t, lggr, memory.MemoryEnvironmentConfig{
Chains: 2,
Nodes: 4,
Bootstraps: 1,
}, nil)
// Deploy all the CCIP contracts.
state, err := LoadOnchainState(e.Env)
require.NoError(t, err)
Expand Down
31 changes: 22 additions & 9 deletions deployment/ccip/changeset/initial_deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/smartcontractkit/chainlink-testing-framework/lib/utils/testcontext"

"github.com/smartcontractkit/chainlink/deployment/environment/memory"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/router"
"github.com/smartcontractkit/chainlink/v2/core/logger"

Expand All @@ -15,9 +16,13 @@ import (

func TestInitialDeploy(t *testing.T) {
lggr := logger.TestLogger(t)
tenv := NewMemoryEnvironmentWithJobsAndContracts(t, lggr, 3, 4, nil)
tenv := NewMemoryEnvironmentWithJobsAndContracts(t, lggr, memory.MemoryEnvironmentConfig{
Chains: 3,
Nodes: 4,
Bootstraps: 1,
NumOfUsersPerChain: 1,
}, nil)
e := tenv.Env

state, err := LoadOnchainState(e)
require.NoError(t, err)
// Add all lanes
Expand All @@ -37,13 +42,21 @@ func TestInitialDeploy(t *testing.T) {
require.NoError(t, err)
block := latesthdr.Number.Uint64()
startBlocks[dest] = &block
msgSentEvent := TestSendRequest(t, e, state, src, dest, false, router.ClientEVM2AnyMessage{
Receiver: common.LeftPadBytes(state.Chains[dest].Receiver.Address().Bytes(), 32),
Data: []byte("hello"),
TokenAmounts: nil,
FeeToken: common.HexToAddress("0x0"),
ExtraArgs: nil,
})
require.GreaterOrEqual(t, len(tenv.Users[src]), 1)
msgSentEvent, err := DoSendRequest(t, e, state,
WithTestRouter(false),
WithSourceChain(src),
WithDestChain(dest),
WithEvm2AnyMessage(router.ClientEVM2AnyMessage{
Receiver: common.LeftPadBytes(state.Chains[dest].Receiver.Address().Bytes(), 32),
Data: []byte("hello"),
TokenAmounts: nil,
FeeToken: common.HexToAddress("0x0"),
ExtraArgs: nil,
}),
WithSender(tenv.Users[src][0]),
)
require.NoError(t, err)
expectedSeqNum[SourceDestPair{
SourceChainSelector: src,
DestChainSelector: dest,
Expand Down
Loading

0 comments on commit 1d93e3b

Please sign in to comment.