Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
b-gopalswami committed Jul 12, 2024
1 parent cf51b9b commit 2543383
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions integration-tests/ccip-tests/testsetups/ccip.go
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,7 @@ func (o *CCIPTestSetUpOutputs) CheckGasUpdateTransaction(lggr *zerolog.Logger) e
transactions := make(map[string]map[uint64]actions.GasUpdateEvent)
transactionsBySource := make(map[string]string)
destToSourcesList := make(map[string][]string)
// create a map to hold the unique destination with list of sources
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)
Expand All @@ -951,27 +952,20 @@ func (o *CCIPTestSetUpOutputs) CheckGasUpdateTransaction(lggr *zerolog.Logger) e
}
}
lggr.Info().Interface("list", destToSourcesList).Msg("Dest to Source")
// a function to read the events and create a map by tx hash with the event details
filterGasUpdateByTx := 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 in tx %s", g.Tx)
}
if v, ok := transactions[g.Tx]; ok {

v[g.DestChain] = g
transactions[g.Tx] = v
} else {
transactions[g.Tx] = map[uint64]actions.GasUpdateEvent{
g.DestChain: g,
}
}

lane.Logger.Info().
Str("Sender", g.Sender).
Str("Tx Hash", g.Tx).
Uint64("Dest", g.DestChain).
Str("Value", g.Value.String()).
Msg("Gas price Updater details")
}
return nil
}
Expand All @@ -996,17 +990,18 @@ func (o *CCIPTestSetUpOutputs) CheckGasUpdateTransaction(lggr *zerolog.Logger) e
}
}
}
lggr.Info().Interface("Tx hashes", transactions).Msg("Checked Gas Update Transactions")
lggr.Debug().Interface("Tx hashes", transactions).Msg("Checked Gas Update Transactions")
lggr.Info().Interface("Tx hashes by source", transactionsBySource).Msg("Checked Gas Update Transactions by Source")
// when leader lane setup is enabled, number of transaction should match the number of leader lanes defined.
// when leader lane setup is enabled, number of unique transaction from the source
//should match the number of leader lanes defined.
var failed bool
if len(transactionsBySource) != len(o.Cfg.LeaderLanes) {
lggr.Warn().
Int("Tx hashes", len(transactions)).
Int("Tx hashes", len(transactionsBySource)).
lggr.Error().
Int("Tx hashes expected", len(o.Cfg.LeaderLanes)).
Int("Tx hashes received", len(transactionsBySource)).
Int("Leader lanes count", len(o.Cfg.LeaderLanes)).
Msg("Checked Gas Update transactions count doesn't match")
//return fmt.Errorf("transaction count %d should match the number of leader lanes %d",
// len(transactions), len(o.Cfg.LeaderLanes))
failed = true
} else {
lggr.Info().
Int("Tx hashes", len(transactions)).
Expand All @@ -1019,24 +1014,29 @@ func (o *CCIPTestSetUpOutputs) CheckGasUpdateTransaction(lggr *zerolog.Logger) e
for source, tx := range transactionsBySource {
l, ok := destToSourcesList[source]
if !ok {
lggr.Warn().Str("Tx hash", tx).Msg("this transaction is probably from non-leader lane which is not expected")
lggr.Error().Str("Tx hash", tx).Msg("this transaction is probably " +
"from non-leader lane which is not expected")
}
if len(transactions[tx]) != len(l) {
lggr.Warn().
lggr.Error().
Str("Tx hash", tx).
Str("Source", source).
Int("Expected event count", len(l)).
Int("Event emitted count", len(transactions[tx])).
Msg("Checked Gas Update transaction events count doesn't match")
failed = true
} else {
lggr.Info().
lggr.Debug().
Str("Tx hash", tx).
Str("Source", source).
Int("Expected event count", len(l)).
Int("Event emitted count", len(transactions[tx])).
Msg("Checked Gas Update transaction events count")
}
}
if failed {
return fmt.Errorf("gas update transaction verification failed. Refer the logs for the errors")
}
return nil
}

Expand Down

0 comments on commit 2543383

Please sign in to comment.