Skip to content

Commit

Permalink
test: Fix intermittent issue in mining_getblocktemplate_longpoll.py
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoFalke committed Jun 23, 2023
1 parent 6a47337 commit fa748c6
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions test/functional/mining_getblocktemplate_longpoll.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ def run_test(self):

self.log.info("Test that longpoll waits if we do nothing")
thr = LongpollThread(self.nodes[0])
thr.start()
with self.nodes[0].assert_debug_log(["ThreadRPCServer method=getblocktemplate"], timeout=3):
thr.start()
# check that thread still lives
thr.join(5) # wait 5 seconds or until thread exits
assert thr.is_alive()
Expand All @@ -55,14 +56,16 @@ def run_test(self):

self.log.info("Test that longpoll will terminate if we generate a block ourselves")
thr = LongpollThread(self.nodes[0])
thr.start()
with self.nodes[0].assert_debug_log(["ThreadRPCServer method=getblocktemplate"], timeout=3):
thr.start()
self.generate(self.nodes[0], 1) # generate a block on own node
thr.join(5) # wait 5 seconds or until thread exits
assert not thr.is_alive()

self.log.info("Test that introducing a new transaction into the mempool will terminate the longpoll")
thr = LongpollThread(self.nodes[0])
thr.start()
with self.nodes[0].assert_debug_log(["ThreadRPCServer method=getblocktemplate"], timeout=3):
thr.start()
# generate a transaction and submit it
self.miniwallet.send_self_transfer(from_node=random.choice(self.nodes))
# after one minute, every 10 seconds the mempool is probed, so in 80 seconds it should have returned
Expand Down

0 comments on commit fa748c6

Please sign in to comment.