@@ -61,19 +61,28 @@ func makeConfigPair(id, modificationPolicy string, lastModified uint64, data []b
61
61
}
62
62
}
63
63
64
- func makeConfigEnvelope ( chainID string , configPairs ... * configPair ) * cb.ConfigEnvelope {
64
+ func makeEnvelopeConfig ( channelID string , configPairs ... * configPair ) * cb.Envelope {
65
65
values := make (map [string ]* cb.ConfigValue )
66
66
for _ , pair := range configPairs {
67
67
values [pair .key ] = pair .value
68
68
}
69
69
70
- return & cb.ConfigEnvelope {
71
- Config : & cb.Config {
72
- Header : & cb.ChannelHeader {ChannelId : chainID },
73
- Channel : & cb.ConfigGroup {
74
- Values : values ,
70
+ return & cb.Envelope {
71
+ Payload : utils .MarshalOrPanic (& cb.Payload {
72
+ Header : & cb.Header {
73
+ ChannelHeader : utils .MarshalOrPanic (& cb.ChannelHeader {
74
+ Type : int32 (cb .HeaderType_CONFIG ),
75
+ ChannelId : channelID ,
76
+ }),
75
77
},
76
- },
78
+ Data : utils .MarshalOrPanic (& cb.ConfigEnvelope {
79
+ Config : & cb.Config {
80
+ ChannelGroup : & cb.ConfigGroup {
81
+ Values : values ,
82
+ },
83
+ },
84
+ }),
85
+ }),
77
86
}
78
87
}
79
88
@@ -84,7 +93,7 @@ func makeConfigUpdateEnvelope(chainID string, configPairs ...*configPair) *cb.En
84
93
}
85
94
86
95
config := & cb.ConfigUpdate {
87
- Header : & cb. ChannelHeader { ChannelId : chainID } ,
96
+ ChannelId : chainID ,
88
97
WriteSet : & cb.ConfigGroup {
89
98
Values : values ,
90
99
},
@@ -110,7 +119,7 @@ func TestCallback(t *testing.T) {
110
119
}
111
120
112
121
cm , err := NewManagerImpl (
113
- makeConfigEnvelope (defaultChain , makeConfigPair ("foo" , "foo" , 0 , []byte ("foo" ))),
122
+ makeEnvelopeConfig (defaultChain , makeConfigPair ("foo" , "foo" , 0 , []byte ("foo" ))),
114
123
defaultInitializer (), []func (api.Manager ){callback })
115
124
116
125
if err != nil {
@@ -125,7 +134,7 @@ func TestCallback(t *testing.T) {
125
134
// TestDifferentChainID tests that a config update for a different chain ID fails
126
135
func TestDifferentChainID (t * testing.T ) {
127
136
cm , err := NewManagerImpl (
128
- makeConfigEnvelope (defaultChain , makeConfigPair ("foo" , "foo" , 0 , []byte ("foo" ))),
137
+ makeEnvelopeConfig (defaultChain , makeConfigPair ("foo" , "foo" , 0 , []byte ("foo" ))),
129
138
defaultInitializer (), nil )
130
139
131
140
if err != nil {
@@ -143,7 +152,7 @@ func TestDifferentChainID(t *testing.T) {
143
152
// TestOldConfigReplay tests that resubmitting a config for a sequence number which is not newer is ignored
144
153
func TestOldConfigReplay (t * testing.T ) {
145
154
cm , err := NewManagerImpl (
146
- makeConfigEnvelope (defaultChain , makeConfigPair ("foo" , "foo" , 0 , []byte ("foo" ))),
155
+ makeEnvelopeConfig (defaultChain , makeConfigPair ("foo" , "foo" , 0 , []byte ("foo" ))),
147
156
defaultInitializer (), nil )
148
157
149
158
if err != nil {
@@ -161,7 +170,7 @@ func TestOldConfigReplay(t *testing.T) {
161
170
// TestValidConfigChange tests the happy path of updating a config value with no defaultModificationPolicy
162
171
func TestValidConfigChange (t * testing.T ) {
163
172
cm , err := NewManagerImpl (
164
- makeConfigEnvelope (defaultChain , makeConfigPair ("foo" , "foo" , 0 , []byte ("foo" ))),
173
+ makeEnvelopeConfig (defaultChain , makeConfigPair ("foo" , "foo" , 0 , []byte ("foo" ))),
165
174
defaultInitializer (), nil )
166
175
167
176
if err != nil {
@@ -190,7 +199,7 @@ func TestValidConfigChange(t *testing.T) {
190
199
// config values while advancing another
191
200
func TestConfigChangeRegressedSequence (t * testing.T ) {
192
201
cm , err := NewManagerImpl (
193
- makeConfigEnvelope (defaultChain , makeConfigPair ("foo" , "foo" , 1 , []byte ("foo" ))),
202
+ makeEnvelopeConfig (defaultChain , makeConfigPair ("foo" , "foo" , 1 , []byte ("foo" ))),
194
203
defaultInitializer (), nil )
195
204
196
205
if err != nil {
@@ -213,7 +222,7 @@ func TestConfigChangeRegressedSequence(t *testing.T) {
213
222
// config values while advancing another
214
223
func TestConfigChangeOldSequence (t * testing.T ) {
215
224
cm , err := NewManagerImpl (
216
- makeConfigEnvelope (defaultChain , makeConfigPair ("foo" , "foo" , 1 , []byte ("foo" ))),
225
+ makeEnvelopeConfig (defaultChain , makeConfigPair ("foo" , "foo" , 1 , []byte ("foo" ))),
217
226
defaultInitializer (), nil )
218
227
219
228
if err != nil {
@@ -236,7 +245,7 @@ func TestConfigChangeOldSequence(t *testing.T) {
236
245
// by omitting them in the new config
237
246
func TestConfigImplicitDelete (t * testing.T ) {
238
247
cm , err := NewManagerImpl (
239
- makeConfigEnvelope (
248
+ makeEnvelopeConfig (
240
249
defaultChain ,
241
250
makeConfigPair ("foo" , "foo" , 0 , []byte ("foo" )),
242
251
makeConfigPair ("bar" , "bar" , 0 , []byte ("bar" )),
@@ -261,7 +270,7 @@ func TestConfigImplicitDelete(t *testing.T) {
261
270
// TestEmptyConfigUpdate tests to make sure that an empty config is rejected as an update
262
271
func TestEmptyConfigUpdate (t * testing.T ) {
263
272
cm , err := NewManagerImpl (
264
- makeConfigEnvelope (defaultChain , makeConfigPair ("foo" , "foo" , 0 , []byte ("foo" ))),
273
+ makeEnvelopeConfig (defaultChain , makeConfigPair ("foo" , "foo" , 0 , []byte ("foo" ))),
265
274
defaultInitializer (), nil )
266
275
267
276
if err != nil {
@@ -281,7 +290,7 @@ func TestEmptyConfigUpdate(t *testing.T) {
281
290
// increasing the config item's LastModified
282
291
func TestSilentConfigModification (t * testing.T ) {
283
292
cm , err := NewManagerImpl (
284
- makeConfigEnvelope (
293
+ makeEnvelopeConfig (
285
294
defaultChain ,
286
295
makeConfigPair ("foo" , "foo" , 0 , []byte ("foo" )),
287
296
makeConfigPair ("bar" , "bar" , 0 , []byte ("bar" )),
@@ -309,7 +318,7 @@ func TestSilentConfigModification(t *testing.T) {
309
318
func TestConfigChangeViolatesPolicy (t * testing.T ) {
310
319
initializer := defaultInitializer ()
311
320
cm , err := NewManagerImpl (
312
- makeConfigEnvelope (defaultChain , makeConfigPair ("foo" , "foo" , 0 , []byte ("foo" ))),
321
+ makeEnvelopeConfig (defaultChain , makeConfigPair ("foo" , "foo" , 0 , []byte ("foo" ))),
313
322
initializer , nil )
314
323
315
324
if err != nil {
@@ -331,7 +340,7 @@ func TestConfigChangeViolatesPolicy(t *testing.T) {
331
340
func TestUnchangedConfigViolatesPolicy (t * testing.T ) {
332
341
initializer := defaultInitializer ()
333
342
cm , err := NewManagerImpl (
334
- makeConfigEnvelope (defaultChain , makeConfigPair ("foo" , "foo" , 0 , []byte ("foo" ))),
343
+ makeEnvelopeConfig (defaultChain , makeConfigPair ("foo" , "foo" , 0 , []byte ("foo" ))),
335
344
initializer , nil )
336
345
337
346
if err != nil {
@@ -369,7 +378,7 @@ func TestUnchangedConfigViolatesPolicy(t *testing.T) {
369
378
func TestInvalidProposal (t * testing.T ) {
370
379
initializer := defaultInitializer ()
371
380
cm , err := NewManagerImpl (
372
- makeConfigEnvelope (defaultChain , makeConfigPair ("foo" , "foo" , 0 , []byte ("foo" ))),
381
+ makeEnvelopeConfig (defaultChain , makeConfigPair ("foo" , "foo" , 0 , []byte ("foo" ))),
373
382
initializer , nil )
374
383
375
384
if err != nil {
@@ -391,7 +400,7 @@ func TestMissingHeader(t *testing.T) {
391
400
group := cb .NewConfigGroup ()
392
401
group .Values ["foo" ] = & cb.ConfigValue {}
393
402
_ , err := NewManagerImpl (
394
- & cb.ConfigEnvelope {Config : & cb.Config {Channel : group }},
403
+ & cb.Envelope { Payload : utils . MarshalOrPanic ( & cb. Payload { Data : utils . MarshalOrPanic ( & cb. ConfigEnvelope {Config : & cb.Config {ChannelGroup : group }})}) },
395
404
defaultInitializer (), nil )
396
405
397
406
if err == nil {
@@ -402,7 +411,7 @@ func TestMissingHeader(t *testing.T) {
402
411
// TestMissingChainID checks that a config item with a missing chainID causes the config to be rejected
403
412
func TestMissingChainID (t * testing.T ) {
404
413
_ , err := NewManagerImpl (
405
- makeConfigEnvelope ("" , makeConfigPair ("foo" , "foo" , 0 , []byte ("foo" ))),
414
+ makeEnvelopeConfig ("" , makeConfigPair ("foo" , "foo" , 0 , []byte ("foo" ))),
406
415
defaultInitializer (), nil )
407
416
408
417
if err == nil {
0 commit comments