From 0f1894663013a5851b00673d2b295d1dd990eac5 Mon Sep 17 00:00:00 2001 From: Duke Date: Tue, 12 Aug 2025 23:30:06 -0400 Subject: [PATCH] Add lockzins test --- qa/rpc-tests/lockzins.py | 78 +++++++++++++++++++++++++++++ qa/rpc-tests/test_framework/util.py | 7 +-- test.sh | 5 +- 3 files changed, 86 insertions(+), 4 deletions(-) create mode 100755 qa/rpc-tests/lockzins.py diff --git a/qa/rpc-tests/lockzins.py b/qa/rpc-tests/lockzins.py new file mode 100755 index 000000000..6fe6cf4bd --- /dev/null +++ b/qa/rpc-tests/lockzins.py @@ -0,0 +1,78 @@ +#!/usr/bin/env python3 +# Copyright (c) 2016-2025 The Hush developers +# Distributed under the GPLv3 software license, see the accompanying +# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html + +from test_framework.test_framework import BitcoinTestFramework +from test_framework.authproxy import JSONRPCException +from test_framework.util import assert_equal, assert_greater_than, \ + initialize_chain_clean, initialize_chain, start_nodes, start_node, connect_nodes_bi, \ + stop_nodes, sync_blocks, sync_mempools, wait_bitcoinds, rpc_port, assert_raises, assert_true + +import time +from decimal import Decimal +from random import choice +from string import ascii_uppercase + +def assert_success(result): + assert_equal(result['result'], 'success') + +def assert_error(result): + assert_equal(result['result'], 'error') + +class LockZinsTest (BitcoinTestFramework): + def setup_chain(self): + print("Initializing test directory "+self.options.tmpdir) + self.num_nodes = 1 + self.options.nocleanup = 1 # do not delete datadir after test run + initialize_chain_clean(self.options.tmpdir, self.num_nodes) + + def setup_network(self, split = False): + print("Setting up network...") + self.nodes = start_nodes(self.num_nodes, self.options.tmpdir, + extra_args=[[ + # always give -ac_name as first extra_arg and port as third + '-ac_name=ZZZ', + #'-ac_algo=randomx', + #'-testnode=1', # why does this make the test node hang before run_test() ? + '-conf='+self.options.tmpdir+'/node0/regtest/ZZZ.conf', + '-port=64367', + '-rpcport=64368', + '-ac_supply=10', + '-ac_reward=25600000000', + '-ac_private=1', + '-allowlist=127.0.0.1', + '-debug', + '-regtest', + '--daemon', + #'-rpcuser=hush', + #'-rpcpassword=puppy' + ]] + ) + self.is_network_split = False + self.rpc = self.nodes[0] + self.sync_all() + print("Done setting up network") + + def run_test (self): + print("Mining blocks...") + rpc = self.nodes[0] + # mine the initial ac_supply + rpc.generate(5) + self.sync_all() + + zaddr = rpc.z_getnewaddress() + print("Created zaddr %s" % zaddr) + + rpc.getinfo() + time.sleep(1) + rpc.getinfo() + + rpc.z_shieldcoinbase('*', zaddr) + rpc.generate(1) + + self.sync_all() + print(rpc.z_getbalances()) + +if __name__ == '__main__': + LockZinsTest ().main() diff --git a/qa/rpc-tests/test_framework/util.py b/qa/rpc-tests/test_framework/util.py index 018f6722d..9e71a28f0 100644 --- a/qa/rpc-tests/test_framework/util.py +++ b/qa/rpc-tests/test_framework/util.py @@ -82,7 +82,6 @@ def sync_mempools(rpc_connections, wait=1): break time.sleep(wait) - return # Now that the mempools are in sync, wait for the internal # notifications to finish while True: @@ -238,13 +237,15 @@ def start_node(i, dirname, extra_args=None, rpchost=None, timewait=None, binary= port = extra_args[3] config.write("rpcport=" + (port[9:]) + "\n") config.write("server=1\n") + #config.write("testnode=1\n") config.write("txindex=1\n") config.write("rpcworkqueue=256\n") config.write("rpcallowip=127.0.0.1\n") config.write("bind=127.0.0.1\n") + #config.write("listenonion=0\n") + #config.write("torcontrol=127.0.0.1:9999\n") config.write("rpcbind=127.0.0.1\n") - - print("Done writing to %s" % configpath) + print("Done writing to %s" % configpath) if binary is None: binary = os.getenv("BITCOIND", "src/hushd") diff --git a/test.sh b/test.sh index b9d12c6ae..5d81d4850 100755 --- a/test.sh +++ b/test.sh @@ -1,4 +1,7 @@ #!/usr/bin/env bash #export PYTHON_DEBUG=1 -PYTHONPATH=./qa/rpc-tests/test_framework/ ./qa/rpc-tests/ac_private.py +export PYTHONPATH=./qa/rpc-tests/test_framework/ + +#./qa/rpc-tests/ac_private.py +./qa/rpc-tests/lockzins.py --tracerpc