@@ -1584,8 +1584,11 @@ func TestVerifyChallengeTxThreshold_validServerAndClientKeyMeetingThreshold(t *t
1584
1584
Network : network .TestNetworkPassphrase ,
1585
1585
}
1586
1586
threshold := Threshold (1 )
1587
- signers := []Signer {
1588
- {Address : clientKP .Address (), Weight : 1 },
1587
+ signerSummary := SignerSummary {
1588
+ clientKP .Address (): 1 ,
1589
+ }
1590
+ wantSigners := []string {
1591
+ clientKP .Address (),
1589
1592
}
1590
1593
1591
1594
err := tx .Build ()
@@ -1594,8 +1597,8 @@ func TestVerifyChallengeTxThreshold_validServerAndClientKeyMeetingThreshold(t *t
1594
1597
assert .NoError (t , err )
1595
1598
tx64 , err := tx .Base64 ()
1596
1599
require .NoError (t , err )
1597
- signersFound , err := VerifyChallengeTxThreshold (tx64 , serverKP .Address (), network .TestNetworkPassphrase , threshold , signers )
1598
- assert .Equal (t , signers , signersFound )
1600
+ signersFound , err := VerifyChallengeTxThreshold (tx64 , serverKP .Address (), network .TestNetworkPassphrase , threshold , signerSummary )
1601
+ assert .Equal (t , wantSigners , signersFound )
1599
1602
assert .NoError (t , err )
1600
1603
}
1601
1604
@@ -1617,9 +1620,13 @@ func TestVerifyChallengeTxThreshold_validServerAndMultipleClientKeyMeetingThresh
1617
1620
Network : network .TestNetworkPassphrase ,
1618
1621
}
1619
1622
threshold := Threshold (3 )
1620
- signers := []Signer {
1621
- {Address : clientKP1 .Address (), Weight : 1 },
1622
- {Address : clientKP2 .Address (), Weight : 2 },
1623
+ signerSummary := map [string ]int32 {
1624
+ clientKP1 .Address (): 1 ,
1625
+ clientKP2 .Address (): 2 ,
1626
+ }
1627
+ wantSigners := []string {
1628
+ clientKP1 .Address (),
1629
+ clientKP2 .Address (),
1623
1630
}
1624
1631
1625
1632
err := tx .Build ()
@@ -1628,8 +1635,8 @@ func TestVerifyChallengeTxThreshold_validServerAndMultipleClientKeyMeetingThresh
1628
1635
assert .NoError (t , err )
1629
1636
tx64 , err := tx .Base64 ()
1630
1637
require .NoError (t , err )
1631
- signersFound , err := VerifyChallengeTxThreshold (tx64 , serverKP .Address (), network .TestNetworkPassphrase , threshold , signers )
1632
- assert .Equal (t , signers , signersFound )
1638
+ signersFound , err := VerifyChallengeTxThreshold (tx64 , serverKP .Address (), network .TestNetworkPassphrase , threshold , signerSummary )
1639
+ assert .Equal (t , wantSigners , signersFound )
1633
1640
assert .NoError (t , err )
1634
1641
}
1635
1642
@@ -1652,10 +1659,14 @@ func TestVerifyChallengeTxThreshold_validServerAndMultipleClientKeyMeetingThresh
1652
1659
Network : network .TestNetworkPassphrase ,
1653
1660
}
1654
1661
threshold := Threshold (3 )
1655
- signers := []Signer {
1656
- {Address : clientKP1 .Address (), Weight : 1 },
1657
- {Address : clientKP2 .Address (), Weight : 2 },
1658
- {Address : clientKP3 .Address (), Weight : 2 },
1662
+ signerSummary := SignerSummary {
1663
+ clientKP1 .Address (): 1 ,
1664
+ clientKP2 .Address (): 2 ,
1665
+ clientKP3 .Address (): 2 ,
1666
+ }
1667
+ wantSigners := []string {
1668
+ clientKP1 .Address (),
1669
+ clientKP2 .Address (),
1659
1670
}
1660
1671
1661
1672
err := tx .Build ()
@@ -1664,12 +1675,8 @@ func TestVerifyChallengeTxThreshold_validServerAndMultipleClientKeyMeetingThresh
1664
1675
assert .NoError (t , err )
1665
1676
tx64 , err := tx .Base64 ()
1666
1677
require .NoError (t , err )
1667
- signersFound , err := VerifyChallengeTxThreshold (tx64 , serverKP .Address (), network .TestNetworkPassphrase , threshold , signers )
1668
- wantSignersFound := []Signer {
1669
- {Address : clientKP1 .Address (), Weight : 1 },
1670
- {Address : clientKP2 .Address (), Weight : 2 },
1671
- }
1672
- assert .Equal (t , wantSignersFound , signersFound )
1678
+ signersFound , err := VerifyChallengeTxThreshold (tx64 , serverKP .Address (), network .TestNetworkPassphrase , threshold , signerSummary )
1679
+ assert .Equal (t , wantSigners , signersFound )
1673
1680
assert .NoError (t , err )
1674
1681
}
1675
1682
@@ -1692,10 +1699,10 @@ func TestVerifyChallengeTxThreshold_invalidServerAndMultipleClientKeyNotMeetingT
1692
1699
Network : network .TestNetworkPassphrase ,
1693
1700
}
1694
1701
threshold := Threshold (10 )
1695
- signers := [] Signer {
1696
- { Address : clientKP1 .Address (), Weight : 1 } ,
1697
- { Address : clientKP2 .Address (), Weight : 2 } ,
1698
- { Address : clientKP3 .Address (), Weight : 2 } ,
1702
+ signerSummary := SignerSummary {
1703
+ clientKP1 .Address (): 1 ,
1704
+ clientKP2 .Address (): 2 ,
1705
+ clientKP3 .Address (): 2 ,
1699
1706
}
1700
1707
1701
1708
err := tx .Build ()
@@ -1704,7 +1711,7 @@ func TestVerifyChallengeTxThreshold_invalidServerAndMultipleClientKeyNotMeetingT
1704
1711
assert .NoError (t , err )
1705
1712
tx64 , err := tx .Base64 ()
1706
1713
require .NoError (t , err )
1707
- _ , err = VerifyChallengeTxThreshold (tx64 , serverKP .Address (), network .TestNetworkPassphrase , threshold , signers )
1714
+ _ , err = VerifyChallengeTxThreshold (tx64 , serverKP .Address (), network .TestNetworkPassphrase , threshold , signerSummary )
1708
1715
assert .EqualError (t , err , "signers with weight 3 do not meet threshold 10" )
1709
1716
}
1710
1717
@@ -1727,9 +1734,9 @@ func TestVerifyChallengeTxThreshold_invalidClientKeyUnrecognized(t *testing.T) {
1727
1734
Network : network .TestNetworkPassphrase ,
1728
1735
}
1729
1736
threshold := Threshold (10 )
1730
- signers := [] Signer {
1731
- { Address : clientKP1 .Address (), Weight : 1 } ,
1732
- { Address : clientKP2 .Address (), Weight : 2 } ,
1737
+ signerSummary := map [ string ] int32 {
1738
+ clientKP1 .Address (): 1 ,
1739
+ clientKP2 .Address (): 2 ,
1733
1740
}
1734
1741
1735
1742
err := tx .Build ()
@@ -1738,7 +1745,7 @@ func TestVerifyChallengeTxThreshold_invalidClientKeyUnrecognized(t *testing.T) {
1738
1745
assert .NoError (t , err )
1739
1746
tx64 , err := tx .Base64 ()
1740
1747
require .NoError (t , err )
1741
- _ , err = VerifyChallengeTxThreshold (tx64 , serverKP .Address (), network .TestNetworkPassphrase , threshold , signers )
1748
+ _ , err = VerifyChallengeTxThreshold (tx64 , serverKP .Address (), network .TestNetworkPassphrase , threshold , signerSummary )
1742
1749
assert .EqualError (t , err , "transaction has unrecognized signatures" )
1743
1750
}
1744
1751
@@ -1761,15 +1768,15 @@ func TestVerifyChallengeTxThreshold_invalidNoSigners(t *testing.T) {
1761
1768
Network : network .TestNetworkPassphrase ,
1762
1769
}
1763
1770
threshold := Threshold (10 )
1764
- signers := [] Signer {}
1771
+ signerSummary := SignerSummary {}
1765
1772
1766
1773
err := tx .Build ()
1767
1774
require .NoError (t , err )
1768
1775
err = tx .Sign (serverKP , clientKP1 , clientKP2 , clientKP3 )
1769
1776
assert .NoError (t , err )
1770
1777
tx64 , err := tx .Base64 ()
1771
1778
require .NoError (t , err )
1772
- _ , err = VerifyChallengeTxThreshold (tx64 , serverKP .Address (), network .TestNetworkPassphrase , threshold , signers )
1779
+ _ , err = VerifyChallengeTxThreshold (tx64 , serverKP .Address (), network .TestNetworkPassphrase , threshold , signerSummary )
1773
1780
assert .EqualError (t , err , "no signers provided" )
1774
1781
}
1775
1782
0 commit comments