mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 12:32:48 +01:00
71b4cf307b
fac95398366f644911b58f1605e6bc37fb76782d qa: Run all tests even if wallet is not compiled (MarcoFalke) faa669cbcd1fc799517b523b0f850e01b11bf40a qa: Premine to deterministic address with -disablewallet (MarcoFalke) Pull request description: Currently the test_runner would exit if the wallet was not compiled into the Bitcoin Core executable. However, a lot of the tests run without the wallet just fine and there is no need to globally require the wallet to run the tests. Tree-SHA512: 63177260aa29126fd20f0be217a82b10b62288ab846f96f1cbcc3bd2c52702437703475d91eae3f8d821a3149fc62b725a4c5b2a7b3657b67ffcbc81532a03bb
58 lines
2.1 KiB
Python
Executable File
58 lines
2.1 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
# Copyright (c) 2017-2018 The Bitcoin Core developers
|
|
# Distributed under the MIT software license, see the accompanying
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
"""Test that we don't leak txs to inbound peers that we haven't yet announced to"""
|
|
|
|
from test_framework.messages import msg_getdata, CInv
|
|
from test_framework.mininode import P2PDataStore
|
|
from test_framework.test_framework import BitcoinTestFramework
|
|
from test_framework.util import (
|
|
assert_equal,
|
|
)
|
|
|
|
|
|
class P2PNode(P2PDataStore):
|
|
def on_inv(self, msg):
|
|
pass
|
|
|
|
|
|
class P2PLeakTxTest(BitcoinTestFramework):
|
|
def set_test_params(self):
|
|
self.num_nodes = 1
|
|
|
|
def skip_test_if_missing_module(self):
|
|
self.skip_if_no_wallet()
|
|
|
|
def run_test(self):
|
|
gen_node = self.nodes[0] # The block and tx generating node
|
|
gen_node.generate(1)
|
|
|
|
inbound_peer = self.nodes[0].add_p2p_connection(P2PNode()) # An "attacking" inbound peer
|
|
|
|
MAX_REPEATS = 100
|
|
self.log.info("Running test up to {} times.".format(MAX_REPEATS))
|
|
for i in range(MAX_REPEATS):
|
|
self.log.info('Run repeat {}'.format(i + 1))
|
|
txid = gen_node.sendtoaddress(gen_node.getnewaddress(), 0.01)
|
|
|
|
want_tx = msg_getdata()
|
|
want_tx.inv.append(CInv(t=1, h=int(txid, 16)))
|
|
inbound_peer.last_message.pop('notfound', None)
|
|
inbound_peer.send_message(want_tx)
|
|
inbound_peer.sync_with_ping()
|
|
|
|
if inbound_peer.last_message.get('notfound'):
|
|
self.log.debug('tx {} was not yet announced to us.'.format(txid))
|
|
self.log.debug("node has responded with a notfound message. End test.")
|
|
assert_equal(inbound_peer.last_message['notfound'].vec[0].hash, int(txid, 16))
|
|
inbound_peer.last_message.pop('notfound')
|
|
break
|
|
else:
|
|
self.log.debug('tx {} was already announced to us. Try test again.'.format(txid))
|
|
assert int(txid, 16) in [inv.hash for inv in inbound_peer.last_message['inv'].inv]
|
|
|
|
|
|
if __name__ == '__main__':
|
|
P2PLeakTxTest().main()
|