@@ -33,6 +33,17 @@ func TestAuthority(t *testing.T) {
3333 st .SetBalance (p3 , big .NewInt (30 ))
3434
3535 aut := New (thor .BytesToAddress ([]byte ("aut" )), st )
36+
37+ checker := func (amount * big.Int ) BalanceChecker {
38+ return func (master , endorser thor.Address ) (bool , error ) {
39+ bal , err := st .GetBalance (endorser )
40+ if err != nil {
41+ return false , err
42+ }
43+ return bal .Cmp (amount ) >= 0 , nil
44+ }
45+ }
46+
3647 tests := []struct {
3748 ret any
3849 expected any
@@ -41,16 +52,16 @@ func TestAuthority(t *testing.T) {
4152 {M (aut .Get (p1 )), M (true , p1 , thor.Bytes32 {}, true , nil )},
4253 {M (aut .Add (p2 , p2 , thor.Bytes32 {})), M (true , nil )},
4354 {M (aut .Add (p3 , p3 , thor.Bytes32 {})), M (true , nil )},
44- {M (aut .Candidates (big .NewInt (10 ), thor .InitialMaxBlockProposers )), M (
55+ {M (aut .Candidates (checker ( big .NewInt (10 ) ), thor .InitialMaxBlockProposers )), M (
4556 []* Candidate {{p1 , p1 , thor.Bytes32 {}, true }, {p2 , p2 , thor.Bytes32 {}, true }, {p3 , p3 , thor.Bytes32 {}, true }}, nil ,
4657 )},
47- {M (aut .Candidates (big .NewInt (20 ), thor .InitialMaxBlockProposers )), M (
58+ {M (aut .Candidates (checker ( big .NewInt (20 ) ), thor .InitialMaxBlockProposers )), M (
4859 []* Candidate {{p2 , p2 , thor.Bytes32 {}, true }, {p3 , p3 , thor.Bytes32 {}, true }}, nil ,
4960 )},
50- {M (aut .Candidates (big .NewInt (30 ), thor .InitialMaxBlockProposers )), M (
61+ {M (aut .Candidates (checker ( big .NewInt (30 ) ), thor .InitialMaxBlockProposers )), M (
5162 []* Candidate {{p3 , p3 , thor.Bytes32 {}, true }}, nil ,
5263 )},
53- {M (aut .Candidates (big .NewInt (10 ), 2 )), M (
64+ {M (aut .Candidates (checker ( big .NewInt (10 ) ), 2 )), M (
5465 []* Candidate {{p1 , p1 , thor.Bytes32 {}, true }, {p2 , p2 , thor.Bytes32 {}, true }}, nil ,
5566 )},
5667 {M (aut .Get (p1 )), M (true , p1 , thor.Bytes32 {}, true , nil )},
@@ -60,7 +71,7 @@ func TestAuthority(t *testing.T) {
6071 {M (aut .Get (p1 )), M (true , p1 , thor.Bytes32 {}, true , nil )},
6172 {M (aut .Revoke (p1 )), M (true , nil )},
6273 {M (aut .Get (p1 )), M (false , p1 , thor.Bytes32 {}, false , nil )},
63- {M (aut .Candidates (& big.Int {}, thor .InitialMaxBlockProposers )), M (
74+ {M (aut .Candidates (checker ( & big.Int {}) , thor .InitialMaxBlockProposers )), M (
6475 []* Candidate {{p2 , p2 , thor.Bytes32 {}, true }, {p3 , p3 , thor.Bytes32 {}, true }}, nil ,
6576 )},
6677 {
0 commit comments