From 75564c82aca568e68164a2a773e48c7db1b35fbd Mon Sep 17 00:00:00 2001 From: Duke Date: Tue, 14 Oct 2025 04:16:15 -0400 Subject: [PATCH] Failing test for shielded donation --- qa/rpc-tests/shieldcoinbase_donation.py | 52 ++++++++++--------------- 1 file changed, 20 insertions(+), 32 deletions(-) diff --git a/qa/rpc-tests/shieldcoinbase_donation.py b/qa/rpc-tests/shieldcoinbase_donation.py index c755c14ee..dc77ef0c1 100755 --- a/qa/rpc-tests/shieldcoinbase_donation.py +++ b/qa/rpc-tests/shieldcoinbase_donation.py @@ -22,7 +22,7 @@ def assert_error(result): class ShieldCoinbaseDonationTest (BitcoinTestFramework): def setup_chain(self): print("Initializing test directory "+self.options.tmpdir) - self.num_nodes = 2 + self.num_nodes = 1 self.options.nocleanup = 1 # do not delete datadir after test run #self.options.nocleanup = 0 initialize_chain_clean(self.options.tmpdir, self.num_nodes) @@ -49,21 +49,6 @@ class ShieldCoinbaseDonationTest (BitcoinTestFramework): #'-zrpc', #'-zdebug', ##'-zrpcunsafe' - ],[ - '-ac_name=ZZZ', - '-conf='+self.options.tmpdir+'/node1/regtest/ZZZ.conf', - '-port=63357', - '-rpcport=63358', - '-ac_supply=' + str(self.supply), - '-ac_reward=100000000', - '-ac_private=1', - '-allowlist=127.0.0.1', - '-regtest', - '--daemon', - #'-debug', - #'-zrpc', - #'-zdebug', - ##'-zrpcunsafe' ]] ) self.is_network_split = False @@ -77,11 +62,9 @@ class ShieldCoinbaseDonationTest (BitcoinTestFramework): def run_test_default(self): rpc0 = self.nodes[0] - rpc1 = self.nodes[1] # mine initial ac_supply rpc0.generate(1) - rpc1.generate(1) self.sync_all() zaddr1 = rpc0.z_getnewaddress() @@ -113,27 +96,24 @@ class ShieldCoinbaseDonationTest (BitcoinTestFramework): def run_test_custom(self): rpc0 = self.nodes[0] - rpc1 = self.nodes[1] zaddr1 = rpc0.z_getnewaddress() # generate some new coinbase funds rpc0.generate(1) - rpc1.generate(1) self.sync_all() - # zregtestsapling1y30nwg0clsu6gcyrnvht8hdyfk3vwtszlh6kc4z5hv9hmpxzg2g0nx7c60xeecggm9x9gma96t4 + testing_zaddr = "zregtestsapling1y30nwg0clsu6gcyrnvht8hdyfk3vwtszlh6kc4z5hv9hmpxzg2g0nx7c60xeecggm9x9gma96t4" testing_privkey = "secret-extended-key-regtest1q0hgrms7qqqqpqrsz6myrtnh3ccp8uzp0kgxj6029wr6vq5hqvyccdlz7a745pgm5eeaamxqp9rxll2xctfrlw2l8xhxsc7zsut2tyz0374rrlk8srjswx7rhm6hcf2d7fuwajazvjesafduzxyka4w02tqjxdehzvghyrsd2zll90k3g2ckdvc5kqd6r7r7nglrtj0ej5a40d6lh8zxrvdlxrpuc59y5m8n9tekdxh4wpqn3smv5nxu4vvu58f8dgwn92qfqrvxqlscchtyh" - # import zaddr that receives donation to node1, no rescan - rpc1.z_importkey(testing_privkey, "no") + # import zaddr that receives donation , no rescan + rpc0.z_importkey(testing_privkey, "no") - rpc1.z_listaddresses() + rpc0.z_listaddresses() # now we test giving a donation parameter donation = 5 - # shield funds to a new zaddr in this node0 wallet, donation goes to - # node1 wallet + # shield funds to a new zaddr in this wallet response = rpc0.z_shieldcoinbase('*', zaddr1, 0, 1, donation) opid = response['opid'] print("opid=" + opid) @@ -145,25 +125,33 @@ class ShieldCoinbaseDonationTest (BitcoinTestFramework): time.sleep(2) # give some time for the ztx to complete rpc0.getinfo() - rpc1.getinfo() rpc0.generate(1) - rpc1.generate(1) self.sync_all() - # get the txid from node0 that created it + # get the txid json = rpc0.z_getoperationstatus() txid = json[0]['result']['txid'] print("txid=" + txid) - rpc1.z_listunspent() + rpc0.z_listunspent() expectedAmount = 5000000 # lookup txid on node1 which should have received donation - rawtx1 = rpc1.z_viewtransaction(txid) - assert_equal( rawtx1['outputs'][0]['valueZat'] , expectedAmount, '5% donation sends correct donationAmount') + 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 + else: + zout = 1 + + assert_equal( rawtx1['outputs'][zout]['address'] , testing_zaddr, 'correct zaddr gets donation') + assert_equal( rawtx1['outputs'][zout]['valueZat'] , expectedAmount, '5% donation sends correct donationAmount') if __name__ == '__main__': ShieldCoinbaseDonationTest().main() + + +