Skip to content

Commit

Permalink
Set a default block time of 2s, make it configurable (0 disables)
Browse files Browse the repository at this point in the history
  • Loading branch information
archseer committed Jan 24, 2025
1 parent 2a44afa commit dd110e2
Show file tree
Hide file tree
Showing 18 changed files with 11 additions and 24 deletions.
1 change: 0 additions & 1 deletion deployment/ccip/changeset/cs_active_candidate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ func Test_ActiveCandidate(t *testing.T) {
// and then setup a candidate instance. The candidate instance
// should not be able to transmit anything until we make it active.
tenv, _ := testhelpers.NewMemoryEnvironment(t,
testhelpers.WithMineBlocks(),
testhelpers.WithNumOfChains(2),
testhelpers.WithNumOfNodes(4))
state, err := changeset.LoadOnchainState(tenv.Env)
Expand Down
2 changes: 1 addition & 1 deletion deployment/ccip/changeset/cs_add_lane_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (

func TestAddLanesWithTestRouter(t *testing.T) {
t.Parallel()
e, _ := testhelpers.NewMemoryEnvironment(t, testhelpers.WithMineBlocks())
e, _ := testhelpers.NewMemoryEnvironment(t)
// Here we have CR + nodes set up, but no CCIP contracts deployed.
state, err := changeset.LoadOnchainState(e.Env)
require.NoError(t, err)
Expand Down
14 changes: 7 additions & 7 deletions deployment/ccip/changeset/testhelpers/test_environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ type TestConfigs struct {
NumOfRMNNodes int
LinkPrice *big.Int
WethPrice *big.Int
MineBlocks bool
BlockTime time.Duration
}

func (tc *TestConfigs) Validate() error {
Expand Down Expand Up @@ -99,14 +99,15 @@ func DefaultTestConfigs() *TestConfigs {
LinkPrice: changeset.MockLinkPrice,
WethPrice: changeset.MockWethPrice,
CreateJobAndContracts: true,
BlockTime: 2 * time.Second,
}
}

type TestOps func(testCfg *TestConfigs)

func WithMineBlocks() TestOps {
func WithBlockTime(blockTime time.Duration) TestOps {
return func(testCfg *TestConfigs) {
testCfg.MineBlocks = true
testCfg.BlockTime = blockTime
}
}

Expand Down Expand Up @@ -347,8 +348,7 @@ func mineBlocks(backend *memory.Backend, blockTime time.Duration) (stopMining fu
}
}

func (m *MemoryEnvironment) MineBlocks(t *testing.T) {
blockTime := 2 * time.Second
func (m *MemoryEnvironment) MineBlocks(t *testing.T, blockTime time.Duration) {
for _, chain := range m.Chains {
if backend, ok := chain.Client.(*memory.Backend); ok {
stopMining := mineBlocks(backend, blockTime)
Expand Down Expand Up @@ -379,8 +379,8 @@ func NewMemoryEnvironment(t *testing.T, opts ...TestOps) (DeployedEnv, TestEnvir
dEnv = NewEnvironment(t, env)
}
env.UpdateDeployedEnvironment(dEnv)
if testCfg.MineBlocks {
env.MineBlocks(t)
if testCfg.BlockTime > 0 {
env.MineBlocks(t, testCfg.BlockTime)
}
return dEnv, env
}
Expand Down
1 change: 0 additions & 1 deletion deployment/ccip/changeset/v1_5/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
func TestE2ELegacy(t *testing.T) {
e, _ := testhelpers.NewMemoryEnvironment(
t,
testhelpers.WithMineBlocks(),
testhelpers.WithPrerequisiteDeploymentOnly(&changeset.V1_5DeploymentConfig{
PriceRegStalenessThreshold: 60 * 60 * 24 * 14, // two weeks
RMNConfig: &rmn_contract.RMNConfig{
Expand Down
1 change: 0 additions & 1 deletion integration-tests/smoke/ccip/ccip_add_chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ func Test_AddChain(t *testing.T) {
// only deploy and configure 3 of them.
e, tEnv := testhelpers.NewMemoryEnvironment(
t,
testhelpers.WithMineBlocks(),
testhelpers.WithNumOfChains(numChains),
testhelpers.WithNumOfNodes(4),
testhelpers.WithPrerequisiteDeploymentOnly(nil),
Expand Down
1 change: 0 additions & 1 deletion integration-tests/smoke/ccip/ccip_batching_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ func newBatchTestSetup(t *testing.T) batchTestSetup {
// Setup 3 chains, with 2 lanes going to the dest.
e, _, _ := testsetups.NewIntegrationEnvironment(
t,
testhelpers.WithMineBlocks(),
testhelpers.WithMultiCall3(),
testhelpers.WithNumOfChains(3),
testhelpers.WithNumOfUsersPerChain(2),
Expand Down
1 change: 0 additions & 1 deletion integration-tests/smoke/ccip/ccip_fee_boosting_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ var (
func Test_CCIPFeeBoosting(t *testing.T) {
e, _, _ := testsetups.NewIntegrationEnvironment(
t,
testhelpers.WithMineBlocks(),
testhelpers.WithOCRConfigOverride(func(params *changeset.CCIPOCRParams) {
params.ExecuteOffChainConfig.RelativeBoostPerWaitHour = 1
// Disable token price updates
Expand Down
1 change: 0 additions & 1 deletion integration-tests/smoke/ccip/ccip_fees_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ func Test_CCIPFees(t *testing.T) {
t.Parallel()
tenv, _, _ := testsetups.NewIntegrationEnvironment(
t,
testhelpers.WithMineBlocks(),
testhelpers.WithMultiCall3(),
)
e := tenv.Env
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ func Test_CCIPGasPriceUpdates(t *testing.T) {

var gasPriceExpiry = 5 * time.Second
e, _, _ := testsetups.NewIntegrationEnvironment(t,
testhelpers.WithMineBlocks(),
testhelpers.WithOCRConfigOverride(func(params *changeset.CCIPOCRParams) {
params.CommitOffChainConfig.RemoteGasPriceBatchWriteFrequency = *config.MustNewDuration(gasPriceExpiry)
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func Test_CCIPMessageLimitations(t *testing.T) {
ctx := testcontext.Get(t)
callOpts := &bind.CallOpts{Context: ctx}

testEnv, _, _ := testsetups.NewIntegrationEnvironment(t, testhelpers.WithMineBlocks())
testEnv, _, _ := testsetups.NewIntegrationEnvironment(t)
chains := maps.Keys(testEnv.Env.Chains)

onChainState, err := changeset.LoadOnchainState(testEnv.Env)
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/smoke/ccip/ccip_messaging_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ type messagingTestCaseOutput struct {
func Test_CCIPMessaging(t *testing.T) {
// Setup 2 chains and a single lane.
ctx := testhelpers.Context(t)
e, _, _ := testsetups.NewIntegrationEnvironment(t, testhelpers.WithMineBlocks())
e, _, _ := testsetups.NewIntegrationEnvironment(t)

state, err := changeset.LoadOnchainState(e.Env)
require.NoError(t, err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ func TestMigrateFromV1_5ToV1_6(t *testing.T) {
},
},
}),
testhelpers.WithMineBlocks(),
testhelpers.WithNumOfChains(3),
testhelpers.WithNumOfUsersPerChain(2),
// for in-memory test it is important to set the dest chain id as 1337 otherwise the config digest will not match
Expand Down
1 change: 0 additions & 1 deletion integration-tests/smoke/ccip/ccip_ooo_execution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ func Test_OutOfOrderExecution(t *testing.T) {
ctx := tests.Context(t)
tenv, _, _ := testsetups.NewIntegrationEnvironment(
t,
testhelpers.WithMineBlocks(),
testhelpers.WithUSDC(),
testhelpers.WithUSDCAttestationMissing(),
testhelpers.WithNumOfUsersPerChain(2),
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/smoke/ccip/ccip_reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ func TestCCIPReader_GetExpectedNextSequenceNumber(t *testing.T) {
t.Parallel()
ctx := tests.Context(t)
//env := NewMemoryEnvironmentContractsOnly(t, logger.TestLogger(t), 2, 4, nil)
env, _ := testhelpers.NewMemoryEnvironment(t, testhelpers.WithMineBlocks())
env, _ := testhelpers.NewMemoryEnvironment(t)
state, err := changeset.LoadOnchainState(env.Env)
require.NoError(t, err)

Expand Down
1 change: 0 additions & 1 deletion integration-tests/smoke/ccip/ccip_rmn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ func runRmnTestCase(t *testing.T, tc rmnTestCase) {
t.Logf("Running RMN test case: %s", tc.name)

envWithRMN, rmnCluster, _ := testsetups.NewIntegrationEnvironment(t,
testhelpers.WithMineBlocks(),
testhelpers.WithRMNEnabled(len(tc.rmnNodes)),
)
t.Logf("envWithRmn: %#v", envWithRMN)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ func Test_CCIPTokenPriceUpdates(t *testing.T) {

var tokenPriceExpiry = 5 * time.Second
e, _, _ := testsetups.NewIntegrationEnvironment(t,
testhelpers.WithMineBlocks(),
testhelpers.WithOCRConfigOverride(func(params *changeset.CCIPOCRParams) {
params.CommitOffChainConfig.TokenPriceBatchWriteFrequency = *config.MustNewDuration(tokenPriceExpiry)
}))
Expand Down
1 change: 0 additions & 1 deletion integration-tests/smoke/ccip/ccip_token_transfer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ func TestTokenTransfer(t *testing.T) {
ctx := tests.Context(t)

tenv, _, _ := testsetups.NewIntegrationEnvironment(t,
testhelpers.WithMineBlocks(),
testhelpers.WithNumOfUsersPerChain(3))

e := tenv.Env
Expand Down
1 change: 0 additions & 1 deletion integration-tests/smoke/ccip/ccip_usdc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ func TestUSDCTokenTransfer(t *testing.T) {
lggr := logger.TestLogger(t)
ctx := tests.Context(t)
tenv, _, _ := testsetups.NewIntegrationEnvironment(t,
testhelpers.WithMineBlocks(),
testhelpers.WithNumOfUsersPerChain(3),
testhelpers.WithNumOfChains(3),
testhelpers.WithUSDC(),
Expand Down

0 comments on commit dd110e2

Please sign in to comment.