Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion test/functional/llmq-is-cl-conflicts.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from test_framework.blocktools import get_masternode_payment, create_coinbase, create_block
from test_framework.mininode import *
from test_framework.test_framework import DashTestFramework
from test_framework.util import sync_blocks, p2p_port, assert_raises_rpc_error, set_node_times
from test_framework.util import sync_blocks, sync_mempools, p2p_port, assert_raises_rpc_error, set_node_times

'''
llmq-is-cl-conflicts.py
Expand Down Expand Up @@ -102,6 +102,8 @@ def test_chainlock_overrides_islock(self, test_block_conflict):
rawtx4 = self.nodes[0].signrawtransaction(rawtx4)['hex']
rawtx4_txid = self.nodes[0].sendrawtransaction(rawtx4)

# wait for transactions to propagate
sync_mempools(self.nodes)
for node in self.nodes:
self.wait_for_instantlock(rawtx1_txid, node)
self.wait_for_instantlock(rawtx4_txid, node)
Expand Down Expand Up @@ -143,6 +145,8 @@ def test_chainlock_overrides_islock(self, test_block_conflict):
rawtx5 = self.nodes[0].createrawtransaction(inputs, {self.nodes[0].getnewaddress(): 0.999})
rawtx5 = self.nodes[0].signrawtransaction(rawtx5)['hex']
rawtx5_txid = self.nodes[0].sendrawtransaction(rawtx5)
# wait for the transaction to propagate
sync_mempools(self.nodes)
for node in self.nodes:
self.wait_for_instantlock(rawtx5_txid, node)

Expand Down
13 changes: 9 additions & 4 deletions test/functional/p2p-instantsend.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from test_framework.mininode import *
from test_framework.test_framework import DashTestFramework
from test_framework.util import isolate_node, set_node_times, reconnect_isolated_node, assert_equal, \
from test_framework.util import isolate_node, sync_mempools, set_node_times, reconnect_isolated_node, assert_equal, \
assert_raises_rpc_error

'''
Expand Down Expand Up @@ -50,9 +50,12 @@ def test_block_doublespend(self):
# instantsend to receiver
receiver_addr = receiver.getnewaddress()
is_id = sender.sendtoaddress(receiver_addr, 0.9)
for node in self.nodes:
if node is not isolated:
self.wait_for_instantlock(is_id, node)
# wait for the transaction to propagate
connected_nodes = self.nodes.copy()
del connected_nodes[self.isolated_idx]
sync_mempools(connected_nodes)
for node in connected_nodes:
self.wait_for_instantlock(is_id, node)
# send doublespend transaction to isolated node
isolated.sendrawtransaction(dblspnd_tx['hex'])
# generate block on isolated node with doublespend transaction
Expand Down Expand Up @@ -109,6 +112,8 @@ def test_mempool_doublespend(self):
# TX from other nodes.
receiver_addr = receiver.getnewaddress()
is_id = sender.sendtoaddress(receiver_addr, 0.9)
# wait for the transaction to propagate
sync_mempools(self.nodes)
for node in self.nodes:
self.wait_for_instantlock(is_id, node)
assert_raises_rpc_error(-5, "No such mempool or blockchain transaction", isolated.getrawtransaction, dblspnd_txid)
Expand Down
22 changes: 7 additions & 15 deletions test/functional/test_framework/test_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@
sync_blocks,
sync_mempools,
sync_masternodes,
wait_to_sync)
wait_to_sync,
wait_until,
)

class TestStatus(Enum):
PASSED = 1
Expand Down Expand Up @@ -687,22 +689,12 @@ def create_raw_tx(self, node_from, node_to, amount, min_inputs, max_inputs):
return ret

def wait_for_instantlock(self, txid, node):
# wait for instantsend locks
start = time.time()
locked = False
while True:
def check_instantlock():
try:
is_tx = node.getrawtransaction(txid, True)
if is_tx['instantlock']:
locked = True
break
return node.getrawtransaction(txid, True)["instantlock"]
except:
# TX not received yet?
pass
if time.time() > start + 10:
break
time.sleep(0.5)
return locked
return False
wait_until(check_instantlock, timeout=10, sleep=0.5)

def wait_for_sporks_same(self, timeout=30):
st = time.time()
Expand Down