From afc0224cdbe73e326addf5fb98a3e95d941f2104 Mon Sep 17 00:00:00 2001 From: stickies-v Date: Fri, 23 Jun 2023 11:02:59 +0100 Subject: test: refactor: remove unnecessary blocks_checked counter Since we already store all the blocks in `events`, keeping an additional counter is redundant. --- test/functional/interface_usdt_validation.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'test/functional/interface_usdt_validation.py') diff --git a/test/functional/interface_usdt_validation.py b/test/functional/interface_usdt_validation.py index f9d9b525cd..f32d83a50c 100755 --- a/test/functional/interface_usdt_validation.py +++ b/test/functional/interface_usdt_validation.py @@ -86,7 +86,6 @@ class ValidationTracepointTest(BitcoinTestFramework): self.duration) BLOCKS_EXPECTED = 2 - blocks_checked = 0 expected_blocks = dict() events = [] @@ -98,11 +97,10 @@ class ValidationTracepointTest(BitcoinTestFramework): usdt_contexts=[ctx], debug=0) def handle_blockconnected(_, data, __): - nonlocal events, blocks_checked + nonlocal events event = ctypes.cast(data, ctypes.POINTER(Block)).contents self.log.info(f"handle_blockconnected(): {event}") events.append(event) - blocks_checked += 1 bpf["block_connected"].open_perf_buffer( handle_blockconnected) @@ -127,7 +125,7 @@ class ValidationTracepointTest(BitcoinTestFramework): # only plausibility checks assert event.duration > 0 del expected_blocks[block_hash] - assert_equal(BLOCKS_EXPECTED, blocks_checked) + assert_equal(BLOCKS_EXPECTED, len(events)) assert_equal(0, len(expected_blocks)) bpf.cleanup() -- cgit v1.2.3 From bc432704505eb165dd86de39ea3434c6fb7a2514 Mon Sep 17 00:00:00 2001 From: stickies-v Date: Fri, 23 Jun 2023 12:01:12 +0100 Subject: test: refactor: remove unnecessary nonlocal Since we're only mutating, and not reassigning, we don't need to declare `events` as `nonlocal`. --- test/functional/interface_usdt_validation.py | 1 - 1 file changed, 1 deletion(-) (limited to 'test/functional/interface_usdt_validation.py') diff --git a/test/functional/interface_usdt_validation.py b/test/functional/interface_usdt_validation.py index f32d83a50c..e29b2c46eb 100755 --- a/test/functional/interface_usdt_validation.py +++ b/test/functional/interface_usdt_validation.py @@ -97,7 +97,6 @@ class ValidationTracepointTest(BitcoinTestFramework): usdt_contexts=[ctx], debug=0) def handle_blockconnected(_, data, __): - nonlocal events event = ctypes.cast(data, ctypes.POINTER(Block)).contents self.log.info(f"handle_blockconnected(): {event}") events.append(event) -- cgit v1.2.3