Browse Source

Merge #9768: [qa] Add logging to test_framework.py

64c0800 Use logging in individual tests (John Newbery)
38ad281 Use logging in test_framework/comptool.py (John Newbery)
ff19073 Use logging in test_framework/blockstore.py (John Newbery)
2a9c7c7 Use logging in test_framework/util.py (John Newbery)
b0dec4a Remove manual debug settings in qa tests. (John Newbery)
af1363c Always enable debug log and microsecond logging for test nodes. (John Newbery)
6d0e325 Use logging in mininode.py (John Newbery)
553a976 Add logging to p2p-segwit.py (John Newbery)
0e6d23d Add logging to test_framework.py (John Newbery)

Tree-SHA512: 42ee2acbf444ec32d796f930f9f6e272da03c75e93d974a126d4ea9b2dbaa77cc57ab5e63ce3fd33d609049d884eb8d9f65272c08922d10f8db69d4a60ad05a3
pull/1/head
MarcoFalke 5 years ago
parent
commit
8910b4717e
No known key found for this signature in database
GPG Key ID: D2EA4850E7528B25
  1. 16
      qa/rpc-tests/abandonconflict.py
  2. 6
      qa/rpc-tests/assumevalid.py
  3. 2
      qa/rpc-tests/bip65-cltv-p2p.py
  4. 2
      qa/rpc-tests/bip68-112-113-p2p.py
  5. 20
      qa/rpc-tests/bip68-sequence.py
  6. 2
      qa/rpc-tests/bip9-softforks.py
  7. 2
      qa/rpc-tests/bipdersig-p2p.py
  8. 8
      qa/rpc-tests/bumpfee.py
  9. 2
      qa/rpc-tests/fundrawtransaction.py
  10. 2
      qa/rpc-tests/getblocktemplate_longpoll.py
  11. 12
      qa/rpc-tests/import-rescan.py
  12. 42
      qa/rpc-tests/importmulti.py
  13. 2
      qa/rpc-tests/importprunedfunds.py
  14. 34
      qa/rpc-tests/invalidateblock.py
  15. 2
      qa/rpc-tests/listsinceblock.py
  16. 6
      qa/rpc-tests/maxblocksinflight.py
  17. 18
      qa/rpc-tests/maxuploadtarget.py
  18. 2
      qa/rpc-tests/mempool_limit.py
  19. 10
      qa/rpc-tests/mempool_packages.py
  20. 2
      qa/rpc-tests/mempool_reorg.py
  21. 2
      qa/rpc-tests/mempool_resurrect_test.py
  22. 2
      qa/rpc-tests/mempool_spendcoinbase.py
  23. 10
      qa/rpc-tests/merkle_blocks.py
  24. 14
      qa/rpc-tests/nulldummy.py
  25. 20
      qa/rpc-tests/p2p-acceptblock.py
  26. 50
      qa/rpc-tests/p2p-compactblocks.py
  27. 4
      qa/rpc-tests/p2p-feefilter.py
  28. 4
      qa/rpc-tests/p2p-leaktests.py
  29. 2
      qa/rpc-tests/p2p-mempool.py
  30. 65
      qa/rpc-tests/p2p-segwit.py
  31. 3
      qa/rpc-tests/p2p-timeouts.py
  32. 2
      qa/rpc-tests/p2p-versionbits-warning.py
  33. 33
      qa/rpc-tests/preciousblock.py
  34. 8
      qa/rpc-tests/prioritise_transaction.py
  35. 8
      qa/rpc-tests/proxy_test.py
  36. 96
      qa/rpc-tests/pruning.py
  37. 4
      qa/rpc-tests/reindex.py
  38. 28
      qa/rpc-tests/replace-by-fee.py
  39. 2
      qa/rpc-tests/rest.py
  40. 2
      qa/rpc-tests/rpcbind_test.py
  41. 32
      qa/rpc-tests/segwit.py
  42. 22
      qa/rpc-tests/sendheaders.py
  43. 19
      qa/rpc-tests/smartfees.py
  44. 6
      qa/rpc-tests/test_framework/blockstore.py
  45. 19
      qa/rpc-tests/test_framework/comptool.py
  46. 28
      qa/rpc-tests/test_framework/mininode.py
  47. 68
      qa/rpc-tests/test_framework/test_framework.py
  48. 21
      qa/rpc-tests/test_framework/util.py
  49. 2
      qa/rpc-tests/wallet-hd.py
  50. 4
      qa/rpc-tests/wallet.py
  51. 16
      qa/rpc-tests/walletbackup.py
  52. 2
      qa/rpc-tests/zapwallettxes.py
  53. 2
      qa/rpc-tests/zmq_test.py

16
qa/rpc-tests/abandonconflict.py

@ -23,8 +23,8 @@ class AbandonConflictTest(BitcoinTestFramework): @@ -23,8 +23,8 @@ class AbandonConflictTest(BitcoinTestFramework):
def setup_network(self):
self.nodes = []
self.nodes.append(start_node(0, self.options.tmpdir, ["-debug","-logtimemicros","-minrelaytxfee=0.00001"]))
self.nodes.append(start_node(1, self.options.tmpdir, ["-debug","-logtimemicros"]))
self.nodes.append(start_node(0, self.options.tmpdir, ["-minrelaytxfee=0.00001"]))
self.nodes.append(start_node(1, self.options.tmpdir))
connect_nodes(self.nodes[0], 1)
def run_test(self):
@ -81,7 +81,7 @@ class AbandonConflictTest(BitcoinTestFramework): @@ -81,7 +81,7 @@ class AbandonConflictTest(BitcoinTestFramework):
# Restart the node with a higher min relay fee so the parent tx is no longer in mempool
# TODO: redo with eviction
stop_node(self.nodes[0],0)
self.nodes[0]=start_node(0, self.options.tmpdir, ["-debug","-logtimemicros","-minrelaytxfee=0.0001"])
self.nodes[0]=start_node(0, self.options.tmpdir, ["-minrelaytxfee=0.0001"])
# Verify txs no longer in mempool
assert_equal(len(self.nodes[0].getrawmempool()), 0)
@ -107,7 +107,7 @@ class AbandonConflictTest(BitcoinTestFramework): @@ -107,7 +107,7 @@ class AbandonConflictTest(BitcoinTestFramework):
# Verify that even with a low min relay fee, the tx is not reaccepted from wallet on startup once abandoned
stop_node(self.nodes[0],0)
self.nodes[0]=start_node(0, self.options.tmpdir, ["-debug","-logtimemicros","-minrelaytxfee=0.00001"])
self.nodes[0]=start_node(0, self.options.tmpdir, ["-minrelaytxfee=0.00001"])
assert_equal(len(self.nodes[0].getrawmempool()), 0)
assert_equal(self.nodes[0].getbalance(), balance)
@ -127,7 +127,7 @@ class AbandonConflictTest(BitcoinTestFramework): @@ -127,7 +127,7 @@ class AbandonConflictTest(BitcoinTestFramework):
# Remove using high relay fee again
stop_node(self.nodes[0],0)
self.nodes[0]=start_node(0, self.options.tmpdir, ["-debug","-logtimemicros","-minrelaytxfee=0.0001"])
self.nodes[0]=start_node(0, self.options.tmpdir, ["-minrelaytxfee=0.0001"])
assert_equal(len(self.nodes[0].getrawmempool()), 0)
newbalance = self.nodes[0].getbalance()
assert_equal(newbalance, balance - Decimal("24.9996"))
@ -158,9 +158,9 @@ class AbandonConflictTest(BitcoinTestFramework): @@ -158,9 +158,9 @@ class AbandonConflictTest(BitcoinTestFramework):
self.nodes[0].invalidateblock(self.nodes[0].getbestblockhash())
newbalance = self.nodes[0].getbalance()
#assert_equal(newbalance, balance - Decimal("10"))
print("If balance has not declined after invalidateblock then out of mempool wallet tx which is no longer")
print("conflicted has not resumed causing its inputs to be seen as spent. See Issue #7315")
print(str(balance) + " -> " + str(newbalance) + " ?")
self.log.info("If balance has not declined after invalidateblock then out of mempool wallet tx which is no longer")
self.log.info("conflicted has not resumed causing its inputs to be seen as spent. See Issue #7315")
self.log.info(str(balance) + " -> " + str(newbalance) + " ?")
if __name__ == '__main__':
AbandonConflictTest().main()

6
qa/rpc-tests/assumevalid.py

@ -73,7 +73,7 @@ class SendHeadersTest(BitcoinTestFramework): @@ -73,7 +73,7 @@ class SendHeadersTest(BitcoinTestFramework):
# we need to pre-mine a block with an invalid transaction
# signature so we can pass in the block hash as assumevalid.
self.nodes = []
self.nodes.append(start_node(0, self.options.tmpdir, ["-debug"]))
self.nodes.append(start_node(0, self.options.tmpdir))
def run_test(self):
@ -146,14 +146,14 @@ class SendHeadersTest(BitcoinTestFramework): @@ -146,14 +146,14 @@ class SendHeadersTest(BitcoinTestFramework):
# Start node1 and node2 with assumevalid so they accept a block with a bad signature.
self.nodes.append(start_node(1, self.options.tmpdir,
["-debug", "-assumevalid=" + hex(block102.sha256)]))
["-assumevalid=" + hex(block102.sha256)]))
node1 = BaseNode() # connects to node1
connections.append(NodeConn('127.0.0.1', p2p_port(1), self.nodes[1], node1))
node1.add_connection(connections[1])
node1.wait_for_verack()
self.nodes.append(start_node(2, self.options.tmpdir,
["-debug", "-assumevalid=" + hex(block102.sha256)]))
["-assumevalid=" + hex(block102.sha256)]))
node2 = BaseNode() # connects to node2
connections.append(NodeConn('127.0.0.1', p2p_port(2), self.nodes[2], node2))
node2.add_connection(connections[2])

2
qa/rpc-tests/bip65-cltv-p2p.py

@ -43,7 +43,7 @@ class BIP65Test(ComparisonTestFramework): @@ -43,7 +43,7 @@ class BIP65Test(ComparisonTestFramework):
def setup_network(self):
# Must set the blockversion for this test
self.nodes = start_nodes(self.num_nodes, self.options.tmpdir,
extra_args=[['-debug', '-whitelist=127.0.0.1', '-blockversion=3']],
extra_args=[['-whitelist=127.0.0.1', '-blockversion=3']],
binary=[self.options.testbinary])
def run_test(self):

2
qa/rpc-tests/bip68-112-113-p2p.py

@ -99,7 +99,7 @@ class BIP68_112_113Test(ComparisonTestFramework): @@ -99,7 +99,7 @@ class BIP68_112_113Test(ComparisonTestFramework):
def setup_network(self):
# Must set the blockversion for this test
self.nodes = start_nodes(self.num_nodes, self.options.tmpdir,
extra_args=[['-debug', '-whitelist=127.0.0.1', '-blockversion=4']],
extra_args=[['-whitelist=127.0.0.1', '-blockversion=4']],
binary=[self.options.testbinary])
def run_test(self):

20
qa/rpc-tests/bip68-sequence.py

@ -24,8 +24,8 @@ class BIP68Test(BitcoinTestFramework): @@ -24,8 +24,8 @@ class BIP68Test(BitcoinTestFramework):
def setup_network(self):
self.nodes = []
self.nodes.append(start_node(0, self.options.tmpdir, ["-debug"]))
self.nodes.append(start_node(1, self.options.tmpdir, ["-debug", "-acceptnonstdtxn=0"]))
self.nodes.append(start_node(0, self.options.tmpdir))
self.nodes.append(start_node(1, self.options.tmpdir, ["-acceptnonstdtxn=0"]))
self.is_network_split = False
self.relayfee = self.nodes[0].getnetworkinfo()["relayfee"]
connect_nodes(self.nodes[0], 1)
@ -34,26 +34,26 @@ class BIP68Test(BitcoinTestFramework): @@ -34,26 +34,26 @@ class BIP68Test(BitcoinTestFramework):
# Generate some coins
self.nodes[0].generate(110)
print("Running test disable flag")
self.log.info("Running test disable flag")
self.test_disable_flag()
print("Running test sequence-lock-confirmed-inputs")
self.log.info("Running test sequence-lock-confirmed-inputs")
self.test_sequence_lock_confirmed_inputs()
print("Running test sequence-lock-unconfirmed-inputs")
self.log.info("Running test sequence-lock-unconfirmed-inputs")
self.test_sequence_lock_unconfirmed_inputs()
print("Running test BIP68 not consensus before versionbits activation")
self.log.info("Running test BIP68 not consensus before versionbits activation")
self.test_bip68_not_consensus()
print("Activating BIP68 (and 112/113)")
self.log.info("Activating BIP68 (and 112/113)")
self.activateCSV()
print("Verifying nVersion=2 transactions are standard.")
print("Note that with current versions of bitcoin software, nVersion=2 transactions are always standard (independent of BIP68 activation status).")
self.log.info("Verifying nVersion=2 transactions are standard.")
self.log.info("Note that nVersion=2 transactions are always standard (independent of BIP68 activation status).")
self.test_version2_relay()
print("Passed\n")
self.log.info("Passed")
# Test that BIP68 is not in effect if tx version is 1, or if
# the first sequence bit is set.

2
qa/rpc-tests/bip9-softforks.py

@ -35,7 +35,7 @@ class BIP9SoftForksTest(ComparisonTestFramework): @@ -35,7 +35,7 @@ class BIP9SoftForksTest(ComparisonTestFramework):
def setup_network(self):
self.nodes = start_nodes(self.num_nodes, self.options.tmpdir,
extra_args=[['-debug', '-whitelist=127.0.0.1']],
extra_args=[['-whitelist=127.0.0.1']],
binary=[self.options.testbinary])
def run_test(self):

2
qa/rpc-tests/bipdersig-p2p.py

@ -50,7 +50,7 @@ class BIP66Test(ComparisonTestFramework): @@ -50,7 +50,7 @@ class BIP66Test(ComparisonTestFramework):
def setup_network(self):
# Must set the blockversion for this test
self.nodes = start_nodes(self.num_nodes, self.options.tmpdir,
extra_args=[['-debug', '-whitelist=127.0.0.1', '-blockversion=2']],
extra_args=[['-whitelist=127.0.0.1', '-blockversion=2']],
binary=[self.options.testbinary])
def run_test(self):

8
qa/rpc-tests/bumpfee.py

@ -26,7 +26,7 @@ class BumpFeeTest(BitcoinTestFramework): @@ -26,7 +26,7 @@ class BumpFeeTest(BitcoinTestFramework):
self.setup_clean_chain = True
def setup_network(self, split=False):
extra_args = [["-debug", "-prematurewitness", "-walletprematurewitness", "-walletrbf={}".format(i)]
extra_args = [["-prematurewitness", "-walletprematurewitness", "-walletrbf={}".format(i)]
for i in range(self.num_nodes)]
self.nodes = start_nodes(self.num_nodes, self.options.tmpdir, extra_args)
@ -45,7 +45,7 @@ class BumpFeeTest(BitcoinTestFramework): @@ -45,7 +45,7 @@ class BumpFeeTest(BitcoinTestFramework):
rbf_node_address = rbf_node.getnewaddress()
# fund rbf node with 10 coins of 0.001 btc (100,000 satoshis)
print("Mining blocks...")
self.log.info("Mining blocks...")
peer_node.generate(110)
self.sync_all()
for i in range(25):
@ -55,7 +55,7 @@ class BumpFeeTest(BitcoinTestFramework): @@ -55,7 +55,7 @@ class BumpFeeTest(BitcoinTestFramework):
self.sync_all()
assert_equal(rbf_node.getbalance(), Decimal("0.025"))
print("Running tests")
self.log.info("Running tests")
dest_address = peer_node.getnewaddress()
test_small_output_fails(rbf_node, dest_address)
test_dust_to_fee(rbf_node, dest_address)
@ -70,7 +70,7 @@ class BumpFeeTest(BitcoinTestFramework): @@ -70,7 +70,7 @@ class BumpFeeTest(BitcoinTestFramework):
test_unconfirmed_not_spendable(rbf_node, rbf_node_address)
test_bumpfee_metadata(rbf_node, dest_address)
test_locked_wallet_fails(rbf_node, dest_address)
print("Success")
self.log.info("Success")
def test_simple_bumpfee_succeeds(rbf_node, peer_node, dest_address):

2
qa/rpc-tests/fundrawtransaction.py

@ -34,8 +34,6 @@ class RawTransactionsTest(BitcoinTestFramework): @@ -34,8 +34,6 @@ class RawTransactionsTest(BitcoinTestFramework):
self.sync_all()
def run_test(self):
print("Mining blocks...")
min_relay_tx_fee = self.nodes[0].getnetworkinfo()['relayfee']
# This test is not meant to test fee estimation and we'd like
# to be sure all txs are sent at a consistent desired feerate

2
qa/rpc-tests/getblocktemplate_longpoll.py

@ -29,7 +29,7 @@ class GetBlockTemplateLPTest(BitcoinTestFramework): @@ -29,7 +29,7 @@ class GetBlockTemplateLPTest(BitcoinTestFramework):
self.setup_clean_chain = False
def run_test(self):
print("Warning: this test will take about 70 seconds in the best case. Be patient.")
self.log.info("Warning: this test will take about 70 seconds in the best case. Be patient.")
self.nodes[0].generate(10)
templat = self.nodes[0].getblocktemplate()
longpollid = templat['longpollid']

12
qa/rpc-tests/import-rescan.py

@ -7,11 +7,11 @@ @@ -7,11 +7,11 @@
Test rescan behavior of importaddress, importpubkey, importprivkey, and
importmulti RPCs with different types of keys and rescan options.
In the first part of the test, node 1 creates an address for each type of
import RPC call and node 0 sends BTC to it. Then other nodes import the
addresses, and the test makes listtransactions and getbalance calls to confirm
that the importing node either did or did not execute rescans picking up the
send transactions.
In the first part of the test, node 0 creates an address for each type of
import RPC call and sends BTC to it. Then other nodes import the addresses,
and the test makes listtransactions and getbalance calls to confirm that the
importing node either did or did not execute rescans picking up the send
transactions.
In the second part of the test, node 0 sends more BTC to each address, and the
test makes more listtransactions and getbalance calls to confirm that the
@ -117,7 +117,7 @@ class ImportRescanTest(BitcoinTestFramework): @@ -117,7 +117,7 @@ class ImportRescanTest(BitcoinTestFramework):
self.num_nodes = 2 + len(IMPORT_NODES)
def setup_network(self):
extra_args = [["-debug=1"] for _ in range(self.num_nodes)]
extra_args = [[] for _ in range(self.num_nodes)]
for i, import_node in enumerate(IMPORT_NODES, 2):
if import_node.prune:
extra_args[i] += ["-prune=1"]

42
qa/rpc-tests/importmulti.py

@ -17,7 +17,7 @@ class ImportMultiTest (BitcoinTestFramework): @@ -17,7 +17,7 @@ class ImportMultiTest (BitcoinTestFramework):
self.is_network_split=False
def run_test (self):
print ("Mining blocks...")
self.log.info("Mining blocks...")
self.nodes[0].generate(1)
self.nodes[1].generate(1)
timestamp = self.nodes[1].getblock(self.nodes[1].getbestblockhash())['mediantime']
@ -48,7 +48,7 @@ class ImportMultiTest (BitcoinTestFramework): @@ -48,7 +48,7 @@ class ImportMultiTest (BitcoinTestFramework):
# RPC importmulti -----------------------------------------------
# Bitcoin Address
print("Should import an address")
self.log.info("Should import an address")
address = self.nodes[0].validateaddress(self.nodes[0].getnewaddress())
result = self.nodes[1].importmulti([{
"scriptPubKey": {
@ -64,7 +64,7 @@ class ImportMultiTest (BitcoinTestFramework): @@ -64,7 +64,7 @@ class ImportMultiTest (BitcoinTestFramework):
watchonly_address = address['address']
watchonly_timestamp = timestamp
print("Should not import an invalid address")
self.log.info("Should not import an invalid address")
result = self.nodes[1].importmulti([{
"scriptPubKey": {
"address": "not valid address",
@ -76,7 +76,7 @@ class ImportMultiTest (BitcoinTestFramework): @@ -76,7 +76,7 @@ class ImportMultiTest (BitcoinTestFramework):
assert_equal(result[0]['error']['message'], 'Invalid address')
# ScriptPubKey + internal
print("Should import a scriptPubKey with internal flag")
self.log.info("Should import a scriptPubKey with internal flag")
address = self.nodes[0].validateaddress(self.nodes[0].getnewaddress())
result = self.nodes[1].importmulti([{
"scriptPubKey": address['scriptPubKey'],
@ -90,7 +90,7 @@ class ImportMultiTest (BitcoinTestFramework): @@ -90,7 +90,7 @@ class ImportMultiTest (BitcoinTestFramework):
assert_equal(address_assert['timestamp'], timestamp)
# ScriptPubKey + !internal
print("Should not import a scriptPubKey without internal flag")
self.log.info("Should not import a scriptPubKey without internal flag")
address = self.nodes[0].validateaddress(self.nodes[0].getnewaddress())
result = self.nodes[1].importmulti([{
"scriptPubKey": address['scriptPubKey'],
@ -106,7 +106,7 @@ class ImportMultiTest (BitcoinTestFramework): @@ -106,7 +106,7 @@ class ImportMultiTest (BitcoinTestFramework):
# Address + Public key + !Internal
print("Should import an address with public key")
self.log.info("Should import an address with public key")
address = self.nodes[0].validateaddress(self.nodes[0].getnewaddress())
result = self.nodes[1].importmulti([{
"scriptPubKey": {
@ -123,7 +123,7 @@ class ImportMultiTest (BitcoinTestFramework): @@ -123,7 +123,7 @@ class ImportMultiTest (BitcoinTestFramework):
# ScriptPubKey + Public key + internal
print("Should import a scriptPubKey with internal and with public key")
self.log.info("Should import a scriptPubKey with internal and with public key")
address = self.nodes[0].validateaddress(self.nodes[0].getnewaddress())
request = [{
"scriptPubKey": address['scriptPubKey'],
@ -139,7 +139,7 @@ class ImportMultiTest (BitcoinTestFramework): @@ -139,7 +139,7 @@ class ImportMultiTest (BitcoinTestFramework):
assert_equal(address_assert['timestamp'], timestamp)
# ScriptPubKey + Public key + !internal
print("Should not import a scriptPubKey without internal and with public key")
self.log.info("Should not import a scriptPubKey without internal and with public key")
address = self.nodes[0].validateaddress(self.nodes[0].getnewaddress())
request = [{
"scriptPubKey": address['scriptPubKey'],
@ -156,7 +156,7 @@ class ImportMultiTest (BitcoinTestFramework): @@ -156,7 +156,7 @@ class ImportMultiTest (BitcoinTestFramework):
assert_equal('timestamp' in address_assert, False)
# Address + Private key + !watchonly
print("Should import an address with private key")
self.log.info("Should import an address with private key")
address = self.nodes[0].validateaddress(self.nodes[0].getnewaddress())
result = self.nodes[1].importmulti([{
"scriptPubKey": {
@ -172,7 +172,7 @@ class ImportMultiTest (BitcoinTestFramework): @@ -172,7 +172,7 @@ class ImportMultiTest (BitcoinTestFramework):
assert_equal(address_assert['timestamp'], timestamp)
# Address + Private key + watchonly
print("Should not import an address with private key and with watchonly")
self.log.info("Should not import an address with private key and with watchonly")
address = self.nodes[0].validateaddress(self.nodes[0].getnewaddress())
result = self.nodes[1].importmulti([{
"scriptPubKey": {
@ -191,7 +191,7 @@ class ImportMultiTest (BitcoinTestFramework): @@ -191,7 +191,7 @@ class ImportMultiTest (BitcoinTestFramework):
assert_equal('timestamp' in address_assert, False)
# ScriptPubKey + Private key + internal
print("Should import a scriptPubKey with internal and with private key")
self.log.info("Should import a scriptPubKey with internal and with private key")
address = self.nodes[0].validateaddress(self.nodes[0].getnewaddress())
result = self.nodes[1].importmulti([{
"scriptPubKey": address['scriptPubKey'],
@ -206,7 +206,7 @@ class ImportMultiTest (BitcoinTestFramework): @@ -206,7 +206,7 @@ class ImportMultiTest (BitcoinTestFramework):
assert_equal(address_assert['timestamp'], timestamp)
# ScriptPubKey + Private key + !internal
print("Should not import a scriptPubKey without internal and with private key")
self.log.info("Should not import a scriptPubKey without internal and with private key")
address = self.nodes[0].validateaddress(self.nodes[0].getnewaddress())
result = self.nodes[1].importmulti([{
"scriptPubKey": address['scriptPubKey'],
@ -233,7 +233,7 @@ class ImportMultiTest (BitcoinTestFramework): @@ -233,7 +233,7 @@ class ImportMultiTest (BitcoinTestFramework):
timestamp = self.nodes[1].getblock(self.nodes[1].getbestblockhash())['mediantime']
transaction = self.nodes[1].gettransaction(transactionid)
print("Should import a p2sh")
self.log.info("Should import a p2sh")
result = self.nodes[1].importmulti([{
"scriptPubKey": {
"address": multi_sig_script['address']
@ -261,7 +261,7 @@ class ImportMultiTest (BitcoinTestFramework): @@ -261,7 +261,7 @@ class ImportMultiTest (BitcoinTestFramework):
timestamp = self.nodes[1].getblock(self.nodes[1].getbestblockhash())['mediantime']
transaction = self.nodes[1].gettransaction(transactionid)
print("Should import a p2sh with respective redeem script")
self.log.info("Should import a p2sh with respective redeem script")
result = self.nodes[1].importmulti([{
"scriptPubKey": {
"address": multi_sig_script['address']
@ -289,7 +289,7 @@ class ImportMultiTest (BitcoinTestFramework): @@ -289,7 +289,7 @@ class ImportMultiTest (BitcoinTestFramework):
timestamp = self.nodes[1].getblock(self.nodes[1].getbestblockhash())['mediantime']
transaction = self.nodes[1].gettransaction(transactionid)
print("Should import a p2sh with respective redeem script and private keys")
self.log.info("Should import a p2sh with respective redeem script and private keys")
result = self.nodes[1].importmulti([{
"scriptPubKey": {
"address": multi_sig_script['address']
@ -316,7 +316,7 @@ class ImportMultiTest (BitcoinTestFramework): @@ -316,7 +316,7 @@ class ImportMultiTest (BitcoinTestFramework):
self.nodes[1].generate(1)
transaction = self.nodes[1].gettransaction(transactionid)
print("Should import a p2sh with respective redeem script and private keys")
self.log.info("Should import a p2sh with respective redeem script and private keys")
result = self.nodes[1].importmulti([{
"scriptPubKey": {
"address": multi_sig_script['address']
@ -332,7 +332,7 @@ class ImportMultiTest (BitcoinTestFramework): @@ -332,7 +332,7 @@ class ImportMultiTest (BitcoinTestFramework):
# Address + Public key + !Internal + Wrong pubkey
print("Should not import an address with a wrong public key")
self.log.info("Should not import an address with a wrong public key")
address = self.nodes[0].validateaddress(self.nodes[0].getnewaddress())
address2 = self.nodes[0].validateaddress(self.nodes[0].getnewaddress())
result = self.nodes[1].importmulti([{
@ -352,7 +352,7 @@ class ImportMultiTest (BitcoinTestFramework): @@ -352,7 +352,7 @@ class ImportMultiTest (BitcoinTestFramework):
# ScriptPubKey + Public key + internal + Wrong pubkey
print("Should not import a scriptPubKey with internal and with a wrong public key")
self.log.info("Should not import a scriptPubKey with internal and with a wrong public key")
address = self.nodes[0].validateaddress(self.nodes[0].getnewaddress())
address2 = self.nodes[0].validateaddress(self.nodes[0].getnewaddress())
request = [{
@ -372,7 +372,7 @@ class ImportMultiTest (BitcoinTestFramework): @@ -372,7 +372,7 @@ class ImportMultiTest (BitcoinTestFramework):
# Address + Private key + !watchonly + Wrong private key
print("Should not import an address with a wrong private key")
self.log.info("Should not import an address with a wrong private key")
address = self.nodes[0].validateaddress(self.nodes[0].getnewaddress())
address2 = self.nodes[0].validateaddress(self.nodes[0].getnewaddress())
result = self.nodes[1].importmulti([{
@ -392,7 +392,7 @@ class ImportMultiTest (BitcoinTestFramework): @@ -392,7 +392,7 @@ class ImportMultiTest (BitcoinTestFramework):
# ScriptPubKey + Private key + internal + Wrong private key
print("Should not import a scriptPubKey with internal and with a wrong private key")
self.log.info("Should not import a scriptPubKey with internal and with a wrong private key")
address = self.nodes[0].validateaddress(self.nodes[0].getnewaddress())
address2 = self.nodes[0].validateaddress(self.nodes[0].getnewaddress())
result = self.nodes[1].importmulti([{
@ -418,7 +418,7 @@ class ImportMultiTest (BitcoinTestFramework): @@ -418,7 +418,7 @@ class ImportMultiTest (BitcoinTestFramework):
assert_equal(address_assert['timestamp'], watchonly_timestamp);
# Bad or missing timestamps
print("Should throw on invalid or missing timestamp values")
self.log.info("Should throw on invalid or missing timestamp values")
assert_raises_message(JSONRPCException, 'Missing required timestamp field for key',
self.nodes[1].importmulti, [{
"scriptPubKey": address['scriptPubKey'],

2
qa/rpc-tests/importprunedfunds.py

@ -21,7 +21,7 @@ class ImportPrunedFundsTest(BitcoinTestFramework): @@ -21,7 +21,7 @@ class ImportPrunedFundsTest(BitcoinTestFramework):
self.sync_all()
def run_test(self):
print("Mining blocks...")
self.log.info("Mining blocks...")
self.nodes[0].generate(101)
self.sync_all()

34
qa/rpc-tests/invalidateblock.py

@ -18,53 +18,51 @@ class InvalidateTest(BitcoinTestFramework): @@ -18,53 +18,51 @@ class InvalidateTest(BitcoinTestFramework):
def setup_network(self):
self.nodes = []
self.is_network_split = False
self.nodes.append(start_node(0, self.options.tmpdir, ["-debug"]))
self.nodes.append(start_node(1, self.options.tmpdir, ["-debug"]))
self.nodes.append(start_node(2, self.options.tmpdir, ["-debug"]))
self.nodes.append(start_node(0, self.options.tmpdir))
self.nodes.append(start_node(1, self.options.tmpdir))
self.nodes.append(start_node(2, self.options.tmpdir))
def run_test(self):
print("Make sure we repopulate setBlockIndexCandidates after InvalidateBlock:")
print("Mine 4 blocks on Node 0")
self.log.info("Make sure we repopulate setBlockIndexCandidates after InvalidateBlock:")
self.log.info("Mine 4 blocks on Node 0")
self.nodes[0].generate(4)
assert(self.nodes[0].getblockcount() == 4)
besthash = self.nodes[0].getbestblockhash()
print("Mine competing 6 blocks on Node 1")
self.log.info("Mine competing 6 blocks on Node 1")
self.nodes[1].generate(6)
assert(self.nodes[1].getblockcount() == 6)
print("Connect nodes to force a reorg")
self.log.info("Connect nodes to force a reorg")
connect_nodes_bi(self.nodes,0,1)
sync_blocks(self.nodes[0:2])
assert(self.nodes[0].getblockcount() == 6)
badhash = self.nodes[1].getblockhash(2)
print("Invalidate block 2 on node 0 and verify we reorg to node 0's original chain")
self.log.info("Invalidate block 2 on node 0 and verify we reorg to node 0's original chain")
self.nodes[0].invalidateblock(badhash)
newheight = self.nodes[0].getblockcount()
newhash = self.nodes[0].getbestblockhash()
if (newheight != 4 or newhash != besthash):
raise AssertionError("Wrong tip for node0, hash %s, height %d"%(newhash,newheight))
print("\nMake sure we won't reorg to a lower work chain:")
self.log.info("Make sure we won't reorg to a lower work chain:")
connect_nodes_bi(self.nodes,1,2)
print("Sync node 2 to node 1 so both have 6 blocks")
self.log.info("Sync node 2 to node 1 so both have 6 blocks")
sync_blocks(self.nodes[1:3])
assert(self.nodes[2].getblockcount() == 6)
print("Invalidate block 5 on node 1 so its tip is now at 4")
self.log.info("Invalidate block 5 on node 1 so its tip is now at 4")
self.nodes[1].invalidateblock(self.nodes[1].getblockhash(5))
assert(self.nodes[1].getblockcount() == 4)
print("Invalidate block 3 on node 2, so its tip is now 2")
self.log.info("Invalidate block 3 on node 2, so its tip is now 2")
self.nodes[2].invalidateblock(self.nodes[2].getblockhash(3))
assert(self.nodes[2].getblockcount() == 2)
print("..and then mine a block")
self.log.info("..and then mine a block")
self.nodes[2].generate(1)
print("Verify all nodes are at the right height")
self.log.info("Verify all nodes are at the right height")
time.sleep(5)
for i in range(3):
print(i,self.nodes[i].getblockcount())
assert(self.nodes[2].getblockcount() == 3)
assert(self.nodes[0].getblockcount() == 4)
assert_equal(self.nodes[2].getblockcount(), 3)
assert_equal(self.nodes[0].getblockcount(), 4)
node1height = self.nodes[1].getblockcount()
if node1height < 4:
raise AssertionError("Node 1 reorged to a lower height: %d"%node1height)

2
qa/rpc-tests/listsinceblock.py

@ -62,7 +62,7 @@ class ListSinceBlockTest (BitcoinTestFramework): @@ -62,7 +62,7 @@ class ListSinceBlockTest (BitcoinTestFramework):
# generate on both sides
lastblockhash = self.nodes[1].generate(6)[5]
self.nodes[2].generate(7)
print('lastblockhash=%s' % (lastblockhash))
self.log.info('lastblockhash=%s' % (lastblockhash))
self.sync_all()

6
qa/rpc-tests/maxblocksinflight.py

@ -13,7 +13,6 @@ reach. [0.10 clients shouldn't request more than 16 from a single peer.] @@ -13,7 +13,6 @@ reach. [0.10 clients shouldn't request more than 16 from a single peer.]
from test_framework.mininode import *
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
import logging
MAX_REQUESTS = 128
@ -33,7 +32,6 @@ class TestManager(NodeConnCB): @@ -33,7 +32,6 @@ class TestManager(NodeConnCB):
def __init__(self):
NodeConnCB.__init__(self)
self.log = logging.getLogger("BlockRelayTest")
def add_new_connection(self, connection):
self.connection = connection
@ -65,7 +63,7 @@ class TestManager(NodeConnCB): @@ -65,7 +63,7 @@ class TestManager(NodeConnCB):
raise AssertionError("Error, test failed: block %064x requested more than once" % key)
if total_requests > MAX_REQUESTS:
raise AssertionError("Error, too many blocks (%d) requested" % total_requests)
print("Round %d: success (total requests: %d)" % (count, total_requests))
self.log.info("Round %d: success (total requests: %d)" % (count, total_requests))
self.disconnectOkay = True
self.connection.disconnect_node()
@ -84,7 +82,7 @@ class MaxBlocksInFlightTest(BitcoinTestFramework): @@ -84,7 +82,7 @@ class MaxBlocksInFlightTest(BitcoinTestFramework):
def setup_network(self):
self.nodes = start_nodes(self.num_nodes, self.options.tmpdir,
extra_args=[['-debug', '-whitelist=127.0.0.1']],
extra_args=[['-whitelist=127.0.0.1']],
binary=[self.options.testbinary])
def run_test(self):

18
qa/rpc-tests/maxuploadtarget.py

@ -90,7 +90,7 @@ class MaxUploadTest(BitcoinTestFramework): @@ -90,7 +90,7 @@ class MaxUploadTest(BitcoinTestFramework):
def setup_network(self):
# Start a node with maxuploadtarget of 200 MB (/24h)
self.nodes = []
self.nodes.append(start_node(0, self.options.tmpdir, ["-debug", "-maxuploadtarget=800", "-blockmaxsize=999000"]))
self.nodes.append(start_node(0, self.options.tmpdir, ["-maxuploadtarget=800", "-blockmaxsize=999000"]))
def run_test(self):
# Before we connect anything, we first set the time on the node
@ -161,7 +161,7 @@ class MaxUploadTest(BitcoinTestFramework): @@ -161,7 +161,7 @@ class MaxUploadTest(BitcoinTestFramework):
test_nodes[0].send_message(getdata_request)
test_nodes[0].wait_for_disconnect()
assert_equal(len(self.nodes[0].getpeerinfo()), 2)
print("Peer 0 disconnected after downloading old block too many times")
self.log.info("Peer 0 disconnected after downloading old block too many times")
# Requesting the current block on test_nodes[1] should succeed indefinitely,
# even when over the max upload target.
@ -172,7 +172,7 @@ class MaxUploadTest(BitcoinTestFramework): @@ -172,7 +172,7 @@ class MaxUploadTest(BitcoinTestFramework):
test_nodes[1].sync_with_ping()
assert_equal(test_nodes[1].block_receive_map[big_new_block], i+1)
print("Peer 1 able to repeatedly download new block")
self.log.info("Peer 1 able to repeatedly download new block")
# But if test_nodes[1] tries for an old block, it gets disconnected too.
getdata_request.inv = [CInv(2, big_old_block)]
@ -180,9 +180,9 @@ class MaxUploadTest(BitcoinTestFramework): @@ -180,9 +180,9 @@ class MaxUploadTest(BitcoinTestFramework):
test_nodes[1].wait_for_disconnect()
assert_equal(len(self.nodes[0].getpeerinfo()), 1)
print("Peer 1 disconnected after trying to download old block")
self.log.info("Peer 1 disconnected after trying to download old block")
print("Advancing system time on node to clear counters...")
self.log.info("Advancing system time on node to clear counters...")
# If we advance the time by 24 hours, then the counters should reset,
# and test_nodes[2] should be able to retrieve the old block.
@ -192,14 +192,14 @@ class MaxUploadTest(BitcoinTestFramework): @@ -192,14 +192,14 @@ class MaxUploadTest(BitcoinTestFramework):
test_nodes[2].sync_with_ping()
assert_equal(test_nodes[2].block_receive_map[big_old_block], 1)
print("Peer 2 able to download old block")
self.log.info("Peer 2 able to download old block")
[c.disconnect_node() for c in connections]
#stop and start node 0 with 1MB maxuploadtarget, whitelist 127.0.0.1
print("Restarting nodes with -whitelist=127.0.0.1")
self.log.info("Restarting nodes with -whitelist=127.0.0.1")
stop_node(self.nodes[0], 0)
self.nodes[0] = start_node(0, self.options.tmpdir, ["-debug", "-whitelist=127.0.0.1", "-maxuploadtarget=1", "-blockmaxsize=999000"])
self.nodes[0] = start_node(0, self.options.tmpdir, ["-whitelist=127.0.0.1", "-maxuploadtarget=1", "-blockmaxsize=999000"])
#recreate/reconnect 3 test nodes
test_nodes = []
@ -225,7 +225,7 @@ class MaxUploadTest(BitcoinTestFramework): @@ -225,7 +225,7 @@ class MaxUploadTest(BitcoinTestFramework):
test_nodes[1].wait_for_disconnect()
assert_equal(len(self.nodes[0].getpeerinfo()), 3) #node is still connected because of the whitelist
print("Peer 1 still connected after trying to download old block (whitelisted)")
self.log.info("Peer 1 still connected after trying to download old block (whitelisted)")
[c.disconnect_node() for c in connections]

2
qa/rpc-tests/mempool_limit.py

@ -11,7 +11,7 @@ class MempoolLimitTest(BitcoinTestFramework): @@ -11,7 +11,7 @@ class MempoolLimitTest(BitcoinTestFramework):
def setup_network(self):
self.nodes = []
self.nodes.append(start_node(0, self.options.tmpdir, ["-maxmempool=5", "-spendzeroconfchange=0", "-debug"]))
self.nodes.append(start_node(0, self.options.tmpdir, ["-maxmempool=5", "-spendzeroconfchange=0"]))
self.is_network_split = False
self.sync_all()
self.relayfee = self.nodes[0].getnetworkinfo()['relayfee']

10
qa/rpc-tests/mempool_packages.py

@ -19,8 +19,8 @@ class MempoolPackagesTest(BitcoinTestFramework): @@ -19,8 +19,8 @@ class MempoolPackagesTest(BitcoinTestFramework):
def setup_network(self):
self.nodes = []
self.nodes.append(start_node(0, self.options.tmpdir, ["-maxorphantx=1000", "-debug"]))
self.nodes.append(start_node(1, self.options.tmpdir, ["-maxorphantx=1000", "-limitancestorcount=5", "-debug"]))
self.nodes.append(start_node(0, self.options.tmpdir, ["-maxorphantx=1000"]))
self.nodes.append(start_node(1, self.options.tmpdir, ["-maxorphantx=1000", "-limitancestorcount=5"]))
connect_nodes(self.nodes[0], 1)
self.is_network_split = False
self.sync_all()
@ -115,7 +115,7 @@ class MempoolPackagesTest(BitcoinTestFramework): @@ -115,7 +115,7 @@ class MempoolPackagesTest(BitcoinTestFramework):
try:
self.chain_transaction(self.nodes[0], txid, vout, value, fee, 1)
except JSONRPCException as e:
print("too-long-ancestor-chain successfully rejected")
self.log.info("too-long-ancestor-chain successfully rejected")
# Check that prioritising a tx before it's added to the mempool works
# First clear the mempool by mining a block.
@ -165,9 +165,9 @@ class MempoolPackagesTest(BitcoinTestFramework): @@ -165,9 +165,9 @@ class MempoolPackagesTest(BitcoinTestFramework):
mempool = self.nodes[0].getrawmempool(True)
assert_equal(mempool[parent_transaction]['descendantcount'], MAX_DESCENDANTS)
except JSONRPCException as e:
print(e.error['message'])
self.log.info(e.error['message'])
assert_equal(i, MAX_DESCENDANTS - 1)
print("tx that would create too large descendant package successfully rejected")
self.log.info("tx that would create too large descendant package successfully rejected")
# TODO: check that node1's mempool is as expected

2
qa/rpc-tests/mempool_reorg.py

@ -21,7 +21,7 @@ class MempoolCoinbaseTest(BitcoinTestFramework): @@ -21,7 +21,7 @@ class MempoolCoinbaseTest(BitcoinTestFramework):
alert_filename = None # Set by setup_network
def setup_network(self):
args = ["-checkmempool", "-debug=mempool"]
args = ["-checkmempool"]
self.nodes = []
self.nodes.append(start_node(0, self.options.tmpdir, args))
self.nodes.append(start_node(1, self.options.tmpdir, args))

2
qa/rpc-tests/mempool_resurrect_test.py

@ -17,7 +17,7 @@ class MempoolCoinbaseTest(BitcoinTestFramework): @@ -17,7 +17,7 @@ class MempoolCoinbaseTest(BitcoinTestFramework):
def setup_network(self):
# Just need one node for this test
args = ["-checkmempool", "-debug=mempool"]
args = ["-checkmempool"]
self.nodes = []
self.nodes.append(start_node(0, self.options.tmpdir, args))
self.is_network_split = False

2
qa/rpc-tests/mempool_spendcoinbase.py

@ -25,7 +25,7 @@ class MempoolSpendCoinbaseTest(BitcoinTestFramework): @@ -25,7 +25,7 @@ class MempoolSpendCoinbaseTest(BitcoinTestFramework):
def setup_network(self):
# Just need one node for this test
args = ["-checkmempool", "-debug=mempool"]
args = ["-checkmempool"]
self.nodes = []
self.nodes.append(start_node(0, self.options.tmpdir, args))
self.is_network_split = False

10
qa/rpc-tests/merkle_blocks.py

@ -17,11 +17,11 @@ class MerkleBlockTest(BitcoinTestFramework): @@ -17,11 +17,11 @@ class MerkleBlockTest(BitcoinTestFramework):
def setup_network(self):
self.nodes = []
# Nodes 0/1 are "wallet" nodes
self.nodes.append(start_node(0, self.options.tmpdir, ["-debug"]))
self.nodes.append(start_node(1, self.options.tmpdir, ["-debug"]))
self.nodes.append(start_node(0, self.options.tmpdir))
self.nodes.append(start_node(1, self.options.tmpdir))
# Nodes 2/3 are used for testing
self.nodes.append(start_node(2, self.options.tmpdir, ["-debug"]))
self.nodes.append(start_node(3, self.options.tmpdir, ["-debug", "-txindex"]))
self.nodes.append(start_node(2, self.options.tmpdir))
self.nodes.append(start_node(3, self.options.tmpdir, ["-txindex"]))
connect_nodes(self.nodes[0], 1)
connect_nodes(self.nodes[0], 2)
connect_nodes(self.nodes[0], 3)
@ -30,7 +30,7 @@ class MerkleBlockTest(BitcoinTestFramework): @@ -30,7 +30,7 @@ class MerkleBlockTest(BitcoinTestFramework):
self.sync_all()
def run_test(self):
print("Mining blocks...")
self.log.info("Mining blocks...")
self.nodes[0].generate(105)
self.sync_all()

14
qa/rpc-tests/nulldummy.py

@ -45,7 +45,7 @@ class NULLDUMMYTest(BitcoinTestFramework): @@ -45,7 +45,7 @@ class NULLDUMMYTest(BitcoinTestFramework):
def setup_network(self):
# Must set the blockversion for this test
self.nodes = start_nodes(self.num_nodes, self.options.tmpdir,
extra_args=[['-debug', '-whitelist=127.0.0.1', '-walletprematurewitness']])
extra_args=[['-whitelist=127.0.0.1', '-walletprematurewitness']])
def run_test(self):
self.address = self.nodes[0].getnewaddress()
@ -64,7 +64,7 @@ class NULLDUMMYTest(BitcoinTestFramework): @@ -64,7 +64,7 @@ class NULLDUMMYTest(BitcoinTestFramework):
self.lastblockheight = 429
self.lastblocktime = int(time.time()) + 429
print ("Test 1: NULLDUMMY compliant base transactions should be accepted to mempool and mined before activation [430]")
self.log.info("Test 1: NULLDUMMY compliant base transactions should be accepted to mempool and mined before activation [430]")
test1txs = [self.create_transaction(self.nodes[0], coinbase_txid[0], self.ms_address, 49)]
txid1 = self.tx_submit(self.nodes[0], test1txs[0])
test1txs.append(self.create_transaction(self.nodes[0], txid1, self.ms_address, 48))
@ -73,29 +73,29 @@ class NULLDUMMYTest(BitcoinTestFramework): @@ -73,29 +73,29 @@ class NULLDUMMYTest(BitcoinTestFramework):
txid3 = self.tx_submit(self.nodes[0], test1txs[2])
self.block_submit(self.nodes[0], test1txs, False, True)
print ("Test 2: Non-NULLDUMMY base multisig transaction should not be accepted to mempool before activation")
self.log.info("Test 2: Non-NULLDUMMY base multisig transaction should not be accepted to mempool before activation")
test2tx = self.create_transaction(self.nodes[0], txid2, self.ms_address, 47)
trueDummy(test2tx)
txid4 = self.tx_submit(self.nodes[0], test2tx, NULLDUMMY_ERROR)
print ("Test 3: Non-NULLDUMMY base transactions should be accepted in a block before activation [431]")
self.log.info("Test 3: Non-NULLDUMMY base transactions should be accepted in a block before activation [431]")
self.block_submit(self.nodes[0], [test2tx], False, True)
print ("Test 4: Non-NULLDUMMY base multisig transaction is invalid after activation")
self.log.info("Test 4: Non-NULLDUMMY base multisig transaction is invalid after activation")
test4tx = self.create_transaction(self.nodes[0], txid4, self.address, 46)
test6txs=[CTransaction(test4tx)]
trueDummy(test4tx)
self.tx_submit(self.nodes[0], test4tx, NULLDUMMY_ERROR)
self.block_submit(self.nodes[0], [test4tx])
print ("Test 5: Non-NULLDUMMY P2WSH multisig transaction invalid after activation")
self.log.info("Test 5: Non-NULLDUMMY P2WSH multisig transaction invalid after activation")
test5tx = self.create_transaction(self.nodes[0], txid3, self.wit_address, 48)
test6txs.append(CTransaction(test5tx))
test5tx.wit.vtxinwit[0].scriptWitness.stack[0] = b'\x01'
self.tx_submit(self.nodes[0], test5tx, NULLDUMMY_ERROR)
self.block_submit(self.nodes[0], [test5tx], True)
print ("Test 6: NULLDUMMY compliant base/witness transactions should be accepted to mempool and in block after activation [432]")
self.log.info("Test 6: NULLDUMMY compliant base/witness transactions should be accepted to mempool and in block after activation [432]")
for i in test6txs:
self.tx_submit(self.nodes[0], i)
self.block_submit(self.nodes[0], test6txs, True, True)

20
qa/rpc-tests/p2p-acceptblock.py

@ -119,10 +119,10 @@ class AcceptBlockTest(BitcoinTestFramework): @@ -119,10 +119,10 @@ class AcceptBlockTest(BitcoinTestFramework):
# from peers which are not whitelisted, while Node1 will be used for
# the whitelisted case.
self.nodes = []
self.nodes.append(start_node(0, self.options.tmpdir, ["-debug"],
self.nodes.append(start_node(0, self.options.tmpdir,
binary=self.options.testbinary))
self.nodes.append(start_node(1, self.options.tmpdir,
["-debug", "-whitelist=127.0.0.1"],
["-whitelist=127.0.0.1"],
binary=self.options.testbinary))
def run_test(self):
@ -160,7 +160,7 @@ class AcceptBlockTest(BitcoinTestFramework): @@ -160,7 +160,7 @@ class AcceptBlockTest(BitcoinTestFramework):
[ x.sync_with_ping() for x in [test_node, white_node] ]
assert_equal(self.nodes[0].getblockcount(), 2)
assert_equal(self.nodes[1].getblockcount(), 2)
print("First height 2 block accepted by both nodes")
self.log.info("First height 2 block accepted by both nodes")
# 3. Send another block that builds on the original tip.
blocks_h2f = [] # Blocks at height 2 that fork off the main chain
@ -179,7 +179,7 @@ class AcceptBlockTest(BitcoinTestFramework): @@ -179,7 +179,7 @@ class AcceptBlockTest(BitcoinTestFramework):
if x['hash'] == blocks_h2f[1].hash:
assert_equal(x['status'], "valid-headers")
print("Second height 2 block accepted only from whitelisted peer")
self.log.info("Second height 2 block accepted only from whitelisted peer")
# 4. Now send another block that builds on the forking chain.
blocks_h3 = []
@ -198,11 +198,11 @@ class AcceptBlockTest(BitcoinTestFramework): @@ -198,11 +198,11 @@ class AcceptBlockTest(BitcoinTestFramework):
# But this block should be accepted by node0 since it has more work.
self.nodes[0].getblock(blocks_h3[0].hash)
print("Unrequested more-work block accepted from non-whitelisted peer")
self.log.info("Unrequested more-work block accepted from non-whitelisted peer")
# Node1 should have accepted and reorged.
assert_equal(self.nodes[1].getblockcount(), 3)
print("Successfully reorged to length 3 chain from whitelisted peer")
self.log.info("Successfully reorged to length 3 chain from whitelisted peer")
# 4b. Now mine 288 more blocks and deliver; all should be processed but
# the last (height-too-high) on node0. Node1 should process the tip if
@ -232,7 +232,7 @@ class AcceptBlockTest(BitcoinTestFramework): @@ -232,7 +232,7 @@ class AcceptBlockTest(BitcoinTestFramework):
white_node.send_message(msg_block(tips[1])) # Now deliver the tip
white_node.sync_with_ping()
self.nodes[1].getblock(tips[1].hash)
print("Unrequested block far ahead of tip accepted from whitelisted peer")
self.log.info("Unrequested block far ahead of tip accepted from whitelisted peer")
# 5. Test handling of unrequested block on the node that didn't process
# Should still not be processed (even though it has a child that has more
@ -246,7 +246,7 @@ class AcceptBlockTest(BitcoinTestFramework): @@ -246,7 +246,7 @@ class AcceptBlockTest(BitcoinTestFramework):
# a getdata request for this block.
test_node.sync_with_ping()
assert_equal(self.nodes[0].getblockcount(), 2)
print("Unrequested block that would complete more-work chain was ignored")
self.log.info("Unrequested block that would complete more-work chain was ignored")
# 6. Try to get node to request the missing block.
# Poke the node with an inv for block at height 3 and see if that
@ -262,14 +262,14 @@ class AcceptBlockTest(BitcoinTestFramework): @@ -262,14 +262,14 @@ class AcceptBlockTest(BitcoinTestFramework):
# Check that the getdata includes the right block
assert_equal(getdata.inv[0].hash, blocks_h2f[0].sha256)
print("Inv at tip triggered getdata for unprocessed block")
self.log.info("Inv at tip triggered getdata for unprocessed block")
# 7. Send the missing block for the third time (now it is requested)
test_node.send_message(msg_block(blocks_h2f[0]))
test_node.sync_with_ping()
assert_equal(self.nodes[0].getblockcount(), 290)
print("Successfully reorged to longer chain from non-whitelisted peer")
self.log.info("Successfully reorged to longer chain from non-whitelisted peer")
[ c.disconnect_node() for c in connections ]

50
qa/rpc-tests/p2p-compactblocks.py

@ -120,8 +120,8 @@ class CompactBlocksTest(BitcoinTestFramework): @@ -120,8 +120,8 @@ class CompactBlocksTest(BitcoinTestFramework):
# Start up node0 to be a version 1, pre-segwit node.
self.nodes = start_nodes(self.num_nodes, self.options.tmpdir,
[["-debug", "-logtimemicros=1", "-bip9params=segwit:0:0"],
["-debug", "-logtimemicros", "-txindex"]])
[["-bip9params=segwit:0:0"],
["-txindex"]])
connect_nodes(self.nodes[0], 1)
def build_block_on_tip(self, node, segwit=False):
@ -846,102 +846,102 @@ class CompactBlocksTest(BitcoinTestFramework): @@ -846,102 +846,102 @@ class CompactBlocksTest(BitcoinTestFramework):
# We will need UTXOs to construct transactions in later tests.
self.make_utxos()
print("Running tests, pre-segwit activation:")
self.log.info("Running tests, pre-segwit activation:")
print("\tTesting SENDCMPCT p2p message... ")
self.log.info("Testing SENDCMPCT p2p message... ")
self.test_sendcmpct(self.nodes[0], self.test_node, 1)
sync_blocks(self.nodes)
self.test_sendcmpct(self.nodes[1], self.segwit_node, 2, old_node=self.old_node)
sync_blocks(self.nodes)
print("\tTesting compactblock construction...")
self.log.info("Testing compactblock construction...")
self.test_compactblock_construction(self.nodes[0], self.test_node, 1, False)
sync_blocks(self.nodes)
self.test_compactblock_construction(self.nodes[1], self.segwit_node, 2, False)
sync_blocks(self.nodes)
print("\tTesting compactblock requests... ")
self.log.info("Testing compactblock requests... ")
self.test_compactblock_requests(self.nodes[0], self.test_node, 1, False)
sync_blocks(self.nodes)
self.test_compactblock_requests(self.nodes[1], self.segwit_node, 2, False)
sync_blocks(self.nodes)
print("\tTesting getblocktxn requests...")
self.log.info("Testing getblocktxn requests...")
self.test_getblocktxn_requests(self.nodes[0], self.test_node, 1)
sync_blocks(self.nodes)
self.test_getblocktxn_requests(self.nodes[1], self.segwit_node, 2)
sync_blocks(self.nodes)
print("\tTesting getblocktxn handler...")
self.log.info("Testing getblocktxn handler...")
self.test_getblocktxn_handler(self.nodes[0], self.test_node, 1)
sync_blocks(self.nodes)
self.test_getblocktxn_handler(self.nodes[1], self.segwit_node, 2)
self.test_getblocktxn_handler(self.nodes[1], self.old_node, 1)
sync_blocks(self.nodes)
print("\tTesting compactblock requests/announcements not at chain tip...")
self.log.info("Testing compactblock requests/announcements not at chain tip...")
self.test_compactblocks_not_at_tip(self.nodes[0], self.test_node)
sync_blocks(self.nodes)
self.test_compactblocks_not_at_tip(self.nodes[1], self.segwit_node)
self.test_compactblocks_not_at_tip(self.nodes[1], self.old_node)
sync_blocks(self.nodes)
print("\tTesting handling of incorrect blocktxn responses...")
self.log.info("Testing handling of incorrect blocktxn responses...")
self.test_incorrect_blocktxn_response(self.nodes[0], self.test_node, 1)
sync_blocks(self.nodes)
self.test_incorrect_blocktxn_response(self.nodes[1], self.segwit_node, 2)
sync_blocks(self.nodes)
# End-to-end block relay tests
print("\tTesting end-to-end block relay...")
self.log.info("Testing end-to-end block relay...")
self.request_cb_announcements(self.test_node, self.nodes[0], 1)
self.request_cb_announcements(self.old_node, self.nodes[1], 1)
self.request_cb_announcements(self.segwit_node, self.nodes[1], 2)
self.test_end_to_end_block_relay(self.nodes[0], [self.segwit_node, self.test_node, self.old_node])
self.test_end_to_end_block_relay(self.nodes[1], [self.segwit_node, self.test_node, self.old_node])
print("\tTesting handling of invalid compact blocks...")
self.log.info("Testing handling of invalid compact blocks...")
self.test_invalid_tx_in_compactblock(self.nodes[0], self.test_node, False)
self.test_invalid_tx_in_compactblock(self.nodes[1], self.segwit_node, False)
self.test_invalid_tx_in_compactblock(self.nodes[1], self.old_node, False)
print("\tTesting reconstructing compact blocks from all peers...")
self.log.info("Testing reconstructing compact blocks from all peers...")
self.test_compactblock_reconstruction_multiple_peers(self.nodes[1], self.segwit_node, self.old_node)
sync_blocks(self.nodes)
# Advance to segwit activation
print ("\nAdvancing to segwit activation\n")
self.log.info("Advancing to segwit activation")
self.activate_segwit(self.nodes[1])
print ("Running tests, post-segwit activation...")
self.log.info("Running tests, post-segwit activation...")
print("\tTesting compactblock construction...")
self.log.info("Testing compactblock construction...")
self.test_compactblock_construction(self.nodes[1], self.old_node, 1, True)
self.test_compactblock_construction(self.nodes[1], self.segwit_node, 2, True)
sync_blocks(self.nodes)
print("\tTesting compactblock requests (unupgraded node)... ")
self.log.info("Testing compactblock requests (unupgraded node)... ")
self.test_compactblock_requests(self.nodes[0], self.test_node, 1, True)
print("\tTesting getblocktxn requests (unupgraded node)...")
self.log.info("Testing getblocktxn requests (unupgraded node)...")
self.test_getblocktxn_requests(self.nodes[0], self.test_node, 1)
# Need to manually sync node0 and node1, because post-segwit activation,
# node1 will not download blocks from node0.
print("\tSyncing nodes...")
self.log.info("Syncing nodes...")
assert(self.nodes[0].getbestblockhash() != self.nodes[1].getbestblockhash())
while (self.nodes[0].getblockcount() > self.nodes[1].getblockcount()):
block_hash = self.nodes[0].getblockhash(self.nodes[1].getblockcount()+1)
self.nodes[1].submitblock(self.nodes[0].getblock(block_hash, False))
assert_equal(self.nodes[0].getbestblockhash(), self.nodes[1].getbestblockhash())
print("\tTesting compactblock requests (segwit node)... ")
self.log.info("Testing compactblock requests (segwit node)... ")
self.test_compactblock_requests(self.nodes[1], self.segwit_node, 2, True)
print("\tTesting getblocktxn requests (segwit node)...")
self.log.info("Testing getblocktxn requests (segwit node)...")
self.test_getblocktxn_requests(self.nodes[1], self.segwit_node, 2)
sync_blocks(self.nodes)
print("\tTesting getblocktxn handler (segwit node should return witnesses)...")
self.log.info("Testing getblocktxn handler (segwit node should return witnesses)...")
self.test_getblocktxn_handler(self.nodes[1], self.segwit_node, 2)
self.test_getblocktxn_handler(self.nodes[1], self.old_node, 1)
@ -949,18 +949,18 @@ class CompactBlocksTest(BitcoinTestFramework): @@ -949,18 +949,18 @@ class CompactBlocksTest(BitcoinTestFramework):
# announcement to all peers.
# (Post-segwit activation, blocks won't propagate from node0 to node1
# automatically, so don't bother testing a block announced to node0.)
print("\tTesting end-to-end block relay...")
self.log.info("Testing end-to-end block relay...")
self.request_cb_announcements(self.test_node, self.nodes[0], 1)
self.request_cb_announcements(self.old_node, self.nodes[1], 1)
self.request_cb_announcements(self.segwit_node, self.nodes[1], 2)
self.test_end_to_end_block_relay(self.nodes[1], [self.segwit_node, self.test_node, self.old_node])
print("\tTesting handling of invalid compact blocks...")
self.log.info("Testing handling of invalid compact blocks...")
self.test_invalid_tx_in_compactblock(self.nodes[0], self.test_node, False)
self.test_invalid_tx_in_compactblock(self.nodes[1], self.segwit_node, True)
self.test_invalid_tx_in_compactblock(self.nodes[1], self.old_node, True)
print("\tTesting invalid index in cmpctblock message...")
self.log.info("Testing invalid index in cmpctblock message...")
self.test_invalid_cmpctblock_message()

4
qa/rpc-tests/p2p-feefilter.py

@ -53,8 +53,8 @@ class FeeFilterTest(BitcoinTestFramework): @@ -53,8 +53,8 @@ class FeeFilterTest(BitcoinTestFramework):
# Node1 will be used to generate txs which should be relayed from Node0
# to our test node
self.nodes = []
self.nodes.append(start_node(0, self.options.tmpdir, ["-debug", "-logtimemicros"]))
self.nodes.append(start_node(1, self.options.tmpdir, ["-debug", "-logtimemicros"]))
self.nodes.append(start_node(0, self.options.tmpdir))
self.nodes.append(start_node(1, self.options.tmpdir))
connect_nodes(self.nodes[0], 1)
def run_test(self):

4
qa/rpc-tests/p2p-leaktests.py

@ -32,7 +32,7 @