diff --git a/qa/zcash/smoke_tests.py b/qa/zcash/smoke_tests.py index 9298873a7..5d214b208 100755 --- a/qa/zcash/smoke_tests.py +++ b/qa/zcash/smoke_tests.py @@ -2,6 +2,12 @@ # # Execute the standard smoke tests for Zcash releases. # +# Usage: +# +# ZCASHD=./src/zcashd ZCASHCLI=./src/zcash-cli ./qa/zcash/smoke_tests.py --wallet=wallet.smoketest.dat "$HOME/.zcash" +# +# ZCASHD=./src/zcashd ZCASHCLI=./src/zcash-cli ./qa/zcash/smoke_tests.py --wallet=wallet.smoketest.dat "$HOME/.zcash" --automate --use-faucet +# import argparse import datetime @@ -36,49 +42,49 @@ SMOKE_TESTS = [ ('2a', True, True), # Run getinfo ('2b', True, True), # Run help # Address generation - ('3a', True, True), # Generate a Sprout z-addr - ('3b', True, True), # Generate multiple Sprout z-addrs + #('3a', True, True), # Generate a Sprout z-addr + #('3b', True, True), # Generate multiple Sprout z-addrs ('3c', True, True), # Generate a t-addr ('3d', True, True), # Generate multiple t-addrs ('3e', True, True), # Generate a Sapling z-addr ('3f', True, True), # Generate multiple Sapling z-addrs # Transactions - ('4a', True, True ), # Send funds from Sprout z-addr to same Sprout z-addr - ('4b', True, True ), # Send funds from Sprout z-addr to a different Sprout z-addr - ('4c', True, True ), # Send funds from Sprout z-addr to a t-addr - ('4d', False, False ), # Send funds from t-addr to Sprout z-addr(expected fail as of Canopy) + #('4a', True, True ), # Send funds from Sprout z-addr to same Sprout z-addr + #('4b', True, True ), # Send funds from Sprout z-addr to a different Sprout z-addr + #('4c', True, True ), # Send funds from Sprout z-addr to a t-addr + #('4d', False, False ), # Send funds from t-addr to Sprout z-addr(expected fail as of Canopy) ('4e', True, True ), # Send funds from t-addr to t-addr ('4f', True, True ), # Send funds from t-addr to Sapling z-addr ('4g', True, True ), # Send funds from Sapling z-addr to same Sapling z-addr ('4h', True, True ), # Send funds from Sapling z-addr to a different Sapling z-addr ('4i', True, True ), # Send funds from Sapling z-addr to a t-addr - ('4j', False, False), # Send funds from Sprout z-addr to Sapling z-addr - ('4k', True, True ), # Send funds from Sprout z-addr to multiple Sprout z-addrs - ('4l', True, True ), # Send funds from Sprout z-addr to multiple t-addrs - ('4m', True, True ), # Send funds from Sprout z-addr to t-addr and Sprout z-addrs - ('4n', False, False), # Send funds from Sprout z-addr to t-addr and Sapling z-addr - ('4o', False, False), # Send funds from Sprout z-addr to multiple Sapling z-addrs + #('4j', False, False), # Send funds from Sprout z-addr to Sapling z-addr + #('4k', True, True ), # Send funds from Sprout z-addr to multiple Sprout z-addrs + #('4l', True, True ), # Send funds from Sprout z-addr to multiple t-addrs + #('4m', True, True ), # Send funds from Sprout z-addr to t-addr and Sprout z-addrs + #('4n', False, False), # Send funds from Sprout z-addr to t-addr and Sapling z-addr + #('4o', False, False), # Send funds from Sprout z-addr to multiple Sapling z-addrs ('4p', True, True ), # Send funds from t-addr to multiple t-addrs - ('4q', False, False ), # Send funds from t-addr to multiple Sprout z-addrs(expected fail as of Canopy) + #('4q', False, False ), # Send funds from t-addr to multiple Sprout z-addrs(expected fail as of Canopy) ('4r', True, True ), # Send funds from t-addr to multiple Sapling z-addrs - ('4s', False, False), # Send funds from t-addr to Sprout z-addr and Sapling z-addr + #('4s', False, False), # Send funds from t-addr to Sprout z-addr and Sapling z-addr ('4t', True, True ), # Send funds from Sapling z-addr to multiple Sapling z-addrs - ('4u', False, False), # Send funds from Sapling z-addr to multiple Sprout z-addrs + #('4u', False, False), # Send funds from Sapling z-addr to multiple Sprout z-addrs ('4v', True, True ), # Send funds from Sapling z-addr to multiple t-addrs ('4w', True, True ), # Send funds from Sapling z-addr to t-addr and Sapling z-addr - ('4x', False, False), # Send funds from Sapling z-addr to Sapling z-addr and Sprout z-addr - ('4y', False, False ), # Send funds from t-addr to Sprout z-addr using z_mergetoaddress(expected fail as of Canopy) - ('4z', False, False ), # Send funds from 2 different t-addrs to Sprout z-addr using z_mergetoaddress(expected fail as of Canopy) - ('4aa', False, False), # Send funds from the same 2 t-addrs to Sprout z-addr using z_mergetoaddress + #('4x', False, False), # Send funds from Sapling z-addr to Sapling z-addr and Sprout z-addr + #('4y', False, False ), # Send funds from t-addr to Sprout z-addr using z_mergetoaddress(expected fail as of Canopy) + #('4z', False, False ), # Send funds from 2 different t-addrs to Sprout z-addr using z_mergetoaddress(expected fail as of Canopy) + #('4aa', False, False), # Send funds from the same 2 t-addrs to Sprout z-addr using z_mergetoaddress ('4bb', True, True ), # Send funds from 2 different t-addrs to Sapling z-addr using z_mergetoaddress ('4cc', True, True ), # Send funds from t-addr to Sapling z-addr using z_mergetoaddress - ('4dd', False, False ), # Send funds from t-addr and Sprout z-addr to Sprout z-addr using z_mergetoaddress(expected fail as of Canopy) + #('4dd', False, False ), # Send funds from t-addr and Sprout z-addr to Sprout z-addr using z_mergetoaddress(expected fail as of Canopy) ('4ee', True, True ), # Send funds from t-addr and Sapling z-addr to Sapling z-addr using z_mergetoaddress - ('4ff', True, True ), # Send funds from Sprout z-addr and Sprout z-addr to Sprout z-addr using z_mergetoaddress + #('4ff', True, True ), # Send funds from Sprout z-addr and Sprout z-addr to Sprout z-addr using z_mergetoaddress ('4gg', True, True ), # Send funds from Sapling z-addr and Sapling z-addr to Sapling z-addr using z_mergetoaddress # Wallet ('5a', True, True), # After generating multiple z-addrs, run z_listaddresses - ('5b', True, True), # Run z_validateaddress with a Sprout z-addr + #('5b', True, True), # Run z_validateaddress with a Sprout z-addr ('5c', True, True), # Run z_validateaddress with a Sapling z-addr ('5d', True, True), # After a transaction, run z_listunspent ('5e', True, True), # After a transaction, run z_listreceivedbyaddress @@ -166,6 +172,8 @@ def wait_for_balance(zcash, zaddr, expected=None): ttl = 300 def wait_and_check_balance(results, case, zcash, addr, expected): + #Wait for aysnc call to finish and persist completely to caller + time.sleep(5) balance = wait_for_balance(zcash, addr, expected) if balance != expected and results is not None and len(case) > 0: results[case] = False @@ -308,9 +316,6 @@ def transaction_chain(zcash): results = {} # Generate the various addresses we will use - sprout_zaddr_1 = run_cmd(results, '3a', zcash, 'z_getnewaddress', ['sprout']) - sprout_zaddr_2 = run_cmd(results, '3b', zcash, 'z_getnewaddress', ['sprout']) - sprout_zaddr_3 = run_cmd(results, '3b', zcash, 'z_getnewaddress', ['sprout']) taddr_1 = run_cmd(results, '3c', zcash, 'getnewaddress') taddr_2 = run_cmd(results, '3d', zcash, 'getnewaddress') taddr_3 = run_cmd(results, '3d', zcash, 'getnewaddress') @@ -322,17 +327,11 @@ def transaction_chain(zcash): # Check that the zaddrs are all listed zaddrs = run_cmd(results, '5a', zcash, 'z_listaddresses') - if (sprout_zaddr_1 not in zaddrs or - sprout_zaddr_2 not in zaddrs or - sapling_zaddr_1 not in zaddrs or + if ( sapling_zaddr_1 not in zaddrs or sapling_zaddr_2 not in zaddrs): results['5a'] = False # Validate the addresses - ret = run_cmd(results, '5b', zcash, 'z_validateaddress', [sprout_zaddr_1]) - if not ret['isvalid'] or ret['type'] != 'sprout': - results['5b'] = False - ret = run_cmd(results, '5c', zcash, 'z_validateaddress', [sapling_zaddr_1]) if not ret['isvalid'] or ret['type'] != 'sapling': results['5c'] = False @@ -345,7 +344,7 @@ def transaction_chain(zcash): if zcash.use_faucet: print('Tapping the testnet faucet for testing funds...') chain_end = get_zfaucet_taddr() - tap_zfaucet(sprout_zaddr_1) + tap_zfaucet(taddr_1) print('Done! Leftover funds will be sent back to the faucet.') else: chain_end = input('Type or paste transparent address where leftover funds should be sent: ') @@ -354,14 +353,14 @@ def transaction_chain(zcash): return results print() print('Please send at least 0.01 ZEC/TAZ to the following address:') - print(sprout_zaddr_1) + print(taddr_1) print() input('Press Enter once the funds have been sent.') print() # Wait to receive starting balance - sprout_balance = wait_for_balance(zcash, sprout_zaddr_1) - starting_balance = sprout_balance + taddr_balance = wait_for_balance(zcash, taddr_1) + starting_balance = taddr_balance # # Start the transaction chain! @@ -372,19 +371,6 @@ def transaction_chain(zcash): print('#') print() try: - # - # First, split the funds across all three pools - # - - # Sprout -> taddr - taddr_balance = check_z_sendmany( - results, '4c', zcash, sprout_zaddr_1, [(taddr_1, (starting_balance / Decimal('10')) * Decimal('6'))])[0] - sprout_balance -= taddr_balance + DEFAULT_FEE - - balance = Decimal(run_cmd(results, '5f', zcash, 'z_getbalance', [sprout_zaddr_1])).quantize(Decimal('1.00000000')) - if balance != sprout_balance: - results['5f'] = False - # taddr -> Sapling # Send it all here because z_sendmany pick a new t-addr for change sapling_balance = check_z_sendmany( @@ -400,30 +386,20 @@ def transaction_chain(zcash): # Intra-pool tests # - # Sprout -> same Sprout # Sapling -> same Sapling - (sprout_balance, sapling_balance) = check_z_sendmany_parallel(results, zcash, [ - ('4a', sprout_zaddr_1, [(sprout_zaddr_1, sprout_balance - DEFAULT_FEE)]), - ('4g', sapling_zaddr_1, [(sapling_zaddr_1, sapling_balance - DEFAULT_FEE)]), - ]) + sapling_balance = check_z_sendmany( + results, '4g',zcash, sapling_zaddr_1, [(sapling_zaddr_1, sapling_balance - DEFAULT_FEE)])[0] - # Sprout -> different Sprout # taddr -> different taddr # Sapling -> different Sapling - (sprout_balance, taddr_balance, sapling_balance) = check_z_sendmany_parallel(results, zcash, [ - ('4b', sprout_zaddr_1, [(sprout_zaddr_2, sprout_balance - DEFAULT_FEE)]), + (taddr_balance, sapling_balance) = check_z_sendmany_parallel(results, zcash, [ ('4e', taddr_1, [(taddr_2, taddr_balance - DEFAULT_FEE)]), ('4h', sapling_zaddr_1, [(sapling_zaddr_2, sapling_balance - DEFAULT_FEE)]), ]) - # Sprout -> multiple Sprout # taddr -> multiple taddr # Sapling -> multiple Sapling check_z_sendmany_parallel(results, zcash, [ - ('4k', sprout_zaddr_2, [ - (sprout_zaddr_1, starting_balance / Decimal('10')), - (sprout_zaddr_3, starting_balance / Decimal('10')), - ]), ('4p', taddr_2, [ (taddr_1, starting_balance / Decimal('10')), (taddr_3, taddr_balance - (starting_balance / Decimal('10')) - DEFAULT_FEE), @@ -433,195 +409,75 @@ def transaction_chain(zcash): (sapling_zaddr_3, starting_balance / Decimal('10')), ]), ]) - sprout_balance -= DEFAULT_FEE + taddr_balance -= DEFAULT_FEE sapling_balance -= DEFAULT_FEE - # multiple Sprout -> Sprout # multiple Sapling -> Sapling # multiple taddr -> taddr check_z_mergetoaddress_parallel(results, zcash, [ - ('4ff', [sprout_zaddr_1, sprout_zaddr_3], sprout_zaddr_2, sprout_balance - DEFAULT_FEE), ('4gg', [sapling_zaddr_1, sapling_zaddr_3], sapling_zaddr_2, sapling_balance - DEFAULT_FEE), ('', [taddr_1, taddr_3], taddr_2, taddr_balance - DEFAULT_FEE), ]) - sprout_balance -= DEFAULT_FEE sapling_balance -= DEFAULT_FEE taddr_balance -= DEFAULT_FEE - # - # Now test a bunch of failing cases - # - - # Sprout -> Sapling - txid = z_sendmany(results, '4j', zcash, sprout_zaddr_2, [(sapling_zaddr_1, sprout_balance - DEFAULT_FEE)]) - if txid is not None: - print('Should have failed') - return results - - # Sprout -> taddr and Sapling - txid = z_sendmany(results, '4n', zcash, sprout_zaddr_2, [ - (taddr_2, starting_balance / Decimal('10')), - (sapling_zaddr_1, starting_balance / Decimal('10')), - ]) - if txid is not None: - print('Should have failed') - return results - - # Sprout -> multiple Sapling - txid = z_sendmany(results, '4o', zcash, sprout_zaddr_2, [ - (sapling_zaddr_1, starting_balance / Decimal('10')), - (sapling_zaddr_2, starting_balance / Decimal('10')), - ]) - if txid is not None: - print('Should have failed') - return results - - # taddr -> Sprout and Sapling - txid = z_sendmany(results, '4s', zcash, taddr_2, [ - (sprout_zaddr_1, starting_balance / Decimal('10')), - (sapling_zaddr_1, starting_balance / Decimal('10')), - ]) - if txid is not None: - print('Should have failed') - return results - - # Sapling -> multiple Sprout - txid = z_sendmany(results, '4u', zcash, sapling_zaddr_2, [ - (sprout_zaddr_1, starting_balance / Decimal('10')), - (sprout_zaddr_2, starting_balance / Decimal('10')), - ]) - if txid is not None: - print('Should have failed') - return results - - # Sapling -> Sapling and Sprout - txid = z_sendmany(results, '4x', zcash, sapling_zaddr_2, [ - (sapling_zaddr_1, starting_balance / Decimal('10')), - (sprout_zaddr_1, starting_balance / Decimal('10')), - ]) - if txid is not None: - print('Should have failed') - return results - - # multiple same taddr -> Sprout - txid = z_mergetoaddress(results, '4aa', zcash, [taddr_2, taddr_2], sprout_zaddr_2) - if txid is not None: - print('Should have failed') - return results - # # Inter-pool tests # - # Sprout -> taddr and Sprout # Sapling -> taddr and Sapling - check_z_sendmany_parallel(results, zcash, [ - ('4m', sprout_zaddr_2, [ - (taddr_1, starting_balance / Decimal('10')), - (sprout_zaddr_1, starting_balance / Decimal('10')), - ]), - ('4w', sapling_zaddr_2, [ + check_z_sendmany( + results, '4w', zcash, sapling_zaddr_2,[ (taddr_3, starting_balance / Decimal('10')), - (sapling_zaddr_1, starting_balance / Decimal('10')), - ]), - ]) - sprout_balance -= (starting_balance / Decimal('10')) + DEFAULT_FEE + (sapling_zaddr_1, starting_balance / Decimal('10'))])[0] + sapling_balance -= (starting_balance / Decimal('10')) + DEFAULT_FEE + taddr_balance += starting_balance / Decimal('10') + + # taddr and Sapling -> Sapling + check_z_mergetoaddress(results, '4ee', zcash, [taddr_3, sapling_zaddr_1], sapling_zaddr_2, sapling_balance + (starting_balance / Decimal('10')) - DEFAULT_FEE) + + sapling_balance += (starting_balance / Decimal('10')) - DEFAULT_FEE + taddr_balance -= starting_balance / Decimal('10') + + # Sapling -> multiple taddr + check_z_sendmany(results, '4v', zcash, sapling_zaddr_2, [ + (taddr_4, (starting_balance / Decimal('10'))), + (taddr_5, (starting_balance / Decimal('10')))])[0] + + sapling_balance -= ((starting_balance / Decimal('10')) * Decimal('2')) + DEFAULT_FEE taddr_balance += (starting_balance / Decimal('10')) * Decimal('2') - # taddr and Sprout -> Sprout - # taddr and Sapling -> Sapling - check_z_mergetoaddress_parallel(results, zcash, [ - ('4dd', [taddr_1, sprout_zaddr_1], sprout_zaddr_2, sprout_balance + (starting_balance / Decimal('10')) - DEFAULT_FEE), - ('4ee', [taddr_3, sapling_zaddr_1], sapling_zaddr_2, sapling_balance + (starting_balance / Decimal('10')) - DEFAULT_FEE), - ]) - sprout_balance += (starting_balance / Decimal('10')) - DEFAULT_FEE - sapling_balance += (starting_balance / Decimal('10')) - DEFAULT_FEE + # multiple taddr -> Sapling + check_z_mergetoaddress(results, '4bb',zcash, [taddr_4, taddr_5], sapling_zaddr_2, sapling_balance + ((starting_balance / Decimal('10')) * Decimal('2')) - DEFAULT_FEE) + sapling_balance += ((starting_balance / Decimal('10')) * Decimal('2')) - DEFAULT_FEE taddr_balance -= (starting_balance / Decimal('10')) * Decimal('2') - # Sprout -> multiple taddr - # Sapling -> multiple taddr - check_z_sendmany_parallel(results, zcash, [ - ('4l', sprout_zaddr_2, [ - (taddr_1, (starting_balance / Decimal('10'))), - (taddr_3, (starting_balance / Decimal('10'))), - ]), - ('4v', sapling_zaddr_2, [ - (taddr_4, (starting_balance / Decimal('10'))), - (taddr_5, (starting_balance / Decimal('10'))), - ]), - ]) - sprout_balance -= ((starting_balance / Decimal('10')) * Decimal('2')) + DEFAULT_FEE - sapling_balance -= ((starting_balance / Decimal('10')) * Decimal('2')) + DEFAULT_FEE - taddr_balance += (starting_balance / Decimal('10')) * Decimal('4') - - # multiple taddr -> Sprout - # multiple taddr -> Sapling - check_z_mergetoaddress_parallel(results, zcash, [ - ('4z', [taddr_1, taddr_3], sprout_zaddr_2, sprout_balance + ((starting_balance / Decimal('10')) * Decimal('2')) - DEFAULT_FEE), - ('4bb', [taddr_4, taddr_5], sapling_zaddr_2, sapling_balance + ((starting_balance / Decimal('10')) * Decimal('2')) - DEFAULT_FEE), - ]) - sprout_balance += ((starting_balance / Decimal('10')) * Decimal('2')) - DEFAULT_FEE - sapling_balance += ((starting_balance / Decimal('10')) * Decimal('2')) - DEFAULT_FEE - taddr_balance -= (starting_balance / Decimal('10')) * Decimal('4') - - # taddr -> Sprout - check_z_sendmany_parallel(results, zcash, [ - ('4d', taddr_2, [(sprout_zaddr_3, taddr_balance - DEFAULT_FEE)]), - ]) - sprout_balance += taddr_balance - DEFAULT_FEE - taddr_balance = Decimal('0') - - # multiple Sprout -> taddr # multiple Sapling -> taddr - check_z_mergetoaddress_parallel(None, zcash, [ - ('', [sprout_zaddr_1, sprout_zaddr_2, sprout_zaddr_3], taddr_1, sprout_balance - DEFAULT_FEE), - ('', [sapling_zaddr_1, sapling_zaddr_2, sapling_zaddr_3], taddr_2, sapling_balance - DEFAULT_FEE), - ]) - taddr_balance = sprout_balance + sapling_balance - (2 * DEFAULT_FEE) - sprout_balance = Decimal('0') + check_z_mergetoaddress(None, '', zcash, [sapling_zaddr_1, sapling_zaddr_2, sapling_zaddr_3], taddr_2, sapling_balance - DEFAULT_FEE) + taddr_balance += sapling_balance - DEFAULT_FEE sapling_balance = Decimal('0') - # taddr -> multiple Sprout # taddr -> multiple Sapling - taddr_1_balance = Decimal(zcash.z_getbalance(taddr_1)).quantize(Decimal('1.00000000')) taddr_2_balance = Decimal(zcash.z_getbalance(taddr_2)).quantize(Decimal('1.00000000')) - check_z_sendmany_parallel(results, zcash, [ - ('4q', taddr_1, [ - (sprout_zaddr_1, (starting_balance / Decimal('10'))), - (sprout_zaddr_2, taddr_1_balance - (starting_balance / Decimal('10')) - DEFAULT_FEE), - ]), - ('4r', taddr_2, [ + check_z_sendmany(results, '4r', zcash, taddr_2, [ (sapling_zaddr_1, (starting_balance / Decimal('10'))), - (sapling_zaddr_2, taddr_2_balance - (starting_balance / Decimal('10')) - DEFAULT_FEE), - ]), - ]) - sprout_balance = taddr_1_balance - DEFAULT_FEE - sapling_balance = taddr_2_balance - DEFAULT_FEE - taddr_balance = Decimal('0') + (sapling_zaddr_2, taddr_2_balance - (starting_balance / Decimal('10')) - DEFAULT_FEE)])[0] + + sapling_balance = taddr_2_balance - DEFAULT_FEE + taddr_balance -= taddr_2_balance - # multiple Sprout -> taddr # multiple Sapling -> taddr - check_z_mergetoaddress_parallel(None, zcash, [ - ('', [sprout_zaddr_1, sprout_zaddr_2], taddr_1, sprout_balance - DEFAULT_FEE), - ('', [sapling_zaddr_1, sapling_zaddr_2], taddr_2, sapling_balance - DEFAULT_FEE), - ]) - taddr_balance = sprout_balance + sapling_balance - (Decimal('2') * DEFAULT_FEE) - sprout_balance = Decimal('0') + check_z_mergetoaddress(None, '', zcash, [sapling_zaddr_1, sapling_zaddr_2], taddr_2, sapling_balance - DEFAULT_FEE) + taddr_balance += sapling_balance - DEFAULT_FEE sapling_balance = Decimal('0') - # z_mergetoaddress taddr -> Sprout # z_mergetoaddress taddr -> Sapling - taddr_1_balance = Decimal(zcash.z_getbalance(taddr_1)).quantize(Decimal('1.00000000')) taddr_2_balance = Decimal(zcash.z_getbalance(taddr_2)).quantize(Decimal('1.00000000')) - check_z_mergetoaddress_parallel(results, zcash, [ - ('4y', [taddr_1], sprout_zaddr_1, taddr_1_balance - DEFAULT_FEE), - ('4cc', [taddr_2], sapling_zaddr_1, taddr_2_balance - DEFAULT_FEE), - ]) - sprout_balance = taddr_1_balance - DEFAULT_FEE + check_z_mergetoaddress(results, '4cc', zcash, [taddr_2], sapling_zaddr_1, taddr_2_balance - DEFAULT_FEE) sapling_balance = taddr_2_balance - DEFAULT_FEE - taddr_balance = Decimal('0') + taddr_balance -= taddr_2_balance except Exception as e: print('Error: %s' % e) traceback.print_exc() @@ -634,7 +490,6 @@ def transaction_chain(zcash): print('# Finishing transaction chain') print('#') all_addrs = [ - sprout_zaddr_1, sprout_zaddr_2, sprout_zaddr_3, taddr_1, taddr_2, taddr_3, taddr_4, taddr_5, sapling_zaddr_1, sapling_zaddr_2, sapling_zaddr_3, ]