|
17 | 17 | from test_framework.messages import CBlockHeader, MAX_HEADERS_RESULTS, msg_headers, msg_version |
18 | 18 | from test_framework.p2p import P2PInterface |
19 | 19 | 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 |
21 | 21 |
|
22 | 22 | # Tor v3 addresses are 62 chars + 6 chars for the port (':12345'). |
23 | 23 | MAX_PEER_ADDR_LENGTH = 68 |
@@ -364,8 +364,8 @@ def handle_inbound_connection(_, data, __): |
364 | 364 |
|
365 | 365 | assert_equal(EXPECTED_INBOUND_CONNECTIONS, len(inbound_connections)) |
366 | 366 | 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) |
369 | 369 | assert_equal(b'inbound', inbound_connection.conn.conn_type) |
370 | 370 | assert_equal(NETWORK_TYPE_UNROUTABLE, inbound_connection.conn.network) |
371 | 371 |
|
@@ -405,8 +405,8 @@ def handle_outbound_connection(_, data, __): |
405 | 405 |
|
406 | 406 | assert_equal(EXPECTED_OUTBOUND_CONNECTIONS, len(outbound_connections)) |
407 | 407 | 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) |
410 | 410 | assert_equal(EXPECTED_CONNECTION_TYPE, outbound_connection.conn.conn_type.decode('utf-8')) |
411 | 411 | assert_equal(NETWORK_TYPE_UNROUTABLE, outbound_connection.conn.network) |
412 | 412 |
|
@@ -442,8 +442,8 @@ def handle_evicted_inbound_connection(_, data, __): |
442 | 442 |
|
443 | 443 | assert_equal(EXPECTED_EVICTED_CONNECTIONS, len(evicted_connections)) |
444 | 444 | 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) |
447 | 447 | assert_equal("inbound", evicted_connection.conn.conn_type.decode('utf-8')) |
448 | 448 | assert_equal(NETWORK_TYPE_UNROUTABLE, evicted_connection.conn.network) |
449 | 449 |
|
@@ -479,9 +479,9 @@ def handle_misbehaving_connection(_, data, __): |
479 | 479 |
|
480 | 480 | assert_equal(EXPECTED_MISBEHAVING_CONNECTIONS, len(misbehaving_connections)) |
481 | 481 | 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") |
485 | 485 |
|
486 | 486 | bpf.cleanup() |
487 | 487 |
|
@@ -516,10 +516,10 @@ def handle_closed_connection(_, data, __): |
516 | 516 |
|
517 | 517 | assert_equal(EXPECTED_CLOSED_CONNECTIONS, len(closed_connections)) |
518 | 518 | for closed_connection in closed_connections: |
519 | | - assert closed_connection.conn.id > 0 |
| 519 | + assert_greater_than(closed_connection.conn.id, 0) |
520 | 520 | assert_equal("inbound", closed_connection.conn.conn_type.decode('utf-8')) |
521 | 521 | assert_equal(0, closed_connection.conn.network) |
522 | | - assert closed_connection.time_established > 0 |
| 522 | + assert_greater_than(closed_connection.time_established, 0) |
523 | 523 |
|
524 | 524 | bpf.cleanup() |
525 | 525 |
|
|
0 commit comments