Skip to content

Commit 3121212

Browse files
committed
fix: updated e2e testing for consumer transition
1 parent 1ae670b commit 3121212

File tree

12 files changed

+117
-16
lines changed

12 files changed

+117
-16
lines changed

tests/e2e/actions.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ type SubmitConsumerAdditionProposalAction struct {
261261
InitialHeight clienttypes.Height
262262
DistributionChannel string
263263
TopN uint32
264+
ConnectionId string // ICS1: Connection ID for connection reuse during changeover
264265
}
265266

266267
func (tr Chain) submitConsumerAdditionProposal(
@@ -286,6 +287,7 @@ func (tr Chain) submitConsumerAdditionProposal(
286287
Deposit: fmt.Sprint(action.Deposit) + `stake`,
287288
DistributionTransmissionChannel: action.DistributionChannel,
288289
TopN: action.TopN,
290+
ConnectionId: action.ConnectionId, // ICS1: Connection ID for connection reuse
289291
}
290292

291293
bz, err := json.Marshal(prop)

tests/e2e/steps.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,12 @@ var happyPathSteps = concatSteps(
3434
stepsCancelUnbond("consu"),
3535
stepsRedelegate("consu"),
3636
stepsDowntime("consu"),
37-
stepsDoubleSignOnProvider("consu"), // carol double signs on provider
37+
stepsDoubleSignOnProvider("consu"), // carol double signs on provider
3838
stepsStartRelayer(),
3939
stepsConsumerRemovalPropNotPassing("consu", 2), // submit removal prop but vote no on it - chain should stay
40-
stepsStopChain("consu", 3), // stop chain
40+
stepsStopChain("consu", 3), // stop chain - consumer becomes sovereign
41+
stepsReAddConsumerWithConnectionReuse("consu", 4), // ICS1: re-add consumer with connection reuse
42+
// Connection reuse test complete - consumer successfully re-added using existing connection-0
4143
)
4244

4345
var shortHappyPathSteps = concatSteps(
@@ -46,10 +48,12 @@ var shortHappyPathSteps = concatSteps(
4648
stepsUnbond("consu"),
4749
stepsRedelegate("consu"),
4850
stepsDowntime("consu"),
49-
stepsDoubleSignOnProvider("consu"), // carol double signs on provider
51+
stepsDoubleSignOnProvider("consu"), // carol double signs on provider
5052
stepsStartRelayer(),
5153
stepsConsumerRemovalPropNotPassing("consu", 2), // submit removal prop but vote no on it - chain should stay
52-
stepsStopChain("consu", 3), // stop chain
54+
stepsStopChain("consu", 3), // stop chain - consumer becomes sovereign
55+
stepsReAddConsumerWithConnectionReuse("consu", 4), // ICS1: re-add consumer with connection reuse
56+
// Connection reuse test complete - consumer successfully re-added using existing connection-0
5357
)
5458

5559
var lightClientAttackSteps = concatSteps(

tests/e2e/steps_sovereign_changeover.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@ func stepsChangeoverToConsumer(consumerName string) []Step {
4949
// the consumer chain will use this channel to send rewards to the provider chain
5050
// there is no need to create a new channel for rewards distribution
5151
DistributionChannel: "channel-0",
52-
SpawnTime: 0,
53-
InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 111}, // 1 block after upgrade !important
52+
// ICS1: connection-0 is created in stepsSovereignTransferChan and will be reused for CCV
53+
ConnectionId: "connection-0",
54+
SpawnTime: 0,
55+
InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 111}, // 1 block after upgrade !important
5456
},
5557
State: State{
5658
ChainID("provi"): ChainState{

tests/e2e/steps_stop_chain.go

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"time"
55

66
gov "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
7+
clienttypes "github.com/cosmos/ibc-go/v10/modules/core/02-client/types"
78
)
89

910
// start relayer so that all messages are relayed
@@ -130,3 +131,65 @@ func stepsConsumerRemovalPropNotPassing(consumerName string, propNumber uint) []
130131

131132
return s
132133
}
134+
135+
// ICS1: Re-adds a consumer chain that was previously removed, reusing the existing IBC connection.
136+
// This tests the connection reuse feature for standalone-to-consumer transitions.
137+
// The consumerName should match a previously removed consumer chain that still has an active IBC connection.
138+
func stepsReAddConsumerWithConnectionReuse(consumerName string, propNumber uint) []Step {
139+
s := []Step{
140+
{
141+
Action: SubmitConsumerAdditionProposalAction{
142+
Chain: ChainID("provi"),
143+
From: ValidatorID("alice"),
144+
Deposit: 10000001,
145+
ConsumerChain: ChainID(consumerName),
146+
SpawnTime: 0,
147+
InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1},
148+
TopN: 100, // All validators must validate (100% = Replicated Security)
149+
// ICS1: Reuse connection-0 that was created when the consumer was first added
150+
ConnectionId: "connection-0",
151+
},
152+
State: State{
153+
ChainID("provi"): ChainState{
154+
// Don't check balances - they vary due to gas costs from previous operations
155+
Proposals: &map[uint]Proposal{
156+
propNumber: ConsumerAdditionProposal{
157+
Deposit: 10000001,
158+
Chain: ChainID(consumerName),
159+
SpawnTime: 0,
160+
InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1},
161+
Status: gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD.String(),
162+
},
163+
},
164+
ProposedConsumerChains: &[]string{consumerName},
165+
},
166+
},
167+
},
168+
{
169+
Action: VoteGovProposalAction{
170+
Chain: ChainID("provi"),
171+
From: []ValidatorID{ValidatorID("alice"), ValidatorID("bob"), ValidatorID("carol")},
172+
Vote: []string{"yes", "yes", "yes"},
173+
PropNumber: propNumber,
174+
},
175+
State: State{
176+
ChainID("provi"): ChainState{
177+
Proposals: &map[uint]Proposal{
178+
propNumber: ConsumerAdditionProposal{
179+
Deposit: 10000001,
180+
Chain: ChainID(consumerName),
181+
SpawnTime: 0,
182+
InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1},
183+
Status: gov.ProposalStatus_PROPOSAL_STATUS_PASSED.String(),
184+
},
185+
},
186+
// Don't check balances - they vary due to gas costs from previous operations
187+
// Consumer chain is re-added
188+
ConsumerChains: &map[ChainID]bool{ChainID(consumerName): true},
189+
},
190+
},
191+
},
192+
}
193+
194+
return s
195+
}

testutil/keeper/unit_test_helpers.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,8 @@ func GetTestConsumerAdditionProp() *providertypes.ConsumerAdditionProposal {
280280
types.DefaultCCVTimeoutPeriod,
281281
types.DefaultTransferTimeoutPeriod,
282282
types.DefaultConsumerUnbondingPeriod,
283-
0, // TopN = 0 for opt-in chain (doesn't require validators for testing)
283+
0, // TopN = 0 for opt-in chain (doesn't require validators for testing)
284+
"", // ConnectionId - empty for non-changeover test
284285
).(*providertypes.ConsumerAdditionProposal)
285286

286287
return prop

x/ccv/provider/client/legacy_proposal_handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ Where proposal.json contains:
8484
proposal.ConsumerRedistributionFraction, proposal.BlocksPerDistributionTransmission,
8585
proposal.DistributionTransmissionChannel, proposal.HistoricalEntries,
8686
proposal.CcvTimeoutPeriod, proposal.TransferTimeoutPeriod, proposal.UnbondingPeriod,
87-
proposal.TopN)
87+
proposal.TopN, proposal.ConnectionId)
8888

8989
from := clientCtx.GetFromAddress()
9090

x/ccv/provider/client/legacy_proposals.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ type ConsumerAdditionProposalJSON struct {
3737
Deposit string `json:"deposit"`
3838

3939
TopN uint32 `json:"top_N"`
40+
41+
// ICS1: Connection ID for connection reuse during standalone-to-consumer changeover
42+
ConnectionId string `json:"connection_id"`
4043
}
4144

4245
type ConsumerAdditionProposalReq struct {

x/ccv/provider/keeper/legacy_proposal_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ func TestHandleLegacyConsumerAdditionProposal(t *testing.T) {
5757
100000000000,
5858
100000000000,
5959
100000000000,
60-
0, // Opt-in chain - doesn't require validators at startup
60+
0, // Opt-in chain - doesn't require validators at startup
61+
"", // ConnectionId
6162
).(*providertypes.ConsumerAdditionProposal),
6263
blockTime: now,
6364
expAppendProp: true,
@@ -83,7 +84,8 @@ func TestHandleLegacyConsumerAdditionProposal(t *testing.T) {
8384
100000000000,
8485
100000000000,
8586
100000000000,
86-
0, // Opt-in chain - doesn't require validators at startup
87+
0, // Opt-in chain - doesn't require validators at startup
88+
"", // ConnectionId
8789
).(*providertypes.ConsumerAdditionProposal),
8890
blockTime: now,
8991
expAppendProp: false,

x/ccv/provider/keeper/proposal_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ func TestHandleConsumerAdditionProposal(t *testing.T) {
6868
100000000000,
6969
100000000000,
7070
100000000000,
71-
0, // Opt-in chain - doesn't require validators at startup
71+
0, // Opt-in chain - doesn't require validators at startup
72+
"", // ConnectionId
7273
).(*providertypes.ConsumerAdditionProposal),
7374
blockTime: now,
7475
expAppendProp: true,
@@ -94,7 +95,8 @@ func TestHandleConsumerAdditionProposal(t *testing.T) {
9495
100000000000,
9596
100000000000,
9697
100000000000,
97-
0, // Opt-in chain - doesn't require validators at startup
98+
0, // Opt-in chain - doesn't require validators at startup
99+
"", // ConnectionId
98100
).(*providertypes.ConsumerAdditionProposal),
99101
blockTime: now,
100102
expAppendProp: false,

x/ccv/provider/proposal_handler_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ func TestProviderProposalHandler(t *testing.T) {
4646
100000000000,
4747
100000000000,
4848
100000000000,
49-
0, // TopN = 0 for opt-in chain
49+
0, // TopN = 0 for opt-in chain
50+
"", // ConnectionId
5051
),
5152
blockTime: hourFromNow, // ctx blocktime is after proposal's spawn time
5253
expValidConsumerAddition: true,

0 commit comments

Comments
 (0)