@@ -649,7 +649,7 @@ func TestMessageHandler_VerifyBlockJustification_WithEquivocatoryVotes(t *testin
649
649
650
650
round := uint64 (1 )
651
651
number := uint32 (1 )
652
- precommits := buildTestJustification (t , 20 , round , setID , kr , precommit )
652
+ precommits := buildTestJustification (t , 18 , round , setID , kr , precommit )
653
653
just := newJustification (round , testHash , number , precommits )
654
654
data , err := scale .Marshal (* just )
655
655
require .NoError (t , err )
@@ -788,13 +788,11 @@ func Test_getEquivocatoryVoters(t *testing.T) {
788
788
ed25519Keyring , err := keystore .NewEd25519Keyring ()
789
789
require .NoError (t , err )
790
790
fakeAuthorities := []* ed25519.Keypair {
791
- ed25519Keyring .Alice ().(* ed25519.Keypair ),
792
791
ed25519Keyring .Alice ().(* ed25519.Keypair ),
793
792
ed25519Keyring .Alice ().(* ed25519.Keypair ),
794
793
ed25519Keyring .Bob ().(* ed25519.Keypair ),
795
794
ed25519Keyring .Charlie ().(* ed25519.Keypair ),
796
795
ed25519Keyring .Charlie ().(* ed25519.Keypair ),
797
- ed25519Keyring .Charlie ().(* ed25519.Keypair ),
798
796
ed25519Keyring .Dave ().(* ed25519.Keypair ),
799
797
ed25519Keyring .Dave ().(* ed25519.Keypair ),
800
798
ed25519Keyring .Eve ().(* ed25519.Keypair ),
@@ -813,8 +811,17 @@ func Test_getEquivocatoryVoters(t *testing.T) {
813
811
}
814
812
}
815
813
816
- eqv := getEquivocatoryVoters (authData )
814
+ eqv , err := getEquivocatoryVoters (authData )
815
+ require .NoError (t , err )
817
816
require .Len (t , eqv , 5 )
817
+
818
+ // test that getEquivocatoryVoters returns an error if a voter has more than two equivocatory votes
819
+ authData = append (authData , AuthData {
820
+ AuthorityID : ed25519Keyring .Alice ().Public ().(* ed25519.PublicKey ).AsBytes (),
821
+ })
822
+
823
+ _ , err = getEquivocatoryVoters (authData )
824
+ require .ErrorIs (t , err , errInvalidMultiplicity )
818
825
}
819
826
820
827
func Test_VerifyCommitMessageJustification_ShouldRemoveEquivocatoryVotes (t * testing.T ) {
@@ -838,13 +845,11 @@ func Test_VerifyCommitMessageJustification_ShouldRemoveEquivocatoryVotes(t *test
838
845
ed25519Keyring , err := keystore .NewEd25519Keyring ()
839
846
require .NoError (t , err )
840
847
fakeAuthorities := []* ed25519.Keypair {
841
- ed25519Keyring .Alice ().(* ed25519.Keypair ),
842
848
ed25519Keyring .Alice ().(* ed25519.Keypair ),
843
849
ed25519Keyring .Alice ().(* ed25519.Keypair ),
844
850
ed25519Keyring .Bob ().(* ed25519.Keypair ),
845
851
ed25519Keyring .Charlie ().(* ed25519.Keypair ),
846
852
ed25519Keyring .Charlie ().(* ed25519.Keypair ),
847
- ed25519Keyring .Charlie ().(* ed25519.Keypair ),
848
853
ed25519Keyring .Dave ().(* ed25519.Keypair ),
849
854
ed25519Keyring .Dave ().(* ed25519.Keypair ),
850
855
ed25519Keyring .Eve ().(* ed25519.Keypair ),
@@ -989,13 +994,11 @@ func Test_VerifyPreCommitJustification(t *testing.T) {
989
994
// total of votes 4 legit + 3 equivocatory
990
995
// the threshold for testing is 9, so 2/3 of 9 = 6
991
996
fakeAuthorities := []* ed25519.Keypair {
992
- ed25519Keyring .Alice ().(* ed25519.Keypair ),
993
997
ed25519Keyring .Alice ().(* ed25519.Keypair ),
994
998
ed25519Keyring .Alice ().(* ed25519.Keypair ),
995
999
ed25519Keyring .Bob ().(* ed25519.Keypair ),
996
1000
ed25519Keyring .Charlie ().(* ed25519.Keypair ),
997
1001
ed25519Keyring .Charlie ().(* ed25519.Keypair ),
998
- ed25519Keyring .Charlie ().(* ed25519.Keypair ),
999
1002
ed25519Keyring .Dave ().(* ed25519.Keypair ),
1000
1003
ed25519Keyring .Dave ().(* ed25519.Keypair ),
1001
1004
ed25519Keyring .Eve ().(* ed25519.Keypair ),
0 commit comments