mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-26 17:02:00 +02:00
[move-only, test]: Match test order with run order
This commit is contained in:
parent
55b1ffcd25
commit
0672522aed
@ -69,6 +69,36 @@ class NetTest(BitcoinTestFramework):
|
|||||||
# After using `connect_nodes` to connect nodes 0 and 1 to each other.
|
# After using `connect_nodes` to connect nodes 0 and 1 to each other.
|
||||||
assert_equal(self.nodes[0].getconnectioncount(), 2)
|
assert_equal(self.nodes[0].getconnectioncount(), 2)
|
||||||
|
|
||||||
|
def test_getpeerinfo(self):
|
||||||
|
self.log.info("Test getpeerinfo")
|
||||||
|
# Create a few getpeerinfo last_block/last_transaction values.
|
||||||
|
if self.is_wallet_compiled():
|
||||||
|
self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 1)
|
||||||
|
self.nodes[1].generate(1)
|
||||||
|
self.sync_all()
|
||||||
|
time_now = int(time.time())
|
||||||
|
peer_info = [x.getpeerinfo() for x in self.nodes]
|
||||||
|
# Verify last_block and last_transaction keys/values.
|
||||||
|
for node, peer, field in product(range(self.num_nodes), range(2), ['last_block', 'last_transaction']):
|
||||||
|
assert field in peer_info[node][peer].keys()
|
||||||
|
if peer_info[node][peer][field] != 0:
|
||||||
|
assert_approx(peer_info[node][peer][field], time_now, vspan=60)
|
||||||
|
# check both sides of bidirectional connection between nodes
|
||||||
|
# the address bound to on one side will be the source address for the other node
|
||||||
|
assert_equal(peer_info[0][0]['addrbind'], peer_info[1][0]['addr'])
|
||||||
|
assert_equal(peer_info[1][0]['addrbind'], peer_info[0][0]['addr'])
|
||||||
|
assert_equal(peer_info[0][0]['minfeefilter'], Decimal("0.00000500"))
|
||||||
|
assert_equal(peer_info[1][0]['minfeefilter'], Decimal("0.00001000"))
|
||||||
|
# check the `servicesnames` field
|
||||||
|
for info in peer_info:
|
||||||
|
assert_net_servicesnames(int(info[0]["services"], 0x10), info[0]["servicesnames"])
|
||||||
|
|
||||||
|
assert_equal(peer_info[0][0]['connection_type'], 'inbound')
|
||||||
|
assert_equal(peer_info[0][1]['connection_type'], 'manual')
|
||||||
|
|
||||||
|
assert_equal(peer_info[1][0]['connection_type'], 'manual')
|
||||||
|
assert_equal(peer_info[1][1]['connection_type'], 'inbound')
|
||||||
|
|
||||||
def test_getnettotals(self):
|
def test_getnettotals(self):
|
||||||
self.log.info("Test getnettotals")
|
self.log.info("Test getnettotals")
|
||||||
# getnettotals totalbytesrecv and totalbytessent should be
|
# getnettotals totalbytesrecv and totalbytessent should be
|
||||||
@ -151,36 +181,6 @@ class NetTest(BitcoinTestFramework):
|
|||||||
# check that a non-existent node returns an error
|
# check that a non-existent node returns an error
|
||||||
assert_raises_rpc_error(-24, "Node has not been added", self.nodes[0].getaddednodeinfo, '1.1.1.1')
|
assert_raises_rpc_error(-24, "Node has not been added", self.nodes[0].getaddednodeinfo, '1.1.1.1')
|
||||||
|
|
||||||
def test_getpeerinfo(self):
|
|
||||||
self.log.info("Test getpeerinfo")
|
|
||||||
# Create a few getpeerinfo last_block/last_transaction values.
|
|
||||||
if self.is_wallet_compiled():
|
|
||||||
self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 1)
|
|
||||||
self.nodes[1].generate(1)
|
|
||||||
self.sync_all()
|
|
||||||
time_now = int(time.time())
|
|
||||||
peer_info = [x.getpeerinfo() for x in self.nodes]
|
|
||||||
# Verify last_block and last_transaction keys/values.
|
|
||||||
for node, peer, field in product(range(self.num_nodes), range(2), ['last_block', 'last_transaction']):
|
|
||||||
assert field in peer_info[node][peer].keys()
|
|
||||||
if peer_info[node][peer][field] != 0:
|
|
||||||
assert_approx(peer_info[node][peer][field], time_now, vspan=60)
|
|
||||||
# check both sides of bidirectional connection between nodes
|
|
||||||
# the address bound to on one side will be the source address for the other node
|
|
||||||
assert_equal(peer_info[0][0]['addrbind'], peer_info[1][0]['addr'])
|
|
||||||
assert_equal(peer_info[1][0]['addrbind'], peer_info[0][0]['addr'])
|
|
||||||
assert_equal(peer_info[0][0]['minfeefilter'], Decimal("0.00000500"))
|
|
||||||
assert_equal(peer_info[1][0]['minfeefilter'], Decimal("0.00001000"))
|
|
||||||
# check the `servicesnames` field
|
|
||||||
for info in peer_info:
|
|
||||||
assert_net_servicesnames(int(info[0]["services"], 0x10), info[0]["servicesnames"])
|
|
||||||
|
|
||||||
assert_equal(peer_info[0][0]['connection_type'], 'inbound')
|
|
||||||
assert_equal(peer_info[0][1]['connection_type'], 'manual')
|
|
||||||
|
|
||||||
assert_equal(peer_info[1][0]['connection_type'], 'manual')
|
|
||||||
assert_equal(peer_info[1][1]['connection_type'], 'inbound')
|
|
||||||
|
|
||||||
def test_service_flags(self):
|
def test_service_flags(self):
|
||||||
self.log.info("Test service flags")
|
self.log.info("Test service flags")
|
||||||
self.nodes[0].add_p2p_connection(P2PInterface(), services=(1 << 4) | (1 << 63))
|
self.nodes[0].add_p2p_connection(P2PInterface(), services=(1 << 4) | (1 << 63))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user