From c6671fc6813e20a30aee03b7db1844f3b9cc1fb1 Mon Sep 17 00:00:00 2001 From: Bernd Mueller Date: Fri, 30 Aug 2024 09:55:33 +0200 Subject: [PATCH] cleanup --- tests/e2e/actions.go | 26 +++++++++---------- tests/e2e/steps_partial_set_security.go | 34 ++++++++++++++++++------- tests/e2e/test_driver.go | 4 +-- 3 files changed, 39 insertions(+), 25 deletions(-) diff --git a/tests/e2e/actions.go b/tests/e2e/actions.go index 17e3525cc8..ec970771a6 100644 --- a/tests/e2e/actions.go +++ b/tests/e2e/actions.go @@ -314,7 +314,7 @@ func (tr Chain) updateConsumerChain(action UpdateConsumerChainAction, verbose bo tr.UpdateConsumer(action.Chain, action.From, update) } -type InitializeConsumerChainAction struct { +type CreateConsumerChainAction struct { Chain ChainID From ValidatorID ConsumerChain ChainID @@ -330,8 +330,8 @@ type InitializeConsumerChainAction struct { AllowInactiveVals bool } -// initializeConsumerChain creates and initializes a consumer chain -func (tr Chain) initializeConsumerChain(action InitializeConsumerChainAction, verbose bool) { +// createConsumerChain creates and initializes a consumer chain +func (tr Chain) createConsumerChain(action CreateConsumerChainAction, verbose bool) { spawn_time := tr.testConfig.containerConfig.Now.Add(time.Duration(action.SpawnTime) * time.Millisecond) params := ccvtypes.DefaultParams() @@ -366,14 +366,11 @@ func (tr Chain) initializeConsumerChain(action InitializeConsumerChainAction, ve Metadata: "no metadata", } - // create consumer - consumerID := tr.CreateConsumer(action.Chain, action.ConsumerChain, action.From, metadata, &initParams, nil) - - update := types.MsgUpdateConsumer{ - ConsumerId: consumerID, - PowerShapingParameters: &powerShapingParams, + // create consumer to get a consumer-id + consumerID := tr.CreateConsumer(action.Chain, action.ConsumerChain, action.From, metadata, &initParams, &powerShapingParams) + if verbose { + fmt.Println("Create consumer chain", string(action.ConsumerChain), " with consumer-id", consumerID) } - tr.UpdateConsumer(action.Chain, action.From, update) } type SubmitConsumerAdditionProposalAction struct { @@ -458,7 +455,7 @@ func (tr Chain) CreateConsumer(providerChain, consumerChain ChainID, validator V content, err := json.Marshal(rec) if err != nil { - log.Fatalf("failed marshalling ConsumerRegistrationRecord", err.Error()) + log.Fatalf("failed marshalling ConsumerRegistrationRecord: %s", err.Error()) } jsonFile := "/create_consumer.json" bz, err := tr.target.ExecCommand( @@ -505,7 +502,7 @@ func (tr Chain) CreateConsumer(providerChain, consumerChain ChainID, validator V // TODO: introduce waitForTx tr.waitBlocks(providerChain, 2, 10*time.Second) - // Get Consumer ID from tx + // Get Consumer ID from transaction cmd = tr.target.ExecCommand( tr.testConfig.chainConfigs[providerChain].BinaryName, "query", "tx", txResponse.TxHash, @@ -545,13 +542,14 @@ func (tr Chain) CreateConsumer(providerChain, consumerChain ChainID, validator V log.Fatal("chain ", chainID, " registered already with a different consumer ID", consumer_id) } - // Set the new created consumer-id on the chain's config + // Set the new created consumer-id on the chain's config cfg.ConsumerId = e2e.ConsumerID(consumer_id) tr.testConfig.chainConfigs[e2e.ChainID(chainID)] = cfg return consumer_id } +// submitConsumerAdditionProposal initializes a consumer chain and submits a governance proposal func (tr Chain) submitConsumerAdditionProposal( action SubmitConsumerAdditionProposalAction, verbose bool, @@ -588,7 +586,7 @@ func (tr Chain) submitConsumerAdditionProposal( ConsumerId: consumer_id, NewOwnerAddress: authority, } - // For the MsgUpdateConsumer sen in the proposal + // For the MsgUpdateConsumer sent in the proposal PowerShapingParameters := types.PowerShapingParameters{ Top_N: 0, ValidatorsPowerCap: action.ValidatorsPowerCap, diff --git a/tests/e2e/steps_partial_set_security.go b/tests/e2e/steps_partial_set_security.go index 4c2a5c457c..614f093c57 100644 --- a/tests/e2e/steps_partial_set_security.go +++ b/tests/e2e/steps_partial_set_security.go @@ -42,7 +42,7 @@ func stepsOptInChain() []Step { State: State{}, }, { - Action: InitializeConsumerChainAction{ + Action: CreateConsumerChainAction{ Chain: ChainID("provi"), From: ValidatorID("alice"), ConsumerChain: ChainID("consu"), @@ -1030,7 +1030,7 @@ func stepsValidatorSetCappedChain() []Step { }, }, { - Action: InitializeConsumerChainAction{ + Action: CreateConsumerChainAction{ Chain: ChainID("provi"), From: ValidatorID("alice"), ConsumerChain: ChainID("consu"), @@ -1039,7 +1039,11 @@ func stepsValidatorSetCappedChain() []Step { TopN: 0, ValidatorSetCap: 2, }, - State: State{}, + State: State{ + ChainID("provi"): ChainState{ + ProposedConsumerChains: &[]string{"consu"}, + }, + }, }, // Οpt in "alice", "bob", and "carol." Note, that "alice" and "bob" use the provider's public key // (see `UseConsumerKey` is set to `false` in `getDefaultValidators`) and hence do not need a consumer-key assignment. @@ -1464,7 +1468,7 @@ func stepsValidatorsAllowlistedChain() []Step { }, }, { - Action: InitializeConsumerChainAction{ + Action: CreateConsumerChainAction{ Chain: ChainID("provi"), From: ValidatorID("alice"), ConsumerChain: ChainID("consu"), @@ -1472,7 +1476,11 @@ func stepsValidatorsAllowlistedChain() []Step { InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, TopN: 0, }, - State: State{}, + State: State{ + ChainID("provi"): ChainState{ + ProposedConsumerChains: &[]string{"consu"}, + }, + }, }, // Οpt in "alice", "bob", and "carol." Note, that "alice" and "bob" use the provider's public key // (see `UseConsumerKey` is set to `false` in `getDefaultValidators`) and hence do not need a consumer-key assignment. @@ -1643,7 +1651,7 @@ func stepsValidatorsDenylistedChain() []Step { }, }, { - Action: InitializeConsumerChainAction{ + Action: CreateConsumerChainAction{ Chain: ChainID("provi"), From: ValidatorID("alice"), ConsumerChain: ChainID("consu"), @@ -1652,7 +1660,11 @@ func stepsValidatorsDenylistedChain() []Step { TopN: 0, ValidatorSetCap: 2, }, - State: State{}, + State: State{ + ChainID("provi"): ChainState{ + ProposedConsumerChains: &[]string{"consu"}, + }, + }, }, // Οpt in "alice", "bob", and "carol." Note, that "alice" and "bob" use the provider's public key // (see `UseConsumerKey` is set to `false` in `getDefaultValidators`) and hence do not need a consumer-key assignment. @@ -1820,7 +1832,7 @@ func stepsModifyChain() []Step { }, }, { - Action: InitializeConsumerChainAction{ + Action: CreateConsumerChainAction{ Chain: ChainID("provi"), From: ValidatorID("alice"), ConsumerChain: ChainID("consu"), @@ -1828,7 +1840,11 @@ func stepsModifyChain() []Step { InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, TopN: 0, }, - State: State{}, + State: State{ + ChainID("provi"): ChainState{ + ProposedConsumerChains: &[]string{"consu"}, + }, + }, }, // Οpt in "alice", "bob", and "carol." Note, that "alice" and "bob" use the provider's public key // (see `UseConsumerKey` is set to `false` in `getDefaultValidators`) and hence do not need a consumer-key assignment. diff --git a/tests/e2e/test_driver.go b/tests/e2e/test_driver.go index a7255c2231..6c2bc35d77 100644 --- a/tests/e2e/test_driver.go +++ b/tests/e2e/test_driver.go @@ -227,8 +227,8 @@ func (td *DefaultDriver) runAction(action interface{}) error { } else { target.submitChangeRewardDenomsProposal(action, td.verbose) } - case InitializeConsumerChainAction: - target.initializeConsumerChain(action, td.verbose) + case CreateConsumerChainAction: + target.createConsumerChain(action, td.verbose) case UpdateConsumerChainAction: target.updateConsumerChain(action, td.verbose) case OptInAction: