Skip to content

Commit

Permalink
Review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
b-gopalswami committed Sep 23, 2024
1 parent a2f64f2 commit bb77d9f
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions integration-tests/ccip-tests/actions/ccip_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -1651,37 +1651,40 @@ func (sourceCCIP *SourceCCIPModule) IsRequestTriggeredWithinTimeframe(timeframe
func (sourceCCIP *SourceCCIPModule) IsPastRequestTriggeredWithinTimeframe(
ctx context.Context,
timeframe *commonconfig.Duration,
) (latestEvent *types.Log, err error) {
) (*types.Log, error) {
if timeframe == nil {
return nil, nil
}
//var foundAt *time.Time
latestBlock, err1 := sourceCCIP.Common.ChainClient.LatestBlockNumber(ctx)
if err1 != nil {
return nil, fmt.Errorf("error while getting latest source block number. Error: %w", err1)
latestBlock, err := sourceCCIP.Common.ChainClient.LatestBlockNumber(ctx)
if err != nil {
return nil, fmt.Errorf("error while getting latest source block number. Error: %w", err)
}
avgBlockTime, err1 := sourceCCIP.Common.ChainClient.AvgBlockTime(ctx)
if err1 != nil {
return nil, fmt.Errorf("error while getting average source block time. Error: %w", err1)
avgBlockTime, err := sourceCCIP.Common.ChainClient.AvgBlockTime(ctx)
if err != nil {
return nil, fmt.Errorf("error while getting average source block time. Error: %w", err)
}
filterFromBlock := latestBlock - uint64(timeframe.Duration()/avgBlockTime)

onRampContract, err1 := evm_2_evm_onramp.NewEVM2EVMOnRamp(common.HexToAddress(sourceCCIP.OnRamp.EthAddress.Hex()),
onRampContract, err := evm_2_evm_onramp.NewEVM2EVMOnRamp(common.HexToAddress(sourceCCIP.OnRamp.EthAddress.Hex()),
sourceCCIP.Common.ChainClient.Backend())
if err1 != nil {
return nil, fmt.Errorf("error while on ramp contract. Error: %w", err1)
if err != nil {
return nil, fmt.Errorf("error while on ramp contract. Error: %w", err)
}
iterator, err1 := onRampContract.FilterCCIPSendRequested(&bind.FilterOpts{
iterator, err := onRampContract.FilterCCIPSendRequested(&bind.FilterOpts{
Start: filterFromBlock,
})
if err1 != nil {
return nil, fmt.Errorf("error while filtering CCIP send requested starting block number: %d. Error: %w", filterFromBlock, err1)
if err != nil {
return nil, fmt.Errorf("error while filtering CCIP send requested starting block number: %d. Error: %w", filterFromBlock, err)
}
defer func() {
err = iterator.Close()
iterErr := iterator.Close()
if iterErr != nil {
sourceCCIP.Common.Logger.Error().Err(iterErr).Msg("Error closing iterator")
}
}()
lastBlockNumber := uint64(0)
latestEvent = nil
var latestEvent *types.Log
for iterator.Next() {
blockNum := iterator.Event.Raw.BlockNumber
if blockNum > lastBlockNumber {
Expand Down

0 comments on commit bb77d9f

Please sign in to comment.