A test for lockzins branch which currently fails on dev branch

This commit is contained in:
Duke
2025-08-13 01:13:10 -04:00
parent 5d31a77036
commit bd9dc4d190
2 changed files with 46 additions and 19 deletions

View File

@@ -7,7 +7,8 @@ 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
stop_nodes, sync_blocks, sync_mempools, wait_bitcoinds, rpc_port, assert_raises, assert_true, \
wait_and_assert_operationid_status
import time
from decimal import Decimal
@@ -38,11 +39,11 @@ class LockZinsTest (BitcoinTestFramework):
'-conf='+self.options.tmpdir+'/node0/regtest/ZZZ.conf',
'-port=64367',
'-rpcport=64368',
'-ac_supply=10',
'-ac_reward=25600000000',
'-ac_supply=1',
'-ac_reward=100000000',
'-ac_private=1',
'-allowlist=127.0.0.1',
'-debug',
#'-debug',
'-regtest',
'--daemon',
#'-rpcuser=hush',
@@ -57,22 +58,47 @@ class LockZinsTest (BitcoinTestFramework):
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)
# mine initial ac_supply
rpc.generate(1)
self.sync_all()
print(rpc.z_getbalances())
zaddr1 = rpc.z_getnewaddress()
zaddr2 = rpc.z_getnewaddress()
x = 0
while x < 15:
rpc.generate(1)
self.sync_all()
time.sleep(1)
rpc.z_shieldcoinbase('*', zaddr1, 0, 1)
x = x+1
rpc.generate(11)
self.sync_all()
rpc.z_listunspent()
rpc.z_getbalances()
recipients = []
recipients.append({"address": zaddr2, "amount": Decimal('3')})
# queue 4 ztxs, which will try to spend the same funds multiple times
# without correct locking of zins
opid1 = rpc.z_sendmany(zaddr1,recipients,1,0)
opid2 = rpc.z_sendmany(zaddr1,recipients,1,0)
opid3 = rpc.z_sendmany(zaddr1,recipients,1,0)
opid4 = rpc.z_sendmany(zaddr1,recipients,1,0)
rpc.generate(1)
self.sync_all()
wait_and_assert_operationid_status(self.nodes[0], opid1)
wait_and_assert_operationid_status(self.nodes[0], opid2)
wait_and_assert_operationid_status(self.nodes[0], opid3)
wait_and_assert_operationid_status(self.nodes[0], opid4)
# give time for all z_sendmany's to run
#time.sleep(10)
rpc.z_getoperationstatus()
if __name__ == '__main__':
LockZinsTest ().main()