Skip to content

Commit

Permalink
refactor RepresentativePowers to StakedTokens
Browse files Browse the repository at this point in the history
  • Loading branch information
insumity committed Sep 27, 2023
1 parent d2c2950 commit 72b12e2
Show file tree
Hide file tree
Showing 11 changed files with 339 additions and 338 deletions.
14 changes: 7 additions & 7 deletions tests/e2e/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type ChainState struct {
ValBalances *map[ValidatorID]uint
Proposals *map[uint]Proposal
ValPowers *map[ValidatorID]uint
RepresentativePowers *map[ValidatorID]uint
StakedTokens *map[ValidatorID]uint
Params *[]Param
Rewards *Rewards
ConsumerChains *map[ChainID]bool
Expand Down Expand Up @@ -138,9 +138,9 @@ func (tr TestConfig) getChainState(chain ChainID, modelState ChainState) ChainSt
chainState.ValPowers = &powers
}

if modelState.RepresentativePowers != nil {
representPowers := tr.getRepresentativePowers(chain, *modelState.RepresentativePowers)
chainState.RepresentativePowers = &representPowers
if modelState.StakedTokens != nil {
representPowers := tr.getStakedTokens(chain, *modelState.StakedTokens)
chainState.StakedTokens = &representPowers
}

if modelState.Params != nil {
Expand Down Expand Up @@ -282,10 +282,10 @@ func (tr TestConfig) getValPowers(chain ChainID, modelState map[ValidatorID]uint
return actualState
}

func (tr TestConfig) getRepresentativePowers(chain ChainID, modelState map[ValidatorID]uint) map[ValidatorID]uint {
func (tr TestConfig) getStakedTokens(chain ChainID, modelState map[ValidatorID]uint) map[ValidatorID]uint {
actualState := map[ValidatorID]uint{}
for k := range modelState {
actualState[k] = tr.getRepresentativePower(chain, k)
actualState[k] = tr.getValStakedTokens(chain, k)
}

return actualState
Expand Down Expand Up @@ -547,7 +547,7 @@ func (tr TestConfig) getValPower(chain ChainID, validator ValidatorID) uint {
return 0
}

func (tr TestConfig) getRepresentativePower(chain ChainID, validator ValidatorID) uint {
func (tr TestConfig) getValStakedTokens(chain ChainID, validator ValidatorID) uint {
//#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments.
bz, err := exec.Command("docker", "exec", tr.containerConfig.InstanceName, tr.chainConfigs[chain].BinaryName,

Expand Down
8 changes: 4 additions & 4 deletions tests/e2e/state_rapid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func GetChainStateGen() *rapid.Generator[ChainState] {
valBalances := GetValBalancesGen().Draw(t, "ValBalances")
proposals := GetProposalsGen().Draw(t, "Proposals")
valPowers := GetValPowersGen().Draw(t, "ValPowers")
representativePowers := GetRepresentativePowersGen().Draw(t, "RepresentativePowers")
stakedTokens := GetStakedTokensGen().Draw(t, "StakedTokens")
params := GetParamsGen().Draw(t, "Params")
rewards := GetRewardsGen().Draw(t, "Rewards")
consumerChains := GetConsumerChainsGen().Draw(t, "ConsumerChains")
Expand All @@ -53,7 +53,7 @@ func GetChainStateGen() *rapid.Generator[ChainState] {
ValBalances: &valBalances,
Proposals: &proposals,
ValPowers: &valPowers,
RepresentativePowers: &representativePowers,
StakedTokens: &stakedTokens,
Params: &params,
Rewards: &rewards,
ConsumerChains: &consumerChains,
Expand Down Expand Up @@ -127,12 +127,12 @@ func GetParamGen() *rapid.Generator[Param] {
})
}

func GetRepresentativePowersGen() *rapid.Generator[map[ValidatorID]uint] {
func GetStakedTokensGen() *rapid.Generator[map[ValidatorID]uint] {
return rapid.Custom(func(t *rapid.T) map[ValidatorID]uint {
return rapid.MapOf(
GetValidatorIDGen(),
rapid.Uint(),
).Draw(t, "RepresentativePowers")
).Draw(t, "StakedTokens")
})
}

Expand Down
6 changes: 3 additions & 3 deletions tests/e2e/steps_democracy.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func stepsDemocracy(consumerName string) []Step {
},
State: State{
ChainID(consumerName): ChainState{
RepresentativePowers: &map[ValidatorID]uint{
StakedTokens: &map[ValidatorID]uint{
ValidatorID("alice"): 100000000,
ValidatorID("bob"): 40000000,
},
Expand All @@ -38,7 +38,7 @@ func stepsDemocracy(consumerName string) []Step {
State: State{
ChainID(consumerName): ChainState{
// Check that delegators on gov-consumer chain can change representative powers
RepresentativePowers: &map[ValidatorID]uint{
StakedTokens: &map[ValidatorID]uint{
ValidatorID("alice"): 100500000,
ValidatorID("bob"): 40000000,
},
Expand Down Expand Up @@ -286,7 +286,7 @@ func stepsDemocracy(consumerName string) []Step {
ValidatorID("carol"): 500,
},
// Check that slashing on the gov-consumer chain does not result in slashing for the representatives or their delegators
RepresentativePowers: &map[ValidatorID]uint{
StakedTokens: &map[ValidatorID]uint{
ValidatorID("alice"): 100500000,
ValidatorID("bob"): 40000000,
},
Expand Down
6 changes: 3 additions & 3 deletions tests/e2e/steps_reward_denom.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ func stepsRewardDenomConsumer(consumerName string) []Step {
},
State: State{
ChainID(consumerName): ChainState{
RepresentativePowers: &map[ValidatorID]uint{
StakedTokens: &map[ValidatorID]uint{
ValidatorID("alice"): 100000000,
ValidatorID("bob"): 40000000,
},
Expand All @@ -36,7 +36,7 @@ func stepsRewardDenomConsumer(consumerName string) []Step {
State: State{
ChainID(consumerName): ChainState{
// Check that delegators on gov-consumer chain can change representative powers
RepresentativePowers: &map[ValidatorID]uint{
StakedTokens: &map[ValidatorID]uint{
ValidatorID("alice"): 100500000,
ValidatorID("bob"): 40000000,
},
Expand Down Expand Up @@ -284,7 +284,7 @@ func stepsRewardDenomConsumer(consumerName string) []Step {
ValidatorID("carol"): 500,
},
// Check that slashing on the gov-consumer chain does not result in slashing for the representatives or their delegators
RepresentativePowers: &map[ValidatorID]uint{
StakedTokens: &map[ValidatorID]uint{
ValidatorID("alice"): 100500000,
ValidatorID("bob"): 40000000,
},
Expand Down
34 changes: 17 additions & 17 deletions tests/e2e/tracehandler_testdata/changeover.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"alice": 9500000000
},
"ValPowers": null,
"RepresentativePowers": null,
"StakedTokens": null,
"Params": null,
"Rewards": null,
"ConsumerChains": null,
Expand Down Expand Up @@ -47,7 +47,7 @@
"bob": 0,
"carol": 0
},
"RepresentativePowers": null,
"StakedTokens": null,
"Params": null,
"Rewards": null,
"ConsumerChains": null,
Expand Down Expand Up @@ -92,7 +92,7 @@
"carol": 9500000000
},
"ValPowers": null,
"RepresentativePowers": null,
"StakedTokens": null,
"Params": null,
"Rewards": null,
"ConsumerChains": null,
Expand Down Expand Up @@ -138,7 +138,7 @@
"sover": {
"ValBalances": null,
"ValPowers": null,
"RepresentativePowers": null,
"StakedTokens": null,
"Params": null,
"Rewards": null,
"ConsumerChains": null,
Expand Down Expand Up @@ -179,7 +179,7 @@
"sover": {
"ValBalances": null,
"ValPowers": null,
"RepresentativePowers": null,
"StakedTokens": null,
"Params": null,
"Rewards": null,
"ConsumerChains": null,
Expand Down Expand Up @@ -233,7 +233,7 @@
"bob": 9500000000
},
"ValPowers": null,
"RepresentativePowers": null,
"StakedTokens": null,
"Params": null,
"Rewards": null,
"ConsumerChains": null,
Expand Down Expand Up @@ -282,7 +282,7 @@
"bob": 9500000000
},
"ValPowers": null,
"RepresentativePowers": null,
"StakedTokens": null,
"Params": null,
"Rewards": null,
"ConsumerChains": null,
Expand Down Expand Up @@ -340,7 +340,7 @@
"bob": 500,
"carol": 500
},
"RepresentativePowers": null,
"StakedTokens": null,
"Params": null,
"Rewards": null,
"ConsumerChains": null,
Expand All @@ -358,7 +358,7 @@
"bob": 500,
"carol": 500
},
"RepresentativePowers": null,
"StakedTokens": null,
"Params": null,
"Rewards": null,
"ConsumerChains": null,
Expand Down Expand Up @@ -408,7 +408,7 @@
"bob": 0
},
"ValPowers": null,
"RepresentativePowers": null,
"StakedTokens": null,
"Params": null,
"Rewards": null,
"ConsumerChains": null,
Expand Down Expand Up @@ -437,7 +437,7 @@
"bob": 500,
"carol": 500
},
"RepresentativePowers": null,
"StakedTokens": null,
"Params": null,
"Rewards": null,
"ConsumerChains": null,
Expand All @@ -455,7 +455,7 @@
"bob": 500,
"carol": 500
},
"RepresentativePowers": null,
"StakedTokens": null,
"Params": null,
"Rewards": null,
"ConsumerChains": null,
Expand Down Expand Up @@ -484,7 +484,7 @@
"bob": 500,
"carol": 500
},
"RepresentativePowers": null,
"StakedTokens": null,
"Params": null,
"Rewards": null,
"ConsumerChains": null,
Expand All @@ -511,7 +511,7 @@
"bob": 100
},
"ValPowers": null,
"RepresentativePowers": null,
"StakedTokens": null,
"Params": null,
"Rewards": null,
"ConsumerChains": null,
Expand Down Expand Up @@ -540,7 +540,7 @@
"bob": 500,
"carol": 500
},
"RepresentativePowers": null,
"StakedTokens": null,
"Params": null,
"Rewards": null,
"ConsumerChains": null,
Expand All @@ -558,7 +558,7 @@
"bob": 500,
"carol": 500
},
"RepresentativePowers": null,
"StakedTokens": null,
"Params": null,
"Rewards": null,
"ConsumerChains": null,
Expand Down Expand Up @@ -587,7 +587,7 @@
"bob": 500,
"carol": 500
},
"RepresentativePowers": null,
"StakedTokens": null,
"Params": null,
"Rewards": null,
"ConsumerChains": null,
Expand Down
Loading

0 comments on commit 72b12e2

Please sign in to comment.