@@ -39,15 +39,19 @@ import (
39
39
"github.com/stretchr/testify/assert"
40
40
)
41
41
42
- var conf * genesisconfig.Profile
43
- var genesisBlock = cb . NewBlock ( 0 , nil ) // *cb.Block
42
+ var conf , singleMSPConf * genesisconfig.Profile
43
+ var genesisBlock , singleMSPGenesisBlock * cb.Block
44
44
var mockSigningIdentity msp.SigningIdentity
45
45
46
46
func init () {
47
47
conf = genesisconfig .Load (genesisconfig .SampleInsecureProfile )
48
48
logging .SetLevel (logging .DEBUG , "" )
49
49
genesisBlock = provisional .New (conf ).GenesisBlock ()
50
50
mockSigningIdentity , _ = mmsp .NewNoopMsp ().GetDefaultSigningIdentity ()
51
+
52
+ singleMSPConf = genesisconfig .Load (genesisconfig .SampleSingleMSPSoloProfile )
53
+ logging .SetLevel (logging .DEBUG , "" )
54
+ singleMSPGenesisBlock = provisional .New (singleMSPConf ).GenesisBlock ()
51
55
}
52
56
53
57
func mockCrypto () * mockCryptoHelper {
@@ -75,6 +79,20 @@ func NewRAMLedgerAndFactory(maxSize int) (ledger.Factory, ledger.ReadWriter) {
75
79
return rlf , rl
76
80
}
77
81
82
+ func NewRAMLedgerAndFactoryWithMSP () (ledger.Factory , ledger.ReadWriter ) {
83
+ rlf := ramledger .New (10 )
84
+
85
+ rl , err := rlf .GetOrCreate (provisional .TestChainID )
86
+ if err != nil {
87
+ panic (err )
88
+ }
89
+ err = rl .Append (singleMSPGenesisBlock )
90
+ if err != nil {
91
+ panic (err )
92
+ }
93
+ return rlf , rl
94
+ }
95
+
78
96
func NewRAMLedger (maxSize int ) ledger.ReadWriter {
79
97
_ , rl := NewRAMLedgerAndFactory (maxSize )
80
98
return rl
@@ -202,7 +220,7 @@ func TestManagerImpl(t *testing.T) {
202
220
203
221
func TestNewChannelConfig (t * testing.T ) {
204
222
205
- lf , _ := NewRAMLedgerAndFactory ( 3 )
223
+ lf , _ := NewRAMLedgerAndFactoryWithMSP ( )
206
224
207
225
consenters := make (map [string ]Consenter )
208
226
consenters [conf .Orderer .OrdererType ] = & mockConsenter {}
@@ -364,6 +382,65 @@ func TestNewChannelConfig(t *testing.T) {
364
382
},
365
383
"^Unknown consortium name:" ,
366
384
},
385
+ {
386
+ "Missing consortium members" ,
387
+ & cb.Payload {
388
+ Data : utils .MarshalOrPanic (& cb.ConfigUpdateEnvelope {
389
+ ConfigUpdate : utils .MarshalOrPanic (
390
+ & cb.ConfigUpdate {
391
+ WriteSet : & cb.ConfigGroup {
392
+ Groups : map [string ]* cb.ConfigGroup {
393
+ config .ApplicationGroupKey : & cb.ConfigGroup {
394
+ Version : 1 ,
395
+ },
396
+ },
397
+ Values : map [string ]* cb.ConfigValue {
398
+ config .ConsortiumKey : & cb.ConfigValue {
399
+ Value : utils .MarshalOrPanic (
400
+ & cb.Consortium {
401
+ Name : genesisconfig .SampleConsortiumName ,
402
+ },
403
+ ),
404
+ },
405
+ },
406
+ },
407
+ },
408
+ ),
409
+ }),
410
+ },
411
+ "Proposed configuration has no application group members, but consortium contains members" ,
412
+ },
413
+ {
414
+ "Member not in consortium" ,
415
+ & cb.Payload {
416
+ Data : utils .MarshalOrPanic (& cb.ConfigUpdateEnvelope {
417
+ ConfigUpdate : utils .MarshalOrPanic (
418
+ & cb.ConfigUpdate {
419
+ WriteSet : & cb.ConfigGroup {
420
+ Groups : map [string ]* cb.ConfigGroup {
421
+ config .ApplicationGroupKey : & cb.ConfigGroup {
422
+ Version : 1 ,
423
+ Groups : map [string ]* cb.ConfigGroup {
424
+ "BadOrgName" : & cb.ConfigGroup {},
425
+ },
426
+ },
427
+ },
428
+ Values : map [string ]* cb.ConfigValue {
429
+ config .ConsortiumKey : & cb.ConfigValue {
430
+ Value : utils .MarshalOrPanic (
431
+ & cb.Consortium {
432
+ Name : genesisconfig .SampleConsortiumName ,
433
+ },
434
+ ),
435
+ },
436
+ },
437
+ },
438
+ },
439
+ ),
440
+ }),
441
+ },
442
+ "Attempted to include a member which is not in the consortium" ,
443
+ },
367
444
} {
368
445
t .Run (tc .name , func (t * testing.T ) {
369
446
_ , err := manager .NewChannelConfig (& cb.Envelope {Payload : utils .MarshalOrPanic (tc .payload )})
0 commit comments