Browse Source

Use logging in individual tests

pull/1/head
John Newbery 6 years ago
parent
commit
64c080051b
  1. 6
      qa/rpc-tests/abandonconflict.py
  2. 16
      qa/rpc-tests/bip68-sequence.py
  3. 6
      qa/rpc-tests/bumpfee.py
  4. 2
      qa/rpc-tests/fundrawtransaction.py
  5. 2
      qa/rpc-tests/getblocktemplate_longpoll.py
  6. 42
      qa/rpc-tests/importmulti.py
  7. 2
      qa/rpc-tests/importprunedfunds.py
  8. 28
      qa/rpc-tests/invalidateblock.py
  9. 2
      qa/rpc-tests/listsinceblock.py
  10. 4
      qa/rpc-tests/maxblocksinflight.py
  11. 14
      qa/rpc-tests/maxuploadtarget.py
  12. 6
      qa/rpc-tests/mempool_packages.py
  13. 2
      qa/rpc-tests/merkle_blocks.py
  14. 12
      qa/rpc-tests/nulldummy.py
  15. 16
      qa/rpc-tests/p2p-acceptblock.py
  16. 46
      qa/rpc-tests/p2p-compactblocks.py
  17. 2
      qa/rpc-tests/p2p-leaktests.py
  18. 2
      qa/rpc-tests/p2p-segwit.py
  19. 32
      qa/rpc-tests/preciousblock.py
  20. 6
      qa/rpc-tests/prioritise_transaction.py
  21. 68
      qa/rpc-tests/pruning.py
  22. 2
      qa/rpc-tests/reindex.py
  23. 26
      qa/rpc-tests/replace-by-fee.py
  24. 2
      qa/rpc-tests/rest.py
  25. 2
      qa/rpc-tests/rpcbind_test.py
  26. 26
      qa/rpc-tests/segwit.py
  27. 20
      qa/rpc-tests/sendheaders.py
  28. 16
      qa/rpc-tests/smartfees.py
  29. 2
      qa/rpc-tests/wallet-hd.py
  30. 4
      qa/rpc-tests/wallet.py
  31. 16
      qa/rpc-tests/walletbackup.py
  32. 2
      qa/rpc-tests/zapwallettxes.py
  33. 2
      qa/rpc-tests/zmq_test.py

6
qa/rpc-tests/abandonconflict.py

@ -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()

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

@ -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.

6
qa/rpc-tests/bumpfee.py

@ -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']

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()

28
qa/rpc-tests/invalidateblock.py

@ -23,48 +23,46 @@ class InvalidateTest(BitcoinTestFramework): @@ -23,48 +23,46 @@ class InvalidateTest(BitcoinTestFramework):
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()

4
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()

14
qa/rpc-tests/maxuploadtarget.py

@ -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,12 +192,12 @@ class MaxUploadTest(BitcoinTestFramework): @@ -192,12 +192,12 @@ 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, ["-whitelist=127.0.0.1", "-maxuploadtarget=1", "-blockmaxsize=999000"])
@ -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]

6
qa/rpc-tests/mempool_packages.py

@ -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/merkle_blocks.py

@ -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()

12
qa/rpc-tests/nulldummy.py

@ -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)

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

@ -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 ]

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

@ -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()

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

@ -32,7 +32,7 @@ class CLazyNode(NodeConnCB): @@ -32,7 +32,7 @@ class CLazyNode(NodeConnCB):
def bad_message(self, message):
self.unexpected_msg = True
print("should not have received message: %s" % message.command)
self.log.info("should not have received message: %s" % message.command)
def on_open(self, conn):
self.connected = True

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

@ -1427,7 +1427,7 @@ class SegWitTest(BitcoinTestFramework): @@ -1427,7 +1427,7 @@ class SegWitTest(BitcoinTestFramework):
block = self.build_next_block()
if (not used_sighash_single_out_of_bounds):
print("WARNING: this test run didn't attempt SIGHASH_SINGLE with out-of-bounds index value")
self.log.info("WARNING: this test run didn't attempt SIGHASH_SINGLE with out-of-bounds index value")
# Test the transactions we've added to the block
if (len(block.vtx) > 1):
self.update_witness_block_with_transactions(block, [])

32
qa/rpc-tests/preciousblock.py

@ -44,7 +44,7 @@ class PreciousTest(BitcoinTestFramework): @@ -44,7 +44,7 @@ class PreciousTest(BitcoinTestFramework):
self.nodes = self.setup_nodes()
def run_test(self):
print("Ensure submitblock can in principle reorg to a competing chain")
self.log.info("Ensure submitblock can in principle reorg to a competing chain")
self.nodes[0].generate(1)
assert_equal(self.nodes[0].getblockcount(), 1)
(hashY, hashZ) = self.nodes[1].generate(2)
@ -52,62 +52,62 @@ class PreciousTest(BitcoinTestFramework): @@ -52,62 +52,62 @@ class PreciousTest(BitcoinTestFramework):
node_sync_via_rpc(self.nodes[0:3])
assert_equal(self.nodes[0].getbestblockhash(), hashZ)
print("Mine blocks A-B-C on Node 0")
self.log.info("Mine blocks A-B-C on Node 0")
(hashA, hashB, hashC) = self.nodes[0].generate(3)
assert_equal(self.nodes[0].getblockcount(), 5)
print("Mine competing blocks E-F-G on Node 1")
self.log.info("Mine competing blocks E-F-G on Node 1")
(hashE, hashF, hashG) = self.nodes[1].generate(3)
assert_equal(self.nodes[1].getblockcount(), 5)
assert(hashC != hashG)
print("Connect nodes and check no reorg occurs")
self.log.info("Connect nodes and check no reorg occurs")
# Submit competing blocks via RPC so any reorg should occur before we proceed (no way to wait on inaction for p2p sync)
node_sync_via_rpc(self.nodes[0:2])
connect_nodes_bi(self.nodes,0,1)
assert_equal(self.nodes[0].getbestblockhash(), hashC)
assert_equal(self.nodes[1].getbestblockhash(), hashG)
print("Make Node0 prefer block G")
self.log.info("Make Node0 prefer block G")
self.nodes[0].preciousblock(hashG)
assert_equal(self.nodes[0].getbestblockhash(), hashG)
print("Make Node0 prefer block C again")
self.log.info("Make Node0 prefer block C again")
self.nodes[0].preciousblock(hashC)
assert_equal(self.nodes[0].getbestblockhash(), hashC)
print("Make Node1 prefer block C")
self.log.info("Make Node1 prefer block C")
self.nodes[1].preciousblock(hashC)
sync_chain(self.nodes[0:2]) # wait because node 1 may not have downloaded hashC
assert_equal(self.nodes[1].getbestblockhash(), hashC)
print("Make Node1 prefer block G again")
self.log.info("Make Node1 prefer block G again")
self.nodes[1].preciousblock(hashG)
assert_equal(self.nodes[1].getbestblockhash(), hashG)
print("Make Node0 prefer block G again")
self.log.info("Make Node0 prefer block G again")
self.nodes[0].preciousblock(hashG)
assert_equal(self.nodes[0].getbestblockhash(), hashG)
print("Make Node1 prefer block C again")
self.log.info("Make Node1 prefer block C again")
self.nodes[1].preciousblock(hashC)
assert_equal(self.nodes[1].getbestblockhash(), hashC)
print("Mine another block (E-F-G-)H on Node 0 and reorg Node 1")
self.log.info("Mine another block (E-F-G-)H on Node 0 and reorg Node 1")
self.nodes[0].generate(1)
assert_equal(self.nodes[0].getblockcount(), 6)
sync_blocks(self.nodes[0:2])
hashH = self.nodes[0].getbestblockhash()
assert_equal(self.nodes[1].getbestblockhash(), hashH)
print("Node1 should not be able to prefer block C anymore")
self.log.info("Node1 should not be able to prefer block C anymore")
self.nodes[1].preciousblock(hashC)
assert_equal(self.nodes[1].getbestblockhash(), hashH)
print("Mine competing blocks I-J-K-L on Node 2")
self.log.info("Mine competing blocks I-J-K-L on Node 2")
self.nodes[2].generate(4)
assert_equal(self.nodes[2].getblockcount(), 6)
hashL = self.nodes[2].getbestblockhash()
print("Connect nodes and check no reorg occurs")
self.log.info("Connect nodes and check no reorg occurs")
node_sync_via_rpc(self.nodes[1:3])
connect_nodes_bi(self.nodes,1,2)
connect_nodes_bi(self.nodes,0,2)
assert_equal(self.nodes[0].getbestblockhash(), hashH)
assert_equal(self.nodes[1].getbestblockhash(), hashH)
assert_equal(self.nodes[2].getbestblockhash(), hashL)
print("Make Node1 prefer block L")
self.log.info("Make Node1 prefer block L")
self.nodes[1].preciousblock(hashL)
assert_equal(self.nodes[1].getbestblockhash(), hashL)
print("Make Node2 prefer block H")
self.log.info("Make Node2 prefer block H")
self.nodes[2].preciousblock(hashH)
assert_equal(self.nodes[2].getbestblockhash(), hashH)

6
qa/rpc-tests/prioritise_transaction.py

@ -56,7 +56,7 @@ class PrioritiseTransactionTest(BitcoinTestFramework): @@ -56,7 +56,7 @@ class PrioritiseTransactionTest(BitcoinTestFramework):
self.nodes[0].generate(1)
mempool = self.nodes[0].getrawmempool()
print("Assert that prioritised transaction was mined")
self.log.info("Assert that prioritised transaction was mined")
assert(txids[0][0] not in mempool)
assert(txids[0][1] in mempool)
@ -88,7 +88,7 @@ class PrioritiseTransactionTest(BitcoinTestFramework): @@ -88,7 +88,7 @@ class PrioritiseTransactionTest(BitcoinTestFramework):
# High fee transaction should not have been mined, but other high fee rate
# transactions should have been.
mempool = self.nodes[0].getrawmempool()
print("Assert that de-prioritised transaction is still in mempool")
self.log.info("Assert that de-prioritised transaction is still in mempool")
assert(high_fee_tx in mempool)
for x in txids[2]:
if (x != high_fee_tx):
@ -120,7 +120,7 @@ class PrioritiseTransactionTest(BitcoinTestFramework): @@ -120,7 +120,7 @@ class PrioritiseTransactionTest(BitcoinTestFramework):
# accepted.
self.nodes[0].prioritisetransaction(tx_id, int(self.relayfee*COIN))
print("Assert that prioritised free transaction is accepted to mempool")
self.log.info("Assert that prioritised free transaction is accepted to mempool")
assert_equal(self.nodes[0].sendrawtransaction(tx_hex), tx_id)
assert(tx_id in self.nodes[0].getrawmempool())

68
qa/rpc-tests/pruning.py

@ -79,9 +79,9 @@ class PruneTest(BitcoinTestFramework): @@ -79,9 +79,9 @@ class PruneTest(BitcoinTestFramework):
def test_height_min(self):
if not os.path.isfile(self.prunedir+"blk00000.dat"):
raise AssertionError("blk00000.dat is missing, pruning too early")
print("Success")
print("Though we're already using more than 550MiB, current usage:", calc_usage(self.prunedir))
print("Mining 25 more blocks should cause the first block file to be pruned")
self.log.info("Success")
self.log.info("Though we're already using more than 550MiB, current usage:", calc_usage(self.prunedir))
self.log.info("Mining 25 more blocks should cause the first block file to be pruned")
# Pruning doesn't run until we're allocating another chunk, 20 full blocks past the height cutoff will ensure this
for i in range(25):
mine_large_block(self.nodes[0], self.utxo_cache_0)
@ -92,15 +92,15 @@ class PruneTest(BitcoinTestFramework): @@ -92,15 +92,15 @@ class PruneTest(BitcoinTestFramework):
if time.time() - waitstart > 30:
raise AssertionError("blk00000.dat not pruned when it should be")
print("Success")
self.log.info("Success")
usage = calc_usage(self.prunedir)
print("Usage should be below target:", usage)
self.log.info("Usage should be below target:", usage)
if (usage > 550):
raise AssertionError("Pruning target not being met")
def create_chain_with_staleblocks(self):
# Create stale blocks in manageable sized chunks
print("Mine 24 (stale) blocks on Node 1, followed by 25 (main chain) block reorg from Node 0, for 12 rounds")
self.log.info("Mine 24 (stale) blocks on Node 1, followed by 25 (main chain) block reorg from Node 0, for 12 rounds")
for j in range(12):
# Disconnect node 0 so it can mine a longer reorg chain without knowing about node 1's soon-to-be-stale chain
@ -124,7 +124,7 @@ class PruneTest(BitcoinTestFramework): @@ -124,7 +124,7 @@ class PruneTest(BitcoinTestFramework):
connect_nodes(self.nodes[2], 0)
sync_blocks(self.nodes[0:3])
print("Usage can be over target because of high stale rate:", calc_usage(self.prunedir))
self.log.info("Usage can be over target because of high stale rate:", calc_usage(self.prunedir))
def reorg_test(self):
# Node 1 will mine a 300 block chain starting 287 blocks back from Node 0 and Node 2's tip
@ -135,11 +135,11 @@ class PruneTest(BitcoinTestFramework): @@ -135,11 +135,11 @@ class PruneTest(BitcoinTestFramework):
self.nodes[1]=start_node(1, self.options.tmpdir, ["-maxreceivebuffer=20000","-blockmaxsize=5000", "-checkblocks=5", "-disablesafemode"], timewait=900)
height = self.nodes[1].getblockcount()
print("Current block height:", height)
self.log.info("Current block height:", height)
invalidheight = height-287
badhash = self.nodes[1].getblockhash(invalidheight)
print("Invalidating block at height:",invalidheight,badhash)
self.log.info("Invalidating block at height:",invalidheight,badhash)
self.nodes[1].invalidateblock(badhash)
# We've now switched to our previously mined-24 block fork on node 1, but thats not what we want
@ -151,24 +151,24 @@ class PruneTest(BitcoinTestFramework): @@ -151,24 +151,24 @@ class PruneTest(BitcoinTestFramework):
curhash = self.nodes[1].getblockhash(invalidheight - 1)
assert(self.nodes[1].getblockcount() == invalidheight - 1)
print("New best height", self.nodes[1].getblockcount())
self.log.info("New best height", self.nodes[1].getblockcount())
# Reboot node1 to clear those giant tx's from mempool
self.stop_node(1)
self.nodes[1]=start_node(1, self.options.tmpdir, ["-maxreceivebuffer=20000","-blockmaxsize=5000", "-checkblocks=5", "-disablesafemode"], timewait=900)
print("Generating new longer chain of 300 more blocks")
self.log.info("Generating new longer chain of 300 more blocks")
self.nodes[1].generate(300)
print("Reconnect nodes")
self.log.info("Reconnect nodes")
connect_nodes(self.nodes[0], 1)
connect_nodes(self.nodes[2], 1)
sync_blocks(self.nodes[0:3], timeout=120)
print("Verify height on node 2:",self.nodes[2].getblockcount())
print("Usage possibly still high bc of stale blocks in block files:", calc_usage(self.prunedir))
self.log.info("Verify height on node 2:",self.nodes[2].getblockcount())
self.log.info("Usage possibly still high bc of stale blocks in block files:", calc_usage(self.prunedir))
print("Mine 220 more blocks so we have requisite history (some blocks will be big and cause pruning of previous chain)")
self.log.info("Mine 220 more blocks so we have requisite history (some blocks will be big and cause pruning of previous chain)")
for i in range(22):
# This can be slow, so do this in multiple RPC calls to avoid
# RPC timeouts.
@ -176,7 +176,7 @@ class PruneTest(BitcoinTestFramework): @@ -176,7 +176,7 @@ class PruneTest(BitcoinTestFramework):
sync_blocks(self.nodes[0:3], timeout=300)
usage = calc_usage(self.prunedir)
print("Usage should be below target:", usage)
self.log.info("Usage should be below target:", usage)
if (usage > 550):
raise AssertionError("Pruning target not being met")
@ -185,7 +185,7 @@ class PruneTest(BitcoinTestFramework): @@ -185,7 +185,7 @@ class PruneTest(BitcoinTestFramework):
def reorg_back(self):
# Verify that a block on the old main chain fork has been pruned away
assert_raises_jsonrpc(-1, "Block not available (pruned data)", self.nodes[2].getblock, self.forkhash)
print("Will need to redownload block",self.forkheight)
self.log.info("Will need to redownload block",self.forkheight)
# Verify that we have enough history to reorg back to the fork point
# Although this is more than 288 blocks, because this chain was written more recently
@ -209,14 +209,14 @@ class PruneTest(BitcoinTestFramework): @@ -209,14 +209,14 @@ class PruneTest(BitcoinTestFramework):
# At this point node 2 is within 288 blocks of the fork point so it will preserve its ability to reorg
if self.nodes[2].getblockcount() < self.mainchainheight:
blocks_to_mine = first_reorg_height + 1 - self.mainchainheight
print("Rewind node 0 to prev main chain to mine longer chain to trigger redownload. Blocks needed:", blocks_to_mine)
self.log.info("Rewind node 0 to prev main chain to mine longer chain to trigger redownload. Blocks needed:", blocks_to_mine)
self.nodes[0].invalidateblock(curchainhash)
assert(self.nodes[0].getblockcount() == self.mainchainheight)
assert(self.nodes[0].getbestblockhash() == self.mainchainhash2)
goalbesthash = self.nodes[0].generate(blocks_to_mine)[-1]
goalbestheight = first_reorg_height + 1
print("Verify node 2 reorged back to the main chain, some blocks of which it had to redownload")
self.log.info("Verify node 2 reorged back to the main chain, some blocks of which it had to redownload")
waitstart = time.time()
while self.nodes[2].getblockcount() < goalbestheight:
time.sleep(0.1)
@ -310,28 +310,28 @@ class PruneTest(BitcoinTestFramework): @@ -310,28 +310,28 @@ class PruneTest(BitcoinTestFramework):
self.stop_node(node_number)
self.nodes[node_number] = start_node(node_number, self.options.tmpdir, ["-prune=550"], timewait=900)
print("Success")
self.log.info("Success")
def wallet_test(self):
# check that the pruning node's wallet is still in good shape
print("Stop and start pruning node to trigger wallet rescan")
self.log.info("Stop and start pruning node to trigger wallet rescan")
self.stop_node(2)
start_node(2, self.options.tmpdir, ["-prune=550"])
print("Success")
self.log.info("Success")
# check that wallet loads loads successfully when restarting a pruned node after IBD.
# this was reported to fail in #7494.
print ("Syncing node 5 to test wallet")
self.log.info("Syncing node 5 to test wallet")
connect_nodes(self.nodes[0], 5)
nds = [self.nodes[0], self.nodes[5]]
sync_blocks(nds, wait=5, timeout=300)
self.stop_node(5) #stop and start to trigger rescan
start_node(5, self.options.tmpdir, ["-prune=550"])
print ("Success")
self.log.info("Success")
def run_test(self):
print("Warning! This test requires 4GB of disk space and takes over 30 mins (up to 2 hours)")
print("Mining a big blockchain of 995 blocks")
self.log.info("Warning! This test requires 4GB of disk space and takes over 30 mins (up to 2 hours)")
self.log.info("Mining a big blockchain of 995 blocks")
self.create_big_chain()
# Chain diagram key:
# * blocks on main chain
@ -346,12 +346,12 @@ class PruneTest(BitcoinTestFramework): @@ -346,12 +346,12 @@ class PruneTest(BitcoinTestFramework):
self.stop_node(3)
self.stop_node(4)
print("Check that we haven't started pruning yet because we're below PruneAfterHeight")
self.log.info("Check that we haven't started pruning yet because we're below PruneAfterHeight")
self.test_height_min()
# Extend this chain past the PruneAfterHeight
# N0=N1=N2 **...*(1020)
print("Check that we'll exceed disk space target if we have a very high stale block rate")
self.log.info("Check that we'll exceed disk space target if we have a very high stale block rate")
self.create_chain_with_staleblocks()
# Disconnect N0
# And mine a 24 block chain on N1 and a separate 25 block chain on N0
@ -375,7 +375,7 @@ class PruneTest(BitcoinTestFramework): @@ -375,7 +375,7 @@ class PruneTest(BitcoinTestFramework):
self.mainchainheight = self.nodes[2].getblockcount() #1320
self.mainchainhash2 = self.nodes[2].getblockhash(self.mainchainheight)
print("Check that we can survive a 288 block reorg still")
self.log.info("Check that we can survive a 288 block reorg still")
(self.forkheight,self.forkhash) = self.reorg_test() #(1033, )
# Now create a 288 block reorg by mining a longer chain on N1
# First disconnect N1
@ -408,7 +408,7 @@ class PruneTest(BitcoinTestFramework): @@ -408,7 +408,7 @@ class PruneTest(BitcoinTestFramework):
# \
# *...**(1320)
print("Test that we can rerequest a block we previously pruned if needed for a reorg")
self.log.info("Test that we can rerequest a block we previously pruned if needed for a reorg")
self.reorg_back()
# Verify that N2 still has block 1033 on current chain (@), but not on main chain (*)
# Invalidate 1033 on current chain (@) on N2 and we should be able to reorg to
@ -428,16 +428,16 @@ class PruneTest(BitcoinTestFramework): @@ -428,16 +428,16 @@ class PruneTest(BitcoinTestFramework):
#
# N1 doesn't change because 1033 on main chain (*) is invalid
print("Test manual pruning with block indices")
self.log.info("Test manual pruning with block indices")
self.manual_test(3, use_timestamp=False)
print("Test manual pruning with timestamps")
self.log.info("Test manual pruning with timestamps")
self.manual_test(4, use_timestamp=True)
print("Test wallet re-scan")
self.log.info("Test wallet re-scan")
self.wallet_test()
print("Done")
self.log.info("Done")
if __name__ == '__main__':
PruneTest().main()

2
qa/rpc-tests/reindex.py

@ -36,7 +36,7 @@ class ReindexTest(BitcoinTestFramework): @@ -36,7 +36,7 @@ class ReindexTest(BitcoinTestFramework):
while self.nodes[0].getblockcount() < blockcount:
time.sleep(0.1)
assert_equal(self.nodes[0].getblockcount(), blockcount)
print("Success")
self.log.