Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
bermuell committed Aug 30, 2024
1 parent 603fdbd commit c6671fc
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 25 deletions.
26 changes: 12 additions & 14 deletions tests/e2e/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
34 changes: 25 additions & 9 deletions tests/e2e/steps_partial_set_security.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func stepsOptInChain() []Step {
State: State{},
},
{
Action: InitializeConsumerChainAction{
Action: CreateConsumerChainAction{
Chain: ChainID("provi"),
From: ValidatorID("alice"),
ConsumerChain: ChainID("consu"),
Expand Down Expand Up @@ -1030,7 +1030,7 @@ func stepsValidatorSetCappedChain() []Step {
},
},
{
Action: InitializeConsumerChainAction{
Action: CreateConsumerChainAction{
Chain: ChainID("provi"),
From: ValidatorID("alice"),
ConsumerChain: ChainID("consu"),
Expand All @@ -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.
Expand Down Expand Up @@ -1464,15 +1468,19 @@ func stepsValidatorsAllowlistedChain() []Step {
},
},
{
Action: InitializeConsumerChainAction{
Action: CreateConsumerChainAction{
Chain: ChainID("provi"),
From: ValidatorID("alice"),
ConsumerChain: ChainID("consu"),
SpawnTime: uint(time.Minute * 10), // set spawn-time far in the future
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.
Expand Down Expand Up @@ -1643,7 +1651,7 @@ func stepsValidatorsDenylistedChain() []Step {
},
},
{
Action: InitializeConsumerChainAction{
Action: CreateConsumerChainAction{
Chain: ChainID("provi"),
From: ValidatorID("alice"),
ConsumerChain: ChainID("consu"),
Expand All @@ -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.
Expand Down Expand Up @@ -1820,15 +1832,19 @@ func stepsModifyChain() []Step {
},
},
{
Action: InitializeConsumerChainAction{
Action: CreateConsumerChainAction{
Chain: ChainID("provi"),
From: ValidatorID("alice"),
ConsumerChain: ChainID("consu"),
SpawnTime: uint(time.Minute * 10), // set spawn-time far in the future
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.
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/test_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit c6671fc

Please sign in to comment.