Skip to content

Commit

Permalink
Try to fix a few sporadic instant send failures in DIP3 tests (#2500)
Browse files Browse the repository at this point in the history
* Sleep in wait_for_instant_lock when TX is not known yet

We'll otherwise stress the CPU quite a lot, which might in turn result in
instant send timeouts.

* Wait for all nodes to have the instant send lock

Otherwise individual nodes might end up not being able to catch up,
especially when it's the last iteration and we generate 6 blocks after it.

* Use getrawtransaction in wait_for_instant_lock instead of gettransaction

gettransaction fails if the TX is not owned by the wallet

* Give instant send tests more time after DIP3 activation

Signature verification changes to BLS when DIP3 gets activated, which is
much more resource hungry. Give instant send tests more time after DIP3
activation until we do proper batched verification of instant send
signatures.
  • Loading branch information
codablock authored Nov 26, 2018
1 parent 7a709b8 commit c248c48
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions qa/rpc-tests/dip3-deterministicmns.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def run_test(self):
self.sync_all()

print("testing instant send with deterministic MNs")
self.test_instantsend(10, 5)
self.test_instantsend(10, 5, timeout=20)

print("testing ProUpServTx")
for mn in mns_protx:
Expand Down Expand Up @@ -339,7 +339,7 @@ def run_test(self):
self.sync_all()

print("testing instant send with replaced MNs")
self.test_instantsend(10, 3)
self.test_instantsend(10, 3, timeout=20)

def create_mn(self, node, idx, alias):
mn = Masternode()
Expand Down Expand Up @@ -558,7 +558,7 @@ def test_mn_votes(self, block_count, test_enforcement=False):
if test_enforcement:
self.nodes[0].spork('SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT', 4070908800)

def test_instantsend(self, tx_count, repeat):
def test_instantsend(self, tx_count, repeat, timeout=20):
self.nodes[0].spork('SPORK_2_INSTANTSEND_ENABLED', 0)
self.wait_for_sporks()

Expand Down Expand Up @@ -588,18 +588,21 @@ def test_instantsend(self, tx_count, repeat):
break
to_address = to_node.getnewaddress()
txid = from_node.instantsendtoaddress(to_address, 0.01)
self.wait_for_instant_lock(to_node, to_node_idx, txid)
for node in self.nodes:
if node is not None:
self.wait_for_instant_lock(node, to_node_idx, txid, timeout=timeout)
self.nodes[0].generate(6)
self.sync_all()

def wait_for_instant_lock(self, node, node_idx, txid, timeout=10):
st = time.time()
while time.time() < st + timeout:
try:
tx = node.gettransaction(txid)
tx = node.getrawtransaction(txid, 1)
except:
continue
tx = None
if tx is None:
time.sleep(0.5)
continue
if tx['instantlock']:
return
Expand Down

0 comments on commit c248c48

Please sign in to comment.