Skip to content

Commit

Permalink
Fix dynamic price range (#693)
Browse files Browse the repository at this point in the history
## Motivation


## Solution
  • Loading branch information
AnieeG authored Apr 8, 2024
1 parent 580d53c commit 7a1f798
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions integration-tests/ccip-tests/actions/ccip_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/ccip-tests/contracts/contract_models.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand Down

0 comments on commit 7a1f798

Please sign in to comment.