From 88696129f33b3958c7b14e995c64d6a09f438503 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Sat, 6 Aug 2022 13:52:29 +0200 Subject: [PATCH] merge bitcoin#25794: don't rely on block_connected USDT event order in tests --- test/functional/interface_usdt_validation.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/test/functional/interface_usdt_validation.py b/test/functional/interface_usdt_validation.py index c684e3c422..6c7b4fc927 100755 --- a/test/functional/interface_usdt_validation.py +++ b/test/functional/interface_usdt_validation.py @@ -91,7 +91,7 @@ class ValidationTracepointTest(BitcoinTestFramework): # that the handle_* functions succeeded. BLOCKS_EXPECTED = 2 blocks_checked = 0 - expected_blocks = list() + expected_blocks = dict() self.log.info("hook into the validation:block_connected tracepoint") ctx = USDT(path=str(self.options.bitcoind)) @@ -104,15 +104,16 @@ class ValidationTracepointTest(BitcoinTestFramework): nonlocal expected_blocks, blocks_checked event = ctypes.cast(data, ctypes.POINTER(Block)).contents self.log.info(f"handle_blockconnected(): {event}") - block = expected_blocks.pop(0) - assert_equal(block["hash"], bytes(event.hash[::-1]).hex()) + block_hash = bytes(event.hash[::-1]).hex() + block = expected_blocks[block_hash] + assert_equal(block["hash"], block_hash) assert_equal(block["height"], event.height) assert_equal(len(block["tx"]), event.transactions) assert_equal(len([tx["vin"] for tx in block["tx"]]), event.inputs) assert_equal(0, event.sigops) # no sigops in coinbase tx # only plausibility checks assert(event.duration > 0) - + del expected_blocks[block_hash] blocks_checked += 1 bpf["block_connected"].open_perf_buffer( @@ -122,7 +123,7 @@ class ValidationTracepointTest(BitcoinTestFramework): block_hashes = self.nodes[0].generatetoaddress( BLOCKS_EXPECTED, ADDRESS_BCRT1_UNSPENDABLE) for block_hash in block_hashes: - expected_blocks.append(self.nodes[0].getblock(block_hash, 2)) + expected_blocks[block_hash] = self.nodes[0].getblock(block_hash, 2) bpf.perf_buffer_poll(timeout=200) bpf.cleanup()