diff --git a/integration-tests/ccip-tests/actions/ccip_helpers.go b/integration-tests/ccip-tests/actions/ccip_helpers.go index e9df87c606..4f247ed090 100644 --- a/integration-tests/ccip-tests/actions/ccip_helpers.go +++ b/integration-tests/ccip-tests/actions/ccip_helpers.go @@ -184,15 +184,15 @@ type CCIPCommon struct { tokenPriceUpdateWatcher map[common.Address]*big.Int // key - token; value - timestamp of update gasUpdateWatcherMu *sync.Mutex gasUpdateWatcher map[uint64]*big.Int // key - destchain id; value - timestamp of update - GasUpdateEvents []gasUpdateEvent + GasUpdateEvents []GasUpdateEvent } -type gasUpdateEvent struct { - Sender string - Tx string - Value *big.Int - DestChain uint64 - ChainSelector uint64 +type GasUpdateEvent struct { + Sender string + Tx string + Value *big.Int + DestChain uint64 + Source string } // FreeUpUnusedSpace sets nil to various elements of ccipModule which are only used @@ -568,12 +568,12 @@ func (ccipModule *CCIPCommon) WatchForPriceUpdates(ctx context.Context, lggr *ze ccipModule.gasUpdateWatcherMu.Lock() ccipModule.gasUpdateWatcher[destChain] = timestamp - ccipModule.GasUpdateEvents = append(ccipModule.GasUpdateEvents, gasUpdateEvent{ - Sender: raw.Address.Hex(), - Tx: raw.TxHash.Hex(), - Value: value, - DestChain: destChain, - ChainSelector: destChainSelector, + ccipModule.GasUpdateEvents = append(ccipModule.GasUpdateEvents, GasUpdateEvent{ + Sender: raw.Address.Hex(), + Tx: raw.TxHash.Hex(), + Value: value, + DestChain: destChain, + Source: ccipModule.ChainClient.GetNetworkName(), }) ccipModule.gasUpdateWatcherMu.Unlock() lggr.Info(). @@ -581,6 +581,7 @@ func (ccipModule *CCIPCommon) WatchForPriceUpdates(ctx context.Context, lggr *ze Str("source_chain", ccipModule.ChainClient.GetNetworkName()). Uint64("dest_chain", destChain). Str("price_registry", ccipModule.PriceRegistry.Address()). + Str("tx hash", raw.TxHash.Hex()). Msgf("UsdPerUnitGasUpdated event received for dest chain %d source chain %s", destChain, ccipModule.ChainClient.GetNetworkName()) return nil diff --git a/integration-tests/ccip-tests/testsetups/ccip.go b/integration-tests/ccip-tests/testsetups/ccip.go index 81a06f2d2d..e8da29cfc3 100644 --- a/integration-tests/ccip-tests/testsetups/ccip.go +++ b/integration-tests/ccip-tests/testsetups/ccip.go @@ -933,31 +933,48 @@ func (o *CCIPTestSetUpOutputs) WaitForPriceUpdates() { // CheckGasUpdateTransaction checks the gas update transactions count, and it has required number of // events as per leader lane definitions. func (o *CCIPTestSetUpOutputs) CheckGasUpdateTransaction(lggr *zerolog.Logger) error { - transactions := make(map[string]map[uint64]string) + transactions := make(map[string]map[uint64]actions.GasUpdateEvent) + destToSourcesList := make(map[string][]string) + for _, n := range o.Cfg.NetworkPairs { + if _, ok := destToSourcesList[n.NetworkB.Name]; ok { + destToSourcesList[n.NetworkB.Name] = append(destToSourcesList[n.NetworkB.Name], n.NetworkA.Name) + } else { + destToSourcesList[n.NetworkB.Name] = []string{n.NetworkA.Name} + } + if pointer.GetBool(o.Cfg.TestGroupInput.BiDirectionalLane) { + if _, ok := destToSourcesList[n.NetworkA.Name]; ok { + destToSourcesList[n.NetworkA.Name] = append(destToSourcesList[n.NetworkA.Name], n.NetworkB.Name) + } else { + destToSourcesList[n.NetworkA.Name] = []string{n.NetworkB.Name} + } + } + } + lggr.Info().Interface("list", destToSourcesList).Msg("Dest to Source") readGasUpdateTx := func(lane *actions.CCIPLane) error { for _, g := range lane.Source.Common.GasUpdateEvents { if g.Value == nil { - return fmt.Errorf("gas update value should not be nil for chain selected %v in tx %s", g.ChainSelector, g.Tx) + return fmt.Errorf("gas update value should not be nil in tx %s", g.Tx) } if v, ok := transactions[g.Tx]; ok { - v[g.ChainSelector] = g.Value.String() + + v[g.DestChain] = g transactions[g.Tx] = v } else { - transactions[g.Tx] = map[uint64]string{ - g.ChainSelector: g.Value.String(), + transactions[g.Tx] = map[uint64]actions.GasUpdateEvent{ + g.DestChain: g, } } - lane.Logger.Debug(). + lane.Logger.Info(). Str("Sender", g.Sender). Str("Tx Hash", g.Tx). Uint64("Dest", g.DestChain). - Uint64("ChainSelector", g.ChainSelector). Str("Value", g.Value.String()). Msg("Gas price Updater details") } return nil } + for _, lanes := range o.ReadLanes() { if err := readGasUpdateTx(lanes.ForwardLane); err != nil { return err @@ -986,20 +1003,33 @@ func (o *CCIPTestSetUpOutputs) CheckGasUpdateTransaction(lggr *zerolog.Logger) e // each transaction should have number of network - 1 chain selectors and corresponding gas values. // Say we have 3 networks, then we have expected every transaction to have 2 chain selectors //failed := false - for k, v := range transactions { - if len(v) != o.Cfg.TestGroupInput.NoOfNetworks-1 { + for k, chainsReceivesPriceUpdate := range transactions { + var ( + priceReceivedFromChain string + sender string + ) + for _, chain := range chainsReceivesPriceUpdate { + priceReceivedFromChain = chain.Source + sender = chain.Sender + break + } + if len(chainsReceivesPriceUpdate) != len(destToSourcesList[priceReceivedFromChain]) { lggr.Warn(). Str("Tx hash", k). - Interface("Chain selectors", v). - Int("Event emitted count", len(v)). + Str("Source", priceReceivedFromChain). + Str("Sender", sender). + Int("Expected event count", len(destToSourcesList[priceReceivedFromChain])). + Int("Event emitted count", len(chainsReceivesPriceUpdate)). Msg("Checked Gas Update transaction events count doesn't match") //failed = true } else { lggr.Info(). Str("Tx hash", k). - Interface("Chain selectors", v). - Int("Event emitted count", len(v)). + Str("Source", priceReceivedFromChain). + Str("Sender", sender). + Int("Expected event count", len(destToSourcesList[priceReceivedFromChain])). + Int("Event emitted count", len(chainsReceivesPriceUpdate)). Msg("Checked Gas Update transaction events count") } }