Skip to content

Commit

Permalink
Simplify ConfirmExecWithSeqNrsForAll
Browse files Browse the repository at this point in the history
  • Loading branch information
archseer committed Jan 21, 2025
1 parent f704674 commit 12a2251
Showing 1 changed file with 28 additions and 39 deletions.
67 changes: 28 additions & 39 deletions deployment/ccip/changeset/testhelpers/test_assertions.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,49 +417,38 @@ func ConfirmExecWithSeqNrsForAll(
mx sync.Mutex
)
executionStates = make(map[SourceDestPair]map[uint64]int)
for src, srcChain := range e.Chains {
for dest, dstChain := range e.Chains {
if src == dest {
continue
}
srcChain := srcChain
dstChain := dstChain
wg.Go(func() error {
var startBlock *uint64
if startBlocks != nil {
startBlock = startBlocks[dstChain.Selector]
}
for sourceDest, seqRange := range expectedSeqNums {
seqRange := seqRange
srcChain := sourceDest.SourceChainSelector
dstChain := sourceDest.DestChainSelector

expectedSeqNum, ok := expectedSeqNums[SourceDestPair{
SourceChainSelector: srcChain.Selector,
DestChainSelector: dstChain.Selector,
}]
if !ok || len(expectedSeqNum) == 0 {
return nil
}
var startBlock *uint64
if startBlocks != nil {
startBlock = startBlocks[dstChain]
}

innerExecutionStates, err := ConfirmExecWithSeqNrs(
t,
srcChain,
dstChain,
state.Chains[dstChain.Selector].OffRamp,
startBlock,
expectedSeqNum,
)
if err != nil {
return err
}
wg.Go(func() error {
innerExecutionStates, err := ConfirmExecWithSeqNrs(
t,
e.Chains[srcChain],
e.Chains[dstChain],
state.Chains[dstChain].OffRamp,
startBlock,
seqRange,
)
if err != nil {
return err
}

mx.Lock()
executionStates[SourceDestPair{
SourceChainSelector: srcChain.Selector,
DestChainSelector: dstChain.Selector,
}] = innerExecutionStates
mx.Unlock()
mx.Lock()
executionStates[SourceDestPair{
SourceChainSelector: srcChain,
DestChainSelector: dstChain,
}] = innerExecutionStates
mx.Unlock()

return nil
})
}
return nil
})
}

require.NoError(t, wg.Wait())
Expand Down

0 comments on commit 12a2251

Please sign in to comment.