Skip to content

Commit

Permalink
update rapid test
Browse files Browse the repository at this point in the history
  • Loading branch information
sainoe committed Oct 4, 2023
1 parent 8349b82 commit ea545b4
Show file tree
Hide file tree
Showing 14 changed files with 1,273 additions and 779 deletions.
33 changes: 33 additions & 0 deletions tests/e2e/action_rapid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ func GetActionGen() *rapid.Generator[any] {
CreateLightClientEquivocationAttackActionGen().AsAny(),
CreateLightClientAmnesiaAttackActionGen().AsAny(),
CreateLightClientLunaticAttackActionGen().AsAny(),
GetStartConsumerEvidenceDetectorActionGen().AsAny(),
GetForkConsumerChainActionGen().AsAny(),
GetUpdateLightClientActionGen().AsAny(),
)
}

Expand Down Expand Up @@ -485,3 +488,33 @@ func GetSlashThrottleDequeueActionGen() *rapid.Generator[slashThrottleDequeueAct
}
})
}

func GetForkConsumerChainActionGen() *rapid.Generator[forkConsumerChainAction] {
return rapid.Custom(func(t *rapid.T) forkConsumerChainAction {
return forkConsumerChainAction{
ConsumerChain: GetChainIDGen().Draw(t, "ConsumerChain"),
ProviderChain: GetChainIDGen().Draw(t, "ProviderChain"),
Validator: GetValidatorIDGen().Draw(t, "Validator"),
RelayerConfig: rapid.String().Draw(t, "RelayerConfig"),
}
})
}

func GetStartConsumerEvidenceDetectorActionGen() *rapid.Generator[startConsumerEvidenceDetectorAction] {
return rapid.Custom(func(t *rapid.T) startConsumerEvidenceDetectorAction {
return startConsumerEvidenceDetectorAction{
Chain: GetChainIDGen().Draw(t, "Chain"),
}
})
}

func GetUpdateLightClientActionGen() *rapid.Generator[updateLightClientAction] {
return rapid.Custom(func(t *rapid.T) updateLightClientAction {
return updateLightClientAction{
Chain: GetChainIDGen().Draw(t, "Chain"),
HostChain: GetChainIDGen().Draw(t, "HostChain"),
RelayerConfig: rapid.String().Draw(t, "RelayerConfig"),
ClientID: rapid.String().Draw(t, "ClientID"),
}
})
}
2 changes: 1 addition & 1 deletion tests/e2e/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ func ChangeoverTestConfig() TestConfig {

func ConsumerMisbehaviourTestConfig() TestConfig {
tc := TestConfig{
name: "misbehaviour",
name: "consumer-misbehaviour",
containerConfig: ContainerConfig{
ContainerName: "interchain-security-container",
InstanceName: "interchain-security-instance",
Expand Down
18 changes: 18 additions & 0 deletions tests/e2e/json_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,24 @@ func UnmarshalMapToActionType(rawAction json.RawMessage, actionTypeString string
if err == nil {
return a, nil
}
case "main.forkConsumerChainAction":
var a forkConsumerChainAction
err := json.Unmarshal(rawAction, &a)
if err == nil {
return a, nil
}
case "main.startConsumerEvidenceDetectorAction":
var a startConsumerEvidenceDetectorAction
err := json.Unmarshal(rawAction, &a)
if err == nil {
return a, nil
}
case "main.updateLightClientAction":
var a updateLightClientAction
err := json.Unmarshal(rawAction, &a)
if err == nil {
return a, nil
}
default:
return nil, fmt.Errorf("unknown action type: %s", actionTypeString)
}
Expand Down
3 changes: 2 additions & 1 deletion tests/e2e/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ func getTestCases(selectedPredefinedTests, selectedTestFiles TestSet) (tests []t
if len(selectedPredefinedTests) == 0 && len(selectedTestFiles) == 0 {
selectedPredefinedTests = TestSet{
"changeover", "happy-path",
"democracy-reward", "democracy", "slash-throttle",
"democracy-reward", "democracy",
"slash-throttle", "consumer-double-sign", "consumer-misbehaviour",
}
if includeMultiConsumer != nil && *includeMultiConsumer {
selectedPredefinedTests = append(selectedPredefinedTests, "multiconsumer")
Expand Down
4 changes: 3 additions & 1 deletion tests/e2e/trace_handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ func TestWriteExamples(t *testing.T) {
"shorthappy": {shortHappyPathSteps},
"democracyRewardsSteps": {democracyRewardsSteps},
"changeover": {changeoverSteps},
"consumer-misbehaviour": {consumerMisbehaviourSteps},
"consumer-double-sign": {consumerDoubleSignSteps},
}

dir := "tracehandler_testdata"
Expand Down Expand Up @@ -131,7 +133,7 @@ func TestMarshalAndUnmarshalChainState(t *testing.T) {
},
},
}},
"consuemr removal proposal": {ChainState{
"consumer removal proposal": {ChainState{
Proposals: &map[uint]Proposal{
5: ConsumerRemovalProposal{
Deposit: 10000001,
Expand Down
19 changes: 18 additions & 1 deletion tests/e2e/tracehandler_testdata/changeover.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"ConsumerChainQueueSizes": null,
"GlobalSlashQueueSize": null,
"RegisteredConsumerRewardDenoms": null,
"ClientsFrozenHeights": null,
"Proposals": null
}
}
Expand Down Expand Up @@ -56,6 +57,7 @@
"ConsumerChainQueueSizes": null,
"GlobalSlashQueueSize": null,
"RegisteredConsumerRewardDenoms": null,
"ClientsFrozenHeights": null,
"Proposals": null
}
}
Expand All @@ -82,7 +84,7 @@
}
],
"GenesisChanges": "",
"SkipGentx": false
"IsConsumer": false
},
"State": {
"provi": {
Expand All @@ -101,6 +103,7 @@
"ConsumerChainQueueSizes": null,
"GlobalSlashQueueSize": null,
"RegisteredConsumerRewardDenoms": null,
"ClientsFrozenHeights": null,
"Proposals": null
}
}
Expand Down Expand Up @@ -147,6 +150,7 @@
"ConsumerChainQueueSizes": null,
"GlobalSlashQueueSize": null,
"RegisteredConsumerRewardDenoms": null,
"ClientsFrozenHeights": null,
"Proposals": {
"1": {
"RawProposal": {
Expand Down Expand Up @@ -188,6 +192,7 @@
"ConsumerChainQueueSizes": null,
"GlobalSlashQueueSize": null,
"RegisteredConsumerRewardDenoms": null,
"ClientsFrozenHeights": null,
"Proposals": {
"1": {
"RawProposal": {
Expand Down Expand Up @@ -242,6 +247,7 @@
"ConsumerChainQueueSizes": null,
"GlobalSlashQueueSize": null,
"RegisteredConsumerRewardDenoms": null,
"ClientsFrozenHeights": null,
"Proposals": {
"1": {
"RawProposal": {
Expand Down Expand Up @@ -291,6 +297,7 @@
"ConsumerChainQueueSizes": null,
"GlobalSlashQueueSize": null,
"RegisteredConsumerRewardDenoms": null,
"ClientsFrozenHeights": null,
"Proposals": {
"1": {
"RawProposal": {
Expand Down Expand Up @@ -349,6 +356,7 @@
"ConsumerChainQueueSizes": null,
"GlobalSlashQueueSize": null,
"RegisteredConsumerRewardDenoms": null,
"ClientsFrozenHeights": null,
"Proposals": null
},
"sover": {
Expand All @@ -367,6 +375,7 @@
"ConsumerChainQueueSizes": null,
"GlobalSlashQueueSize": null,
"RegisteredConsumerRewardDenoms": null,
"ClientsFrozenHeights": null,
"Proposals": null
}
}
Expand Down Expand Up @@ -417,6 +426,7 @@
"ConsumerChainQueueSizes": null,
"GlobalSlashQueueSize": null,
"RegisteredConsumerRewardDenoms": null,
"ClientsFrozenHeights": null,
"Proposals": null
}
}
Expand Down Expand Up @@ -446,6 +456,7 @@
"ConsumerChainQueueSizes": null,
"GlobalSlashQueueSize": null,
"RegisteredConsumerRewardDenoms": null,
"ClientsFrozenHeights": null,
"Proposals": null
},
"sover": {
Expand All @@ -464,6 +475,7 @@
"ConsumerChainQueueSizes": null,
"GlobalSlashQueueSize": null,
"RegisteredConsumerRewardDenoms": null,
"ClientsFrozenHeights": null,
"Proposals": null
}
}
Expand Down Expand Up @@ -493,6 +505,7 @@
"ConsumerChainQueueSizes": null,
"GlobalSlashQueueSize": null,
"RegisteredConsumerRewardDenoms": null,
"ClientsFrozenHeights": null,
"Proposals": null
}
}
Expand Down Expand Up @@ -520,6 +533,7 @@
"ConsumerChainQueueSizes": null,
"GlobalSlashQueueSize": null,
"RegisteredConsumerRewardDenoms": null,
"ClientsFrozenHeights": null,
"Proposals": null
}
}
Expand Down Expand Up @@ -549,6 +563,7 @@
"ConsumerChainQueueSizes": null,
"GlobalSlashQueueSize": null,
"RegisteredConsumerRewardDenoms": null,
"ClientsFrozenHeights": null,
"Proposals": null
},
"sover": {
Expand All @@ -567,6 +582,7 @@
"ConsumerChainQueueSizes": null,
"GlobalSlashQueueSize": null,
"RegisteredConsumerRewardDenoms": null,
"ClientsFrozenHeights": null,
"Proposals": null
}
}
Expand Down Expand Up @@ -596,6 +612,7 @@
"ConsumerChainQueueSizes": null,
"GlobalSlashQueueSize": null,
"RegisteredConsumerRewardDenoms": null,
"ClientsFrozenHeights": null,
"Proposals": null
}
}
Expand Down
Loading

0 comments on commit ea545b4

Please sign in to comment.