@@ -42,7 +42,7 @@ func TestMigrateParamsv1p0To1p3(t *testing.T) {
42
42
)
43
43
44
44
// Note that new param key table is set in keeper constructor
45
- subspace = subspace .WithKeyTable (consumertypes . ParamKeyTable ())
45
+ subspace = subspace .WithKeyTable (v1p0p0KeyTable ())
46
46
47
47
// Set 9 params from v1.0.0
48
48
subspace .Set (ctx , consumertypes .KeyEnabled , true )
@@ -55,10 +55,24 @@ func TestMigrateParamsv1p0To1p3(t *testing.T) {
55
55
subspace .Set (ctx , consumertypes .KeyHistoricalEntries , int64 (10 ))
56
56
subspace .Set (ctx , consumertypes .KeyConsumerUnbondingPeriod , time .Hour )
57
57
58
- // Confirm 3 new params are not set
59
- require .False (t , subspace .Has (ctx , consumertypes .KeySoftOptOutThreshold ))
60
- require .False (t , subspace .Has (ctx , consumertypes .KeyRewardDenoms ))
61
- require .False (t , subspace .Has (ctx , consumertypes .KeyProviderRewardDenoms ))
58
+ // Confirm 3 new params cannot be set with old key table
59
+ require .Panics (t , func () {
60
+ subspace .Set (ctx , consumertypes .KeySoftOptOutThreshold , "0.05" )
61
+ })
62
+ require .Panics (t , func () {
63
+ subspace .Set (ctx , consumertypes .KeyRewardDenoms , []string {"untrn" })
64
+ })
65
+ require .Panics (t , func () {
66
+ subspace .Set (ctx , consumertypes .KeyProviderRewardDenoms , []string {"uatom" })
67
+ })
68
+
69
+ // Now create new subspace, mocking an upgrade where app initialization happens again
70
+ subspace = paramtypes .NewSubspace (cdc ,
71
+ codec .NewLegacyAmino (),
72
+ storeKey ,
73
+ memStoreKey ,
74
+ paramtypes .ModuleName ,
75
+ ).WithKeyTable (consumertypes .ParamKeyTable ()) // Use new key table, this would be set in keeper constructor
62
76
63
77
// Run migration
64
78
consumerkeeper .MigrateParamsv1p0To1p3 (ctx , subspace )
@@ -92,3 +106,49 @@ func TestMigrateParamsv1p0To1p3(t *testing.T) {
92
106
require .Equal (t , []string {"untrn" }, keeper .GetRewardDenoms (ctx ))
93
107
require .Equal (t , []string {"uatom" }, keeper .GetProviderRewardDenoms (ctx ))
94
108
}
109
+
110
+ //
111
+ // Note: the following methods and struct could be removed if v1.3.0 is actually defined as v2.0.0
112
+ // and we bump the go.mod package name accordingly
113
+ //
114
+
115
+ // v1p0p0Params is a copy of the ParamKeyTable method from v1.0.0
116
+ func v1p0p0KeyTable () paramtypes.KeyTable {
117
+ return paramtypes .NewKeyTable ().RegisterParamSet (& v1p0p0Params {})
118
+ }
119
+
120
+ // ParamSetPairs implements params.ParamSet for v1p0p0Params
121
+ func (p * v1p0p0Params ) ParamSetPairs () paramtypes.ParamSetPairs {
122
+ return paramtypes.ParamSetPairs {
123
+ paramtypes .NewParamSetPair (consumertypes .KeyEnabled , p .Enabled , ccvtypes .ValidateBool ),
124
+ paramtypes .NewParamSetPair (consumertypes .KeyBlocksPerDistributionTransmission ,
125
+ p .BlocksPerDistributionTransmission , ccvtypes .ValidatePositiveInt64 ),
126
+ paramtypes .NewParamSetPair (consumertypes .KeyDistributionTransmissionChannel ,
127
+ p .DistributionTransmissionChannel , consumertypes .ValidateDistributionTransmissionChannel ),
128
+ paramtypes .NewParamSetPair (consumertypes .KeyProviderFeePoolAddrStr ,
129
+ p .ProviderFeePoolAddrStr , consumertypes .ValidateProviderFeePoolAddrStr ),
130
+ paramtypes .NewParamSetPair (ccvtypes .KeyCCVTimeoutPeriod ,
131
+ p .CcvTimeoutPeriod , ccvtypes .ValidateDuration ),
132
+ paramtypes .NewParamSetPair (consumertypes .KeyTransferTimeoutPeriod ,
133
+ p .TransferTimeoutPeriod , ccvtypes .ValidateDuration ),
134
+ paramtypes .NewParamSetPair (consumertypes .KeyConsumerRedistributionFrac ,
135
+ p .ConsumerRedistributionFraction , ccvtypes .ValidateStringFraction ),
136
+ paramtypes .NewParamSetPair (consumertypes .KeyHistoricalEntries ,
137
+ p .HistoricalEntries , ccvtypes .ValidatePositiveInt64 ),
138
+ paramtypes .NewParamSetPair (consumertypes .KeyConsumerUnbondingPeriod ,
139
+ p .UnbondingPeriod , ccvtypes .ValidateDuration ),
140
+ }
141
+ }
142
+
143
+ // v1p0p0Params is a copy of the Params struct from v1.0.0
144
+ type v1p0p0Params struct {
145
+ Enabled bool `protobuf:"varint,1,opt,name=enabled,proto3" json:"enabled,omitempty"`
146
+ BlocksPerDistributionTransmission int64 `protobuf:"varint,2,opt,name=blocks_per_distribution_transmission,json=blocksPerDistributionTransmission,proto3" json:"blocks_per_distribution_transmission,omitempty"`
147
+ DistributionTransmissionChannel string `protobuf:"bytes,3,opt,name=distribution_transmission_channel,json=distributionTransmissionChannel,proto3" json:"distribution_transmission_channel,omitempty"`
148
+ ProviderFeePoolAddrStr string `protobuf:"bytes,4,opt,name=provider_fee_pool_addr_str,json=providerFeePoolAddrStr,proto3" json:"provider_fee_pool_addr_str,omitempty"`
149
+ CcvTimeoutPeriod time.Duration `protobuf:"bytes,5,opt,name=ccv_timeout_period,json=ccvTimeoutPeriod,proto3,stdduration" json:"ccv_timeout_period"`
150
+ TransferTimeoutPeriod time.Duration `protobuf:"bytes,6,opt,name=transfer_timeout_period,json=transferTimeoutPeriod,proto3,stdduration" json:"transfer_timeout_period"`
151
+ ConsumerRedistributionFraction string `protobuf:"bytes,7,opt,name=consumer_redistribution_fraction,json=consumerRedistributionFraction,proto3" json:"consumer_redistribution_fraction,omitempty"`
152
+ HistoricalEntries int64 `protobuf:"varint,8,opt,name=historical_entries,json=historicalEntries,proto3" json:"historical_entries,omitempty"`
153
+ UnbondingPeriod time.Duration `protobuf:"bytes,9,opt,name=unbonding_period,json=unbondingPeriod,proto3,stdduration" json:"unbonding_period"`
154
+ }
0 commit comments