Fix dip4-coinbasemerkleroots.py race condition (#3297)

Sometimes the node we ask for mnlistdiff is so fast to reply that we receive the message back before we reset `last_mnlistdiff`. To fix this we should reset it before sending the message, not after.
This commit is contained in:
UdjinM6 2020-01-22 13:35:47 +03:00
parent a8213cadb9
commit 6b5d3edae3

View File

@ -24,13 +24,13 @@ class TestNode(NodeConnCB):
self.last_mnlistdiff = message self.last_mnlistdiff = message
def wait_for_mnlistdiff(self, timeout=30): def wait_for_mnlistdiff(self, timeout=30):
self.last_mnlistdiff = None
def received_mnlistdiff(): def received_mnlistdiff():
return self.last_mnlistdiff is not None return self.last_mnlistdiff is not None
return wait_until(received_mnlistdiff, timeout=timeout) return wait_until(received_mnlistdiff, timeout=timeout)
def getmnlistdiff(self, baseBlockHash, blockHash): def getmnlistdiff(self, baseBlockHash, blockHash):
msg = msg_getmnlistd(baseBlockHash, blockHash) msg = msg_getmnlistd(baseBlockHash, blockHash)
self.last_mnlistdiff = None
self.send_message(msg) self.send_message(msg)
self.wait_for_mnlistdiff() self.wait_for_mnlistdiff()
return self.last_mnlistdiff return self.last_mnlistdiff