13 In this test we connect to one node over p2p, send it numerous inv's, and 14 compare the resulting number of getdata requests to a max allowed value. We 15 test for exceeding 128 blocks in flight, which was the limit an 0.9 client will 16 reach. [0.10 clients shouldn't request more than 16 from a single peer.] 23 self.
log.
debug(
"got getdata %s" % repr(message))
25 for inv
in message.inv:
35 NodeConnCB.__init__(self)
36 self.
log = logging.getLogger(
"BlockRelayTest")
46 numBlocksToGenerate = [8, 16, 128, 1024]
47 for count
in range(len(numBlocksToGenerate)):
49 for i
in range(numBlocksToGenerate[count]):
50 current_invs.append(
CInv(2, random.randrange(0, 1 << 256)))
51 if len(current_invs) >= 50000:
54 if len(current_invs) > 0:
65 raise AssertionError(
"Error, test failed: block %064x requested more than once" % key)
66 if total_requests > MAX_REQUESTS:
67 raise AssertionError(
"Error, too many blocks (%d) requested" % total_requests)
68 print "Round %d: success (total requests: %d)" % (count, total_requests)
76 parser.add_option(
"--testbinary", dest=
"testbinary",
77 default=os.getenv(
"DASHD",
"dashd"),
78 help=
"Binary to test max block requests behavior")
81 print "Initializing test directory "+self.options.tmpdir
86 extra_args=[[
'-debug',
'-whitelist=127.0.0.1']],
87 binary=[self.options.testbinary])
95 if __name__ ==
'__main__':
def on_getdata(self, conn, message)
def start_nodes(num_nodes, dirname, extra_args=None, rpchost=None, binary=None)
def add_new_connection(self, connection)
def initialize_chain_clean(test_dir, num_nodes)
def add_options(self, parser)
UniValue debug(const UniValue ¶ms, bool fHelp)