Skip to content

Commit

Permalink
Merge bitcoin#9768: [qa] Add logging to test_framework.py
Browse files Browse the repository at this point in the history
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
  • Loading branch information
MarcoFalke committed Mar 9, 2017
2 parents 5703dff + 64c0800 commit 8910b47
Show file tree
Hide file tree
Showing 53 changed files with 398 additions and 394 deletions.
16 changes: 8 additions & 8 deletions qa/rpc-tests/abandonconflict.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def __init__(self):

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):
Expand Down Expand Up @@ -81,7 +81,7 @@ def run_test(self):
# 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)
Expand All @@ -107,7 +107,7 @@ def run_test(self):

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

Expand All @@ -127,7 +127,7 @@ def run_test(self):

# 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"))
Expand Down Expand Up @@ -158,9 +158,9 @@ def run_test(self):
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 changes: 3 additions & 3 deletions qa/rpc-tests/assumevalid.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def setup_network(self):
# 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):

Expand Down Expand Up @@ -146,14 +146,14 @@ def run_test(self):

# 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])
Expand Down
2 changes: 1 addition & 1 deletion qa/rpc-tests/bip65-cltv-p2p.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __init__(self):
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):
Expand Down
2 changes: 1 addition & 1 deletion qa/rpc-tests/bip68-112-113-p2p.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def __init__(self):
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):
Expand Down
20 changes: 10 additions & 10 deletions qa/rpc-tests/bip68-sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ def __init__(self):

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)
Expand All @@ -34,26 +34,26 @@ def run_test(self):
# 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.
Expand Down
2 changes: 1 addition & 1 deletion qa/rpc-tests/bip9-softforks.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __init__(self):

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):
Expand Down
2 changes: 1 addition & 1 deletion qa/rpc-tests/bipdersig-p2p.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def __init__(self):
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):
Expand Down
8 changes: 4 additions & 4 deletions qa/rpc-tests/bumpfee.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def __init__(self):
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)

Expand All @@ -45,7 +45,7 @@ def run_test(self):
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):
Expand All @@ -55,7 +55,7 @@ def run_test(self):
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)
Expand All @@ -70,7 +70,7 @@ def run_test(self):
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):
Expand Down
2 changes: 0 additions & 2 deletions qa/rpc-tests/fundrawtransaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ def setup_network(self, split=False):
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
Expand Down
2 changes: 1 addition & 1 deletion qa/rpc-tests/getblocktemplate_longpoll.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def __init__(self):
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']
Expand Down
12 changes: 6 additions & 6 deletions qa/rpc-tests/import-rescan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -117,7 +117,7 @@ def __init__(self):
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"]
Expand Down
Loading

0 comments on commit 8910b47

Please sign in to comment.