From 5bd50a28012563d8552c9ead69962701cef721e7 Mon Sep 17 00:00:00 2001 From: AnieeG Date: Sat, 6 Apr 2024 00:49:58 -0700 Subject: [PATCH 1/2] fix range for dynamic price updates --- integration-tests/ccip-tests/actions/ccip_helpers.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/integration-tests/ccip-tests/actions/ccip_helpers.go b/integration-tests/ccip-tests/actions/ccip_helpers.go index 973c060fd0..47b7c18eee 100644 --- a/integration-tests/ccip-tests/actions/ccip_helpers.go +++ b/integration-tests/ccip-tests/actions/ccip_helpers.go @@ -454,7 +454,11 @@ func (ccipModule *CCIPCommon) WatchForPriceUpdates(ctx context.Context) error { }) go func() { - defer sub.Unsubscribe() + defer func() { + sub.Unsubscribe() + ccipModule.gasUpdateWatcher = nil + ccipModule.gasUpdateWatcherMu = nil + }() for { select { case e := <-gasUpdateEvent: @@ -496,14 +500,14 @@ func (ccipModule *CCIPCommon) UpdateTokenPricesAtRegularInterval(ctx context.Con aggregators = append(aggregators, contract) } go func() { - rand.NewSource(new(big.Int).Mul(big.NewInt(1e18), big.NewInt(10)).Uint64()) + rand.NewSource(uint64(time.Now().UnixNano())) ticker := time.NewTicker(interval) for { select { case <-ticker.C: // randomly choose an aggregator contract from slice of aggregators randomIndex := rand.Intn(len(aggregators)) - err := aggregators[randomIndex].UpdateRoundData(big.NewInt(int64(rand.Uint64()))) + err := aggregators[randomIndex].UpdateRoundData(new(big.Int).Add(big.NewInt(1e18), big.NewInt(rand.Int63n(1000)))) if err != nil { continue } From f4e42fc2795384650f7468842bef80008b377c60 Mon Sep 17 00:00:00 2001 From: AnieeG Date: Sat, 6 Apr 2024 09:51:18 -0700 Subject: [PATCH 2/2] fix range for dynamic price updates --- integration-tests/ccip-tests/contracts/contract_models.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-tests/ccip-tests/contracts/contract_models.go b/integration-tests/ccip-tests/contracts/contract_models.go index 8845a75638..8b284ee3b2 100644 --- a/integration-tests/ccip-tests/contracts/contract_models.go +++ b/integration-tests/ccip-tests/contracts/contract_models.go @@ -918,7 +918,7 @@ func (a *MockAggregator) UpdateRoundData(answer *big.Int) error { round, err := a.Instance.LatestRound(nil) if err != nil { rand.Seed(uint64(time.Now().UnixNano())) - round = big.NewInt(int64(rand.Uint64())) + round = big.NewInt(rand.Int63n(2000)) } round = new(big.Int).Add(round, big.NewInt(1)) tx, err := a.Instance.UpdateRoundData(opts, round, answer, big.NewInt(time.Now().UTC().UnixNano()), big.NewInt(time.Now().UTC().UnixNano()))