diff --git a/qa/rpc-tests/shieldcoinbase_donation.py b/qa/rpc-tests/shieldcoinbase_donation.py index 010ed3548..53ae1356c 100755 --- a/qa/rpc-tests/shieldcoinbase_donation.py +++ b/qa/rpc-tests/shieldcoinbase_donation.py @@ -40,7 +40,7 @@ class ShieldCoinbaseDonationTest (BitcoinTestFramework): '-port=63367', '-rpcport=63368', '-ac_supply=' + str(self.supply), - '-ac_reward=100000000', + '-ac_reward=300000000', '-ac_private=1', '-allowlist=127.0.0.1', '-regtest', @@ -82,8 +82,10 @@ class ShieldCoinbaseDonationTest (BitcoinTestFramework): time.sleep(2) # give some time for the ztx to complete - # 555 supply plus magic utxo = 555.02070592 - totalSupply = 55502070592 # in puposhis + # 555 supply plus magic utxo = 555.05537304 + # NOTE: if any consensus params for this testcoin are changed above, + # the magic utxo will change and this value will need to be updated + totalSupply = 55505537304 # in puposhis expectedAmount = totalSupply json = rpc0.z_getoperationstatus() @@ -113,8 +115,9 @@ class ShieldCoinbaseDonationTest (BitcoinTestFramework): # now we test giving a donation parameter donation = 5 - # shield funds to a new zaddr in this wallet - response = rpc0.z_shieldcoinbase('*', zaddr1, 0, 1, donation) + # shield funds to a new zaddr in this wallet with default fee + fee = 0.0001 + response = rpc0.z_shieldcoinbase('*', zaddr1, fee, 1, donation) opid = response['opid'] print("opid=" + opid) #wait_and_assert_operationid_status(rpc0, opid) @@ -136,18 +139,31 @@ class ShieldCoinbaseDonationTest (BitcoinTestFramework): rpc0.z_listunspent() - expectedAmount = 5000000 + # (3 - fee)*0.05 + expectedAmount1 = 14999500 # lookup txid on node1 which should have received donation rawtx1 = rpc0.z_viewtransaction(txid) # there should be two outputs to different addresses, order is nondeterministic if rawtx1['outputs'][0]['address'] == testing_zaddr: - zout = 0 + donation_zout = 0 + other_zout = 1 else: - zout = 1 + donation_zout = 1 + other_zout = 0 - assert_equal( rawtx1['outputs'][zout]['address'] , testing_zaddr, 'correct zaddr gets donation') - assert_equal( rawtx1['outputs'][zout]['valueZat'] , expectedAmount, '5% donation sends correct donationAmount') + # print("donation_zout=%d other_zout=%d" % (donation_zout,other_zout) ) + + assert_equal( rawtx1['outputs'][donation_zout]['address'] , testing_zaddr, 'correct zaddr gets donation') + assert_equal( rawtx1['outputs'][donation_zout]['valueZat'] , expectedAmount1, '5% donation sends correct donationAmount') + + # (3 - fee)*0.95 + expectedAmount2 = 284990500 + assert_equal( rawtx1['outputs'][other_zout]['address'] , zaddr1, 'correct zaddr gets main amount') + assert_equal( rawtx1['outputs'][other_zout]['valueZat'] , expectedAmount2, '5% donation sends correct sendAmount') + + + assert_equal( expectedAmount1 + expectedAmount2, 299990000, 'sendAmount+donationAmount = targetAmount - fee' ) if __name__ == '__main__':