@@ -389,17 +389,32 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) {
389
389
doActions func (sdk.Context , providerkeeper.Keeper )
390
390
}{
391
391
/*
392
- 0. Consumer registered: Assign PK0->CK0 and retrieve PK0->CK0
393
- 1. Consumer registered: Assign PK0->CK0, PK0->CK1 and retrieve PK0->CK1
394
- 2. Consumer registered: Assign PK0->CK0, PK1->CK0 and error
395
- 3. Consumer registered: Assign PK1->PK0 and error
396
- 4. Consumer not registered: Assign PK0->CK0 and retrieve PK0->CK0
397
- 5. Consumer not registered: Assign PK0->CK0, PK0->CK1 and retrieve PK0->CK1
398
- 6. Consumer not registered: Assign PK0->CK0, PK1->CK0 and error
399
- 7. Consumer not registered: Assign PK1->PK0 and error
392
+ 0. Consumer not registered: Assign PK0->CK0 and error
393
+ 1. Consumer registered: Assign PK0->CK0 and retrieve PK0->CK0
394
+ 2. Consumer registered: Assign PK0->CK0, PK0->CK1 and retrieve PK0->CK1
395
+ 3. Consumer registered: Assign PK0->CK0, PK1->CK0 and error
396
+ 4. Consumer registered: Assign PK1->PK0 and error
397
+ 5. Consumer proposed: Assign Assign PK0->CK0 and retrieve PK0->CK0
398
+ 6. Consumer proposed: Assign PK0->CK0, PK0->CK1 and retrieve PK0->CK1
399
+ 7. Consumer proposed: Assign PK0->CK0, PK1->CK0 and error
400
+ 8. Consumer proposed: Assign PK1->PK0 and error
400
401
*/
401
402
{
402
- name : "0" ,
403
+ name : "0" ,
404
+ mockSetup : func (ctx sdk.Context , k providerkeeper.Keeper , mocks testkeeper.MockedKeepers ) {},
405
+ doActions : func (ctx sdk.Context , k providerkeeper.Keeper ) {
406
+ err := k .AssignConsumerKey (ctx , chainID ,
407
+ providerIdentities [0 ].SDKStakingValidator (),
408
+ consumerIdentities [0 ].TMProtoCryptoPublicKey (),
409
+ )
410
+ require .Error (t , err )
411
+ _ , found := k .GetValidatorByConsumerAddr (ctx , chainID ,
412
+ consumerIdentities [0 ].ConsumerConsAddress ())
413
+ require .False (t , found )
414
+ },
415
+ },
416
+ {
417
+ name : "1" ,
403
418
mockSetup : func (ctx sdk.Context , k providerkeeper.Keeper , mocks testkeeper.MockedKeepers ) {
404
419
gomock .InOrder (
405
420
mocks .MockStakingKeeper .EXPECT ().GetValidatorByConsAddr (ctx ,
@@ -424,7 +439,7 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) {
424
439
},
425
440
},
426
441
{
427
- name : "1 " ,
442
+ name : "2 " ,
428
443
mockSetup : func (ctx sdk.Context , k providerkeeper.Keeper , mocks testkeeper.MockedKeepers ) {
429
444
gomock .InOrder (
430
445
mocks .MockStakingKeeper .EXPECT ().GetValidatorByConsAddr (ctx ,
@@ -460,7 +475,7 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) {
460
475
},
461
476
},
462
477
{
463
- name : "2 " ,
478
+ name : "3 " ,
464
479
mockSetup : func (ctx sdk.Context , k providerkeeper.Keeper , mocks testkeeper.MockedKeepers ) {
465
480
gomock .InOrder (
466
481
mocks .MockStakingKeeper .EXPECT ().GetValidatorByConsAddr (ctx ,
@@ -493,7 +508,7 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) {
493
508
},
494
509
},
495
510
{
496
- name : "3 " ,
511
+ name : "4 " ,
497
512
mockSetup : func (ctx sdk.Context , k providerkeeper.Keeper , mocks testkeeper.MockedKeepers ) {
498
513
gomock .InOrder (
499
514
mocks .MockStakingKeeper .EXPECT ().GetValidatorByConsAddr (ctx ,
@@ -511,7 +526,7 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) {
511
526
},
512
527
},
513
528
{
514
- name : "4 " ,
529
+ name : "5 " ,
515
530
mockSetup : func (ctx sdk.Context , k providerkeeper.Keeper , mocks testkeeper.MockedKeepers ) {
516
531
gomock .InOrder (
517
532
mocks .MockStakingKeeper .EXPECT ().GetValidatorByConsAddr (ctx ,
@@ -520,6 +535,7 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) {
520
535
)
521
536
},
522
537
doActions : func (ctx sdk.Context , k providerkeeper.Keeper ) {
538
+ k .SetProposedConsumerChain (ctx , chainID , 0 )
523
539
err := k .AssignConsumerKey (ctx , chainID ,
524
540
providerIdentities [0 ].SDKStakingValidator (),
525
541
consumerIdentities [0 ].TMProtoCryptoPublicKey (),
@@ -532,7 +548,7 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) {
532
548
},
533
549
},
534
550
{
535
- name : "5 " ,
551
+ name : "6 " ,
536
552
mockSetup : func (ctx sdk.Context , k providerkeeper.Keeper , mocks testkeeper.MockedKeepers ) {
537
553
gomock .InOrder (
538
554
mocks .MockStakingKeeper .EXPECT ().GetValidatorByConsAddr (ctx ,
@@ -544,6 +560,7 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) {
544
560
)
545
561
},
546
562
doActions : func (ctx sdk.Context , k providerkeeper.Keeper ) {
563
+ k .SetProposedConsumerChain (ctx , chainID , 0 )
547
564
err := k .AssignConsumerKey (ctx , chainID ,
548
565
providerIdentities [0 ].SDKStakingValidator (),
549
566
consumerIdentities [0 ].TMProtoCryptoPublicKey (),
@@ -561,7 +578,7 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) {
561
578
},
562
579
},
563
580
{
564
- name : "6 " ,
581
+ name : "7 " ,
565
582
mockSetup : func (ctx sdk.Context , k providerkeeper.Keeper , mocks testkeeper.MockedKeepers ) {
566
583
gomock .InOrder (
567
584
mocks .MockStakingKeeper .EXPECT ().GetValidatorByConsAddr (ctx ,
@@ -573,6 +590,7 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) {
573
590
)
574
591
},
575
592
doActions : func (ctx sdk.Context , k providerkeeper.Keeper ) {
593
+ k .SetProposedConsumerChain (ctx , chainID , 0 )
576
594
err := k .AssignConsumerKey (ctx , chainID ,
577
595
providerIdentities [0 ].SDKStakingValidator (),
578
596
consumerIdentities [0 ].TMProtoCryptoPublicKey (),
@@ -590,7 +608,7 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) {
590
608
},
591
609
},
592
610
{
593
- name : "7 " ,
611
+ name : "8 " ,
594
612
mockSetup : func (ctx sdk.Context , k providerkeeper.Keeper , mocks testkeeper.MockedKeepers ) {
595
613
gomock .InOrder (
596
614
mocks .MockStakingKeeper .EXPECT ().GetValidatorByConsAddr (ctx ,
@@ -599,6 +617,7 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) {
599
617
)
600
618
},
601
619
doActions : func (ctx sdk.Context , k providerkeeper.Keeper ) {
620
+ k .SetProposedConsumerChain (ctx , chainID , 0 )
602
621
err := k .AssignConsumerKey (ctx , chainID ,
603
622
providerIdentities [1 ].SDKStakingValidator (),
604
623
providerIdentities [0 ].TMProtoCryptoPublicKey (),
0 commit comments