Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: improve ICS misbehaviour E2E testing coverage #1225

Merged
merged 2 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions tests/e2e/actions_consumer_misbehaviour.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func (tr TestRun) forkConsumerChain(action forkConsumerChainAction, verbose bool
)

if verbose {
fmt.Println("forkConsumerChain - reconfigure node cmd:", configureNodeCmd.String())
log.Println("forkConsumerChain - reconfigure node cmd:", configureNodeCmd.String())
}

cmdReader, err := configureNodeCmd.StdoutPipe()
Expand All @@ -47,7 +47,7 @@ func (tr TestRun) forkConsumerChain(action forkConsumerChainAction, verbose bool
for scanner.Scan() {
out := scanner.Text()
if verbose {
fmt.Println("fork consumer validator : " + out)
log.Println("fork consumer validator : " + out)
}
if out == done {
break
Expand Down Expand Up @@ -90,3 +90,25 @@ func (tr TestRun) updateLightClient(

tr.waitBlocks(action.hostChain, 5, 30*time.Second)
}

type assertChainIsHaltedAction struct {
chain chainID
}

func (tr TestRun) assertChainIsHalted(
action assertChainIsHaltedAction,
verbose bool,
) {
// Recover the panic if the chain doesn't produce blocks as expected
defer func() {
if r := recover(); r != nil {
if verbose {
log.Printf("assertChainIsHalted - chain %v was successfully halted\n", action.chain)
}
}
}()

// Panic if the chain still produces blocks
tr.waitBlocks(action.chain, 1, 20*time.Second)
panic(fmt.Sprintf("chain %v isn't expected to produce blocks", action.chain))
}
2 changes: 2 additions & 0 deletions tests/e2e/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ func (tr *TestRun) runStep(step Step, verbose bool) {
tr.forkConsumerChain(action, verbose)
case updateLightClientAction:
tr.updateLightClient(action, verbose)
case assertChainIsHaltedAction:
tr.assertChainIsHalted(action, verbose)
default:
log.Fatalf("unknown action in testRun %s: %#v", tr.name, action)
}
Expand Down
14 changes: 8 additions & 6 deletions tests/e2e/steps_consumer_misbehaviour.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,13 +241,15 @@ func stepsCauseConsumerMisbehaviour(consumerName string) []Step {
},
},
},
chainID(consumerName): ChainState{
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed since our model state checker requires the chain to still produce blocks.

ValPowers: &map[validatorID]uint{
validatorID("alice"): 511,
validatorID("bob"): 20,
},
},
},
},
// we expect the consumer chain to be halted since the last VSC packet should
// have updated the alice validator power to 0.
{
action: assertChainIsHaltedAction{
chain: chainID("consu"),
},
state: State{},
},
}
}
Loading