mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-18 22:35:39 +01:00
test: replace inv type magic numbers by constants
This commit is contained in:
@@ -13,7 +13,7 @@ if uploadtarget has been reached.
|
||||
from collections import defaultdict
|
||||
import time
|
||||
|
||||
from test_framework.messages import CInv, msg_getdata
|
||||
from test_framework.messages import CInv, MSG_BLOCK, msg_getdata
|
||||
from test_framework.mininode import P2PInterface
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import assert_equal, mine_large_block
|
||||
@@ -84,7 +84,7 @@ class MaxUploadTest(BitcoinTestFramework):
|
||||
# the same big old block too many times (expect: disconnect)
|
||||
|
||||
getdata_request = msg_getdata()
|
||||
getdata_request.inv.append(CInv(2, big_old_block))
|
||||
getdata_request.inv.append(CInv(MSG_BLOCK, big_old_block))
|
||||
|
||||
max_bytes_per_day = 800*1024*1024
|
||||
daily_buffer = 144 * 4000000
|
||||
@@ -109,7 +109,7 @@ class MaxUploadTest(BitcoinTestFramework):
|
||||
# Requesting the current block on p2p_conns[1] should succeed indefinitely,
|
||||
# even when over the max upload target.
|
||||
# We'll try 800 times
|
||||
getdata_request.inv = [CInv(2, big_new_block)]
|
||||
getdata_request.inv = [CInv(MSG_BLOCK, big_new_block)]
|
||||
for i in range(800):
|
||||
p2p_conns[1].send_and_ping(getdata_request)
|
||||
assert_equal(p2p_conns[1].block_receive_map[big_new_block], i+1)
|
||||
@@ -117,7 +117,7 @@ class MaxUploadTest(BitcoinTestFramework):
|
||||
self.log.info("Peer 1 able to repeatedly download new block")
|
||||
|
||||
# But if p2p_conns[1] tries for an old block, it gets disconnected too.
|
||||
getdata_request.inv = [CInv(2, big_old_block)]
|
||||
getdata_request.inv = [CInv(MSG_BLOCK, big_old_block)]
|
||||
p2p_conns[1].send_message(getdata_request)
|
||||
p2p_conns[1].wait_for_disconnect()
|
||||
assert_equal(len(self.nodes[0].getpeerinfo()), 1)
|
||||
@@ -145,12 +145,12 @@ class MaxUploadTest(BitcoinTestFramework):
|
||||
self.nodes[0].add_p2p_connection(TestP2PConn())
|
||||
|
||||
#retrieve 20 blocks which should be enough to break the 1MB limit
|
||||
getdata_request.inv = [CInv(2, big_new_block)]
|
||||
getdata_request.inv = [CInv(MSG_BLOCK, big_new_block)]
|
||||
for i in range(20):
|
||||
self.nodes[0].p2p.send_and_ping(getdata_request)
|
||||
assert_equal(self.nodes[0].p2p.block_receive_map[big_new_block], i+1)
|
||||
|
||||
getdata_request.inv = [CInv(2, big_old_block)]
|
||||
getdata_request.inv = [CInv(MSG_BLOCK, big_old_block)]
|
||||
self.nodes[0].p2p.send_and_ping(getdata_request)
|
||||
assert_equal(len(self.nodes[0].getpeerinfo()), 1) #node is still connected because of the whitelist
|
||||
|
||||
|
||||
Reference in New Issue
Block a user