Skip to content

Commit 387385b

Browse files
author
Chandra Pratap
committed
test: replace assert with assert_equal and assert_greater_than
In test/functional/interface_usdt_net.py, assert_equal is already used to check for equality between objects. Replace 'assert.*==' with 'assert_equal' and 'assert.*>' with 'assert_greater_than' to further easify debugging.
1 parent 257fd27 commit 387385b

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

test/functional/interface_usdt_net.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from test_framework.messages import CBlockHeader, MAX_HEADERS_RESULTS, msg_headers, msg_version
1818
from test_framework.p2p import P2PInterface
1919
from test_framework.test_framework import BitcoinTestFramework
20-
from test_framework.util import assert_equal
20+
from test_framework.util import assert_equal, assert_greater_than
2121

2222
# Tor v3 addresses are 62 chars + 6 chars for the port (':12345').
2323
MAX_PEER_ADDR_LENGTH = 68
@@ -364,8 +364,8 @@ def handle_inbound_connection(_, data, __):
364364

365365
assert_equal(EXPECTED_INBOUND_CONNECTIONS, len(inbound_connections))
366366
for inbound_connection in inbound_connections:
367-
assert inbound_connection.conn.id > 0
368-
assert inbound_connection.existing > 0
367+
assert_greater_than(inbound_connection.conn.id, 0)
368+
assert_greater_than(inbound_connection.existing, 0)
369369
assert_equal(b'inbound', inbound_connection.conn.conn_type)
370370
assert_equal(NETWORK_TYPE_UNROUTABLE, inbound_connection.conn.network)
371371

@@ -405,8 +405,8 @@ def handle_outbound_connection(_, data, __):
405405

406406
assert_equal(EXPECTED_OUTBOUND_CONNECTIONS, len(outbound_connections))
407407
for outbound_connection in outbound_connections:
408-
assert outbound_connection.conn.id > 0
409-
assert outbound_connection.existing > 0
408+
assert_greater_than(outbound_connection.conn.id, 0)
409+
assert_greater_than(outbound_connection.existing, 0)
410410
assert_equal(EXPECTED_CONNECTION_TYPE, outbound_connection.conn.conn_type.decode('utf-8'))
411411
assert_equal(NETWORK_TYPE_UNROUTABLE, outbound_connection.conn.network)
412412

@@ -442,8 +442,8 @@ def handle_evicted_inbound_connection(_, data, __):
442442

443443
assert_equal(EXPECTED_EVICTED_CONNECTIONS, len(evicted_connections))
444444
for evicted_connection in evicted_connections:
445-
assert evicted_connection.conn.id > 0
446-
assert evicted_connection.time_established > 0
445+
assert_greater_than(evicted_connection.conn.id, 0)
446+
assert_greater_than(evicted_connection.time_established, 0)
447447
assert_equal("inbound", evicted_connection.conn.conn_type.decode('utf-8'))
448448
assert_equal(NETWORK_TYPE_UNROUTABLE, evicted_connection.conn.network)
449449

@@ -479,9 +479,9 @@ def handle_misbehaving_connection(_, data, __):
479479

480480
assert_equal(EXPECTED_MISBEHAVING_CONNECTIONS, len(misbehaving_connections))
481481
for misbehaving_connection in misbehaving_connections:
482-
assert misbehaving_connection.id > 0
483-
assert len(misbehaving_connection.message) > 0
484-
assert misbehaving_connection.message == b"headers message size = 2001"
482+
assert_greater_than(misbehaving_connection.id, 0)
483+
assert_greater_than(len(misbehaving_connection.message), 0)
484+
assert_equal(misbehaving_connection.message, b"headers message size = 2001")
485485

486486
bpf.cleanup()
487487

@@ -516,10 +516,10 @@ def handle_closed_connection(_, data, __):
516516

517517
assert_equal(EXPECTED_CLOSED_CONNECTIONS, len(closed_connections))
518518
for closed_connection in closed_connections:
519-
assert closed_connection.conn.id > 0
519+
assert_greater_than(closed_connection.conn.id, 0)
520520
assert_equal("inbound", closed_connection.conn.conn_type.decode('utf-8'))
521521
assert_equal(0, closed_connection.conn.network)
522-
assert closed_connection.time_established > 0
522+
assert_greater_than(closed_connection.time_established, 0)
523523

524524
bpf.cleanup()
525525

0 commit comments

Comments
 (0)