Skip to content

Commit

Permalink
integration-tests/deployment/ccip: fix assertion fns (#14482)
Browse files Browse the repository at this point in the history
* integration-tests/deployment/ccip: fix assertion fns

* fix stringer

* use getExecutionState to assert test condition
  • Loading branch information
makramkd authored Sep 18, 2024
1 parent 7d369d7 commit d64834a
Showing 1 changed file with 64 additions and 25 deletions.
89 changes: 64 additions & 25 deletions integration-tests/deployment/ccip/test_assertions.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,20 @@ func ConfirmCommitForAllWithExpectedSeqNums(
srcChain := srcChain
dstChain := dstChain
wg.Go(func() error {
return func(src, dest uint64) error {
var startBlock *uint64
if startBlocks != nil {
startBlock = startBlocks[dest]
}
return ConfirmCommitWithExpectedSeqNumRange(t, srcChain, dstChain, state.Chains[dest].OffRamp, startBlock,
ccipocr3.SeqNumRange{ccipocr3.SeqNum(expectedSeqNums[dest]), ccipocr3.SeqNum(expectedSeqNums[dest])})
}(src, dest)
var startBlock *uint64
if startBlocks != nil {
startBlock = startBlocks[dstChain.Selector]
}
return ConfirmCommitWithExpectedSeqNumRange(
t,
srcChain,
dstChain,
state.Chains[dstChain.Selector].OffRamp,
startBlock,
ccipocr3.SeqNumRange{
ccipocr3.SeqNum(expectedSeqNums[dstChain.Selector]),
ccipocr3.SeqNum(expectedSeqNums[dstChain.Selector]),
})
})
}
}
Expand Down Expand Up @@ -131,16 +137,18 @@ func ConfirmExecWithSeqNrForAll(
srcChain := srcChain
dstChain := dstChain
wg.Go(func() error {
return func(src, dest deployment.Chain) error {
var startBlock *uint64
if startBlocks != nil {
startBlock = startBlocks[dest.Selector]
}
return ConfirmExecWithSeqNr(
t, src, dest, state.Chains[dest.Selector].OffRamp, startBlock,
expectedSeqNums[dstChain.Selector],
)
}(srcChain, dstChain)
var startBlock *uint64
if startBlocks != nil {
startBlock = startBlocks[dstChain.Selector]
}
return ConfirmExecWithSeqNr(
t,
srcChain,
dstChain,
state.Chains[dstChain.Selector].OffRamp,
startBlock,
expectedSeqNums[dstChain.Selector],
)
})
}
}
Expand Down Expand Up @@ -185,19 +193,50 @@ func ConfirmExecWithSeqNr(
if err != nil {
return fmt.Errorf("error to get source chain config : %w", err)
}
t.Logf("Waiting for ExecutionStateChanged on chain %d from chain %d with expected sequence number %d, current onchain minSeqNr: %d",
dest.Selector, source.Selector, expectedSeqNr, scc.MinSeqNr)
executionState, err := offRamp.GetExecutionState(nil, source.Selector, expectedSeqNr)
if err != nil {
return fmt.Errorf("error to get execution state : %w", err)
}
t.Logf("Waiting for ExecutionStateChanged on chain %d (offramp %s) from chain %d with expected sequence number %d, current onchain minSeqNr: %d, execution state: %s",
dest.Selector, offRamp.Address().String(), source.Selector, expectedSeqNr, scc.MinSeqNr, executionStateToString(executionState))
if executionState == EXECUTION_STATE_SUCCESS {
t.Logf("Observed SUCCESS execution state on chain %d (offramp %s) from chain %d with expected sequence number %d",
dest.Selector, offRamp.Address().String(), source.Selector, expectedSeqNr)
return nil
}
case execEvent := <-sink:
if execEvent.SequenceNumber == expectedSeqNr && execEvent.SourceChainSelector == source.Selector {
t.Logf("Received ExecutionStateChanged on chain %d from chain %d with expected sequence number %d",
dest.Selector, source.Selector, expectedSeqNr)
t.Logf("Received ExecutionStateChanged on chain %d (offramp %s) from chain %d with expected sequence number %d",
dest.Selector, offRamp.Address().String(), source.Selector, expectedSeqNr)
return nil
}
case <-timer.C:
return fmt.Errorf("timed out waiting for ExecutionStateChanged on chain %d from chain %d with expected sequence number %d",
dest.Selector, source.Selector, expectedSeqNr)
return fmt.Errorf("timed out waiting for ExecutionStateChanged on chain %d (offramp %s) from chain %d with expected sequence number %d",
dest.Selector, offRamp.Address().String(), source.Selector, expectedSeqNr)
case subErr := <-subscription.Err():
return fmt.Errorf("Subscription error: %w", subErr)
return fmt.Errorf("subscription error: %w", subErr)
}
}
}

const (
EXECUTION_STATE_UNTOUCHED = 0
EXECUTION_STATE_INPROGRESS = 1
EXECUTION_STATE_SUCCESS = 2
EXECUTION_STATE_FAILURE = 3
)

func executionStateToString(state uint8) string {
switch state {
case EXECUTION_STATE_UNTOUCHED:
return "UNTOUCHED"
case EXECUTION_STATE_INPROGRESS:
return "IN_PROGRESS"
case EXECUTION_STATE_SUCCESS:
return "SUCCESS"
case EXECUTION_STATE_FAILURE:
return "FAILURE"
default:
return "UNKNOWN"
}
}

0 comments on commit d64834a

Please sign in to comment.