-
Notifications
You must be signed in to change notification settings - Fork 149
/
Copy pathsteps_stop_chain.go
124 lines (118 loc) · 3.33 KB
/
steps_stop_chain.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
package main
import (
gov "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
)
// start relayer so that all messages are relayed
func stepsStartRelayer() []Step {
return []Step{
{
Action: StartRelayerAction{},
State: State{},
},
}
}
// submits a consumer-removal proposal and removes the chain
func stepsStopChain(consumerName string, propNumber uint) []Step {
s := []Step{
{
Action: SubmitConsumerRemovalProposalAction{
Chain: ChainID("provi"),
From: ValidatorID("bob"),
Deposit: 10000001,
ConsumerChain: ChainID(consumerName),
},
State: State{
ChainID("provi"): ChainState{
ValBalances: &map[ValidatorID]uint{
ValidatorID("bob"): 9489999999,
},
Proposals: &map[uint]Proposal{
propNumber: ConsumerRemovalProposal{
Deposit: 10000001,
Chain: ChainID(consumerName),
Status: gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD.String(),
},
},
ConsumerChains: &map[ChainID]bool{"consu": true}, // consumer chain not yet removed
},
},
},
{
Action: VoteGovProposalAction{
Chain: ChainID("provi"),
From: []ValidatorID{ValidatorID("alice"), ValidatorID("bob"), ValidatorID("carol")},
Vote: []string{"yes", "yes", "yes"},
PropNumber: propNumber,
},
State: State{
ChainID("provi"): ChainState{
Proposals: &map[uint]Proposal{
propNumber: ConsumerRemovalProposal{
Deposit: 10000001,
Chain: ChainID(consumerName),
Status: gov.ProposalStatus_PROPOSAL_STATUS_PASSED.String(),
},
},
ValBalances: &map[ValidatorID]uint{
ValidatorID("bob"): 9500000000,
},
ConsumerChains: &map[ChainID]bool{}, // Consumer chain is now removed
},
},
},
}
return s
}
// submits a consumer-removal proposal and votes no on it
// the chain should not be removed
func stepsConsumerRemovalPropNotPassing(consumerName string, propNumber uint) []Step {
s := []Step{
{
Action: SubmitConsumerRemovalProposalAction{
Chain: ChainID("provi"),
From: ValidatorID("bob"),
Deposit: 10000001,
ConsumerChain: ChainID(consumerName),
},
State: State{
ChainID("provi"): ChainState{
ValBalances: &map[ValidatorID]uint{
ValidatorID("bob"): 9489999999,
},
Proposals: &map[uint]Proposal{
propNumber: ConsumerRemovalProposal{
Deposit: 10000001,
Chain: ChainID(consumerName),
Status: gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD.String(),
},
},
ConsumerChains: &map[ChainID]bool{"consu": true}, // consumer chain not removed
},
},
},
{
Action: VoteGovProposalAction{
Chain: ChainID("provi"),
From: []ValidatorID{ValidatorID("alice"), ValidatorID("bob"), ValidatorID("carol")},
Vote: []string{"no", "no", "no"},
PropNumber: propNumber,
},
State: State{
ChainID("provi"): ChainState{
Proposals: &map[uint]Proposal{
propNumber: ConsumerRemovalProposal{
Deposit: 10000001,
Chain: ChainID(consumerName),
Status: gov.ProposalStatus_PROPOSAL_STATUS_REJECTED.String(),
},
},
ValBalances: &map[ValidatorID]uint{
ValidatorID("bob"): 9500000000,
},
ConsumerChains: &map[ChainID]bool{"consu": true}, // consumer chain not removed
},
},
},
}
return s
}