mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-10 05:03:26 +01:00
functional_tests: fix multisig tests noutputs assertion
The changes to the multisig tests in #8914 and #8904 affected each other, this PR cleans up the code and fixes that issue.
This commit is contained in:
parent
eac1b86bb2
commit
7dbb14b02a
@ -37,100 +37,61 @@ import random
|
|||||||
from framework.daemon import Daemon
|
from framework.daemon import Daemon
|
||||||
from framework.wallet import Wallet
|
from framework.wallet import Wallet
|
||||||
|
|
||||||
MULTISIG_PUB_ADDRS = [
|
TEST_CASES = \
|
||||||
'45J58b7PmKJFSiNPFFrTdtfMcFGnruP7V4CMuRpX7NsH4j3jGHKAjo3YJP2RePX6HMaSkbvTbrWUFhDNcNcHgtNmQ3gr7sG', # 2/2
|
[
|
||||||
'44G2TQNfsiURKkvxp7gbgaJY8WynZvANnhmyMAwv6WeEbAvyAWMfKXRhh3uBXT2UAKhAsUJ7Fg5zjjF2U1iGciFk5duN94i', # 2/3
|
# M N Primary Address
|
||||||
'41mro238grj56GnrWkakAKTkBy2yDcXYsUZ2iXCM9pe5Ueajd2RRc6Fhh3uBXT2UAKhAsUJ7Fg5zjjF2U1iGciFk5ief4ZP', # 3/3
|
[2, 2, '45J58b7PmKJFSiNPFFrTdtfMcFGnruP7V4CMuRpX7NsH4j3jGHKAjo3YJP2RePX6HMaSkbvTbrWUFhDNcNcHgtNmQ3gr7sG'],
|
||||||
'44vZSprQKJQRFe6t1VHgU4ESvq2dv7TjBLVGE7QscKxMdFSiyyPCEV64NnKUQssFPyWxc2meyt7j63F2S2qtCTRL6dakeff', # 3/4
|
[2, 3, '44G2TQNfsiURKkvxp7gbgaJY8WynZvANnhmyMAwv6WeEbAvyAWMfKXRhh3uBXT2UAKhAsUJ7Fg5zjjF2U1iGciFk5duN94i'],
|
||||||
'47puypSwsV1gvUDratmX4y58fSwikXVehEiBhVLxJA1gRCxHyrRgTDr4NnKUQssFPyWxc2meyt7j63F2S2qtCTRL6aRPj5U', # 2/4
|
[3, 3, '41mro238grj56GnrWkakAKTkBy2yDcXYsUZ2iXCM9pe5Ueajd2RRc6Fhh3uBXT2UAKhAsUJ7Fg5zjjF2U1iGciFk5ief4ZP'],
|
||||||
'4A8RnBQixry4VXkqeWhmg8L7vWJVDJj4FN9PV4E7Mgad5ZZ6LKQdn8dYJP2RePX6HMaSkbvTbrWUFhDNcNcHgtNmQ4S8RSB' # 1/2
|
[3, 4, '44vZSprQKJQRFe6t1VHgU4ESvq2dv7TjBLVGE7QscKxMdFSiyyPCEV64NnKUQssFPyWxc2meyt7j63F2S2qtCTRL6dakeff'],
|
||||||
|
[2, 4, '47puypSwsV1gvUDratmX4y58fSwikXVehEiBhVLxJA1gRCxHyrRgTDr4NnKUQssFPyWxc2meyt7j63F2S2qtCTRL6aRPj5U'],
|
||||||
|
[1, 2, '4A8RnBQixry4VXkqeWhmg8L7vWJVDJj4FN9PV4E7Mgad5ZZ6LKQdn8dYJP2RePX6HMaSkbvTbrWUFhDNcNcHgtNmQ4S8RSB']
|
||||||
]
|
]
|
||||||
|
|
||||||
|
PUB_ADDRS = [case[2] for case in TEST_CASES]
|
||||||
|
|
||||||
class MultisigTest():
|
class MultisigTest():
|
||||||
def run_test(self):
|
def run_test(self):
|
||||||
self.reset()
|
self.reset()
|
||||||
for pub_addr in MULTISIG_PUB_ADDRS:
|
for pub_addr in PUB_ADDRS:
|
||||||
self.mine(pub_addr, 4)
|
self.mine(pub_addr, 4)
|
||||||
self.mine('42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm', 80)
|
self.mine('42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm', 80)
|
||||||
|
|
||||||
self.test_states()
|
self.test_states()
|
||||||
|
|
||||||
self.fund_addrs_with_normal_wallet(MULTISIG_PUB_ADDRS)
|
self.fund_addrs_with_normal_wallet(PUB_ADDRS)
|
||||||
|
|
||||||
self.create_multisig_wallets(2, 2, '45J58b7PmKJFSiNPFFrTdtfMcFGnruP7V4CMuRpX7NsH4j3jGHKAjo3YJP2RePX6HMaSkbvTbrWUFhDNcNcHgtNmQ3gr7sG')
|
for M, N, pub_addr in TEST_CASES:
|
||||||
self.import_multisig_info([1, 0], 5)
|
assert M <= N
|
||||||
txid = self.transfer([1, 0])
|
shuffled_participants = list(range(N))
|
||||||
self.import_multisig_info([0, 1], 6)
|
random.shuffle(shuffled_participants)
|
||||||
self.check_transaction(txid)
|
shuffled_signers = shuffled_participants[:M]
|
||||||
|
|
||||||
self.remake_some_multisig_wallets_by_multsig_seed(2)
|
expected_outputs = 5 # each wallet owns four mined outputs & one transferred output
|
||||||
self.import_multisig_info([0, 1], 6) # six outputs, same as before
|
|
||||||
txid = self.transfer([0, 1])
|
|
||||||
self.import_multisig_info([0, 1], 7) # seven outputs b/c we're dest plus change
|
|
||||||
self.check_transaction(txid)
|
|
||||||
|
|
||||||
self.create_multisig_wallets(2, 3, '44G2TQNfsiURKkvxp7gbgaJY8WynZvANnhmyMAwv6WeEbAvyAWMfKXRhh3uBXT2UAKhAsUJ7Fg5zjjF2U1iGciFk5duN94i')
|
# Create multisig wallet and test transferring
|
||||||
self.import_multisig_info([0, 2], 5)
|
self.create_multisig_wallets(M, N, pub_addr)
|
||||||
txid = self.transfer([0, 2])
|
self.import_multisig_info(shuffled_signers if M != 1 else shuffled_participants, expected_outputs)
|
||||||
self.import_multisig_info([0, 1, 2], 6)
|
txid = self.transfer(shuffled_signers)
|
||||||
self.check_transaction(txid)
|
expected_outputs += 1
|
||||||
|
self.import_multisig_info(shuffled_participants, expected_outputs)
|
||||||
|
self.check_transaction(txid)
|
||||||
|
|
||||||
self.remake_some_multisig_wallets_by_multsig_seed(2)
|
# If more than 1 signer, try to freeze key image of one signer, make tx using that key
|
||||||
self.import_multisig_info([0, 2], 6) # six outputs, same as before
|
# image on another signer, then have first signer sign multisg_txset. Should fail
|
||||||
txid = self.transfer([0, 2])
|
if M != 1:
|
||||||
self.import_multisig_info([0, 1, 2], 7) # seven outputs b/c we're dest plus change
|
txid = self.try_transfer_frozen(shuffled_signers)
|
||||||
self.check_transaction(txid)
|
expected_outputs += 1
|
||||||
|
self.import_multisig_info(shuffled_participants, expected_outputs)
|
||||||
|
self.check_transaction(txid)
|
||||||
|
|
||||||
self.create_multisig_wallets(3, 3, '41mro238grj56GnrWkakAKTkBy2yDcXYsUZ2iXCM9pe5Ueajd2RRc6Fhh3uBXT2UAKhAsUJ7Fg5zjjF2U1iGciFk5ief4ZP')
|
# Recreate wallet from multisig seed and test transferring
|
||||||
self.import_multisig_info([2, 0, 1], 5)
|
self.remake_some_multisig_wallets_by_multsig_seed(M)
|
||||||
txid = self.transfer([2, 1, 0])
|
self.import_multisig_info(shuffled_signers if M != 1 else shuffled_participants, expected_outputs)
|
||||||
self.import_multisig_info([0, 2, 1], 6)
|
txid = self.transfer(shuffled_signers)
|
||||||
self.check_transaction(txid)
|
expected_outputs += 1
|
||||||
|
self.import_multisig_info(shuffled_participants, expected_outputs)
|
||||||
self.remake_some_multisig_wallets_by_multsig_seed(3)
|
self.check_transaction(txid)
|
||||||
self.import_multisig_info([2, 0, 1], 6) # six outputs, same as before
|
|
||||||
txid = self.transfer([2, 1, 0])
|
|
||||||
self.import_multisig_info([0, 2, 1], 7) # seven outputs b/c we're dest plus change
|
|
||||||
self.check_transaction(txid)
|
|
||||||
|
|
||||||
self.create_multisig_wallets(3, 4, '44vZSprQKJQRFe6t1VHgU4ESvq2dv7TjBLVGE7QscKxMdFSiyyPCEV64NnKUQssFPyWxc2meyt7j63F2S2qtCTRL6dakeff')
|
|
||||||
self.import_multisig_info([0, 2, 3], 5)
|
|
||||||
txid = self.transfer([0, 2, 3])
|
|
||||||
self.import_multisig_info([0, 1, 2, 3], 6)
|
|
||||||
self.check_transaction(txid)
|
|
||||||
|
|
||||||
self.remake_some_multisig_wallets_by_multsig_seed(3)
|
|
||||||
self.import_multisig_info([0, 2, 3], 6) # six outputs, same as before
|
|
||||||
txid = self.transfer([0, 2, 3])
|
|
||||||
self.import_multisig_info([0, 1, 2, 3], 7) # seven outputs b/c we're dest plus change
|
|
||||||
self.check_transaction(txid)
|
|
||||||
|
|
||||||
self.create_multisig_wallets(2, 4, '47puypSwsV1gvUDratmX4y58fSwikXVehEiBhVLxJA1gRCxHyrRgTDr4NnKUQssFPyWxc2meyt7j63F2S2qtCTRL6aRPj5U')
|
|
||||||
self.import_multisig_info([1, 2], 5)
|
|
||||||
txid = self.transfer([1, 2])
|
|
||||||
self.import_multisig_info([0, 1, 2, 3], 6)
|
|
||||||
self.check_transaction(txid)
|
|
||||||
txid = self.try_transfer_frozen([2, 3])
|
|
||||||
self.import_multisig_info([0, 1, 2, 3], 7)
|
|
||||||
self.check_transaction(txid)
|
|
||||||
|
|
||||||
self.remake_some_multisig_wallets_by_multsig_seed(2)
|
|
||||||
self.import_multisig_info([0, 1, 2, 3], 6) # six outputs, same as before
|
|
||||||
txid = self.transfer([2, 3])
|
|
||||||
self.import_multisig_info([0, 1, 2, 3], 7) # seven outputs b/c we're dest plus change
|
|
||||||
self.check_transaction(txid)
|
|
||||||
|
|
||||||
self.create_multisig_wallets(1, 2, '4A8RnBQixry4VXkqeWhmg8L7vWJVDJj4FN9PV4E7Mgad5ZZ6LKQdn8dYJP2RePX6HMaSkbvTbrWUFhDNcNcHgtNmQ4S8RSB')
|
|
||||||
self.import_multisig_info([0, 1], 5)
|
|
||||||
txid = self.transfer([0])
|
|
||||||
self.import_multisig_info([0, 1], 6)
|
|
||||||
self.check_transaction(txid)
|
|
||||||
|
|
||||||
self.remake_some_multisig_wallets_by_multsig_seed(1)
|
|
||||||
self.import_multisig_info([0, 1], 6) # six outputs, same as before
|
|
||||||
txid = self.transfer([1])
|
|
||||||
self.import_multisig_info([0, 1], 7) # seven outputs b/c we're dest plus change
|
|
||||||
self.check_transaction(txid)
|
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
print('Resetting blockchain')
|
print('Resetting blockchain')
|
||||||
@ -262,10 +223,10 @@ class MultisigTest():
|
|||||||
|
|
||||||
def remake_some_multisig_wallets_by_multsig_seed(self, threshold):
|
def remake_some_multisig_wallets_by_multsig_seed(self, threshold):
|
||||||
N = len(self.wallet)
|
N = len(self.wallet)
|
||||||
signers_to_remake = set()
|
|
||||||
num_signers_to_remake = random.randint(1, N) # Do at least one
|
num_signers_to_remake = random.randint(1, N) # Do at least one
|
||||||
while len(signers_to_remake) < num_signers_to_remake:
|
signers_to_remake = list(range(N))
|
||||||
signers_to_remake.add(random.randint(0, N - 1))
|
random.shuffle(signers_to_remake)
|
||||||
|
signers_to_remake = signers_to_remake[:num_signers_to_remake]
|
||||||
|
|
||||||
for i in signers_to_remake:
|
for i in signers_to_remake:
|
||||||
print("Remaking {}/{} multsig wallet from multisig seed: #{}".format(threshold, N, i+1))
|
print("Remaking {}/{} multsig wallet from multisig seed: #{}".format(threshold, N, i+1))
|
||||||
@ -501,7 +462,7 @@ class MultisigTest():
|
|||||||
print("Attemping to sign with frozen key image. This should fail")
|
print("Attemping to sign with frozen key image. This should fail")
|
||||||
try:
|
try:
|
||||||
res = self.wallet[signers[1]].sign_multisig(multisig_txset)
|
res = self.wallet[signers[1]].sign_multisig(multisig_txset)
|
||||||
raise ValueError('sign_multisig should not have succeeded w/ fronzen enotes')
|
raise ValueError('sign_multisig should not have succeeded w/ frozen enotes')
|
||||||
except AssertionError:
|
except AssertionError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user