From 12a22517cbe8b141104064d23f5f149fcd30ba3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Tue, 21 Jan 2025 16:27:15 +0900 Subject: [PATCH] Simplify ConfirmExecWithSeqNrsForAll --- .../changeset/testhelpers/test_assertions.go | 67 ++++++++----------- 1 file changed, 28 insertions(+), 39 deletions(-) diff --git a/deployment/ccip/changeset/testhelpers/test_assertions.go b/deployment/ccip/changeset/testhelpers/test_assertions.go index fb7068e7826..a8f5e75f5ed 100644 --- a/deployment/ccip/changeset/testhelpers/test_assertions.go +++ b/deployment/ccip/changeset/testhelpers/test_assertions.go @@ -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())