Skip to content

Commit c9755da

Browse files
committed
Use logging in individual tests
1 parent 19542fa commit c9755da

34 files changed

+212
-224
lines changed

qa/rpc-tests/abandonconflict.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,9 @@ def run_test(self):
159159
self.nodes[0].invalidateblock(self.nodes[0].getbestblockhash())
160160
newbalance = self.nodes[0].getbalance()
161161
#assert_equal(newbalance, balance - Decimal("10"))
162-
print("If balance has not declined after invalidateblock then out of mempool wallet tx which is no longer")
163-
print("conflicted has not resumed causing its inputs to be seen as spent. See Issue #7315")
164-
print(str(balance) + " -> " + str(newbalance) + " ?")
162+
self.log.info("If balance has not declined after invalidateblock then out of mempool wallet tx which is no longer")
163+
self.log.info("conflicted has not resumed causing its inputs to be seen as spent. See Issue #7315")
164+
self.log.info(str(balance) + " -> " + str(newbalance) + " ?")
165165

166166
if __name__ == '__main__':
167167
AbandonConflictTest().main()

qa/rpc-tests/bip68-sequence.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,26 +34,26 @@ def run_test(self):
3434
# Generate some coins
3535
self.nodes[0].generate(110)
3636

37-
print("Running test disable flag")
37+
self.log.info("Running test disable flag")
3838
self.test_disable_flag()
3939

40-
print("Running test sequence-lock-confirmed-inputs")
40+
self.log.info("Running test sequence-lock-confirmed-inputs")
4141
self.test_sequence_lock_confirmed_inputs()
4242

43-
print("Running test sequence-lock-unconfirmed-inputs")
43+
self.log.info("Running test sequence-lock-unconfirmed-inputs")
4444
self.test_sequence_lock_unconfirmed_inputs()
4545

46-
print("Running test BIP68 not consensus before versionbits activation")
46+
self.log.info("Running test BIP68 not consensus before versionbits activation")
4747
self.test_bip68_not_consensus()
4848

49-
print("Activating BIP68 (and 112/113)")
49+
self.log.info("Activating BIP68 (and 112/113)")
5050
self.activateCSV()
5151

52-
print("Verifying nVersion=2 transactions are standard.")
53-
print("Note that with current versions of bitcoin software, nVersion=2 transactions are always standard (independent of BIP68 activation status).")
52+
self.log.info("Verifying nVersion=2 transactions are standard.")
53+
self.log.info("Note that nVersion=2 transactions are always standard (independent of BIP68 activation status).")
5454
self.test_version2_relay()
5555

56-
print("Passed\n")
56+
self.log.info("Passed")
5757

5858
# Test that BIP68 is not in effect if tx version is 1, or if
5959
# the first sequence bit is set.

qa/rpc-tests/bumpfee.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def run_test(self):
4545
rbf_node_address = rbf_node.getnewaddress()
4646

4747
# fund rbf node with 10 coins of 0.001 btc (100,000 satoshis)
48-
print("Mining blocks...")
48+
self.log.info("Mining blocks...")
4949
peer_node.generate(110)
5050
self.sync_all()
5151
for i in range(25):
@@ -55,7 +55,7 @@ def run_test(self):
5555
self.sync_all()
5656
assert_equal(rbf_node.getbalance(), Decimal("0.025"))
5757

58-
print("Running tests")
58+
self.log.info("Running tests")
5959
dest_address = peer_node.getnewaddress()
6060
test_small_output_fails(rbf_node, dest_address)
6161
test_dust_to_fee(rbf_node, dest_address)
@@ -70,7 +70,7 @@ def run_test(self):
7070
test_unconfirmed_not_spendable(rbf_node, rbf_node_address)
7171
test_bumpfee_metadata(rbf_node, dest_address)
7272
test_locked_wallet_fails(rbf_node, dest_address)
73-
print("Success")
73+
self.log.info("Success")
7474

7575

7676
def test_simple_bumpfee_succeeds(rbf_node, peer_node, dest_address):

qa/rpc-tests/fundrawtransaction.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ def setup_network(self, split=False):
3434
self.sync_all()
3535

3636
def run_test(self):
37-
print("Mining blocks...")
38-
3937
min_relay_tx_fee = self.nodes[0].getnetworkinfo()['relayfee']
4038
# This test is not meant to test fee estimation and we'd like
4139
# to be sure all txs are sent at a consistent desired feerate

qa/rpc-tests/getblocktemplate_longpoll.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def __init__(self):
2929
self.setup_clean_chain = False
3030

3131
def run_test(self):
32-
print("Warning: this test will take about 70 seconds in the best case. Be patient.")
32+
self.log.info("Warning: this test will take about 70 seconds in the best case. Be patient.")
3333
self.nodes[0].generate(10)
3434
templat = self.nodes[0].getblocktemplate()
3535
longpollid = templat['longpollid']

qa/rpc-tests/importmulti.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def setup_network(self, split=False):
1717
self.is_network_split=False
1818

1919
def run_test (self):
20-
print ("Mining blocks...")
20+
self.log.info("Mining blocks...")
2121
self.nodes[0].generate(1)
2222
self.nodes[1].generate(1)
2323
timestamp = self.nodes[1].getblock(self.nodes[1].getbestblockhash())['mediantime']
@@ -48,7 +48,7 @@ def run_test (self):
4848
# RPC importmulti -----------------------------------------------
4949

5050
# Bitcoin Address
51-
print("Should import an address")
51+
self.log.info("Should import an address")
5252
address = self.nodes[0].validateaddress(self.nodes[0].getnewaddress())
5353
result = self.nodes[1].importmulti([{
5454
"scriptPubKey": {
@@ -64,7 +64,7 @@ def run_test (self):
6464
watchonly_address = address['address']
6565
watchonly_timestamp = timestamp
6666

67-
print("Should not import an invalid address")
67+
self.log.info("Should not import an invalid address")
6868
result = self.nodes[1].importmulti([{
6969
"scriptPubKey": {
7070
"address": "not valid address",
@@ -76,7 +76,7 @@ def run_test (self):
7676
assert_equal(result[0]['error']['message'], 'Invalid address')
7777

7878
# ScriptPubKey + internal
79-
print("Should import a scriptPubKey with internal flag")
79+
self.log.info("Should import a scriptPubKey with internal flag")
8080
address = self.nodes[0].validateaddress(self.nodes[0].getnewaddress())
8181
result = self.nodes[1].importmulti([{
8282
"scriptPubKey": address['scriptPubKey'],
@@ -90,7 +90,7 @@ def run_test (self):
9090
assert_equal(address_assert['timestamp'], timestamp)
9191

9292
# ScriptPubKey + !internal
93-
print("Should not import a scriptPubKey without internal flag")
93+
self.log.info("Should not import a scriptPubKey without internal flag")
9494
address = self.nodes[0].validateaddress(self.nodes[0].getnewaddress())
9595
result = self.nodes[1].importmulti([{
9696
"scriptPubKey": address['scriptPubKey'],
@@ -106,7 +106,7 @@ def run_test (self):
106106

107107

108108
# Address + Public key + !Internal
109-
print("Should import an address with public key")
109+
self.log.info("Should import an address with public key")
110110
address = self.nodes[0].validateaddress(self.nodes[0].getnewaddress())
111111
result = self.nodes[1].importmulti([{
112112
"scriptPubKey": {
@@ -123,7 +123,7 @@ def run_test (self):
123123

124124

125125
# ScriptPubKey + Public key + internal
126-
print("Should import a scriptPubKey with internal and with public key")
126+
self.log.info("Should import a scriptPubKey with internal and with public key")
127127
address = self.nodes[0].validateaddress(self.nodes[0].getnewaddress())
128128
request = [{
129129
"scriptPubKey": address['scriptPubKey'],
@@ -139,7 +139,7 @@ def run_test (self):
139139
assert_equal(address_assert['timestamp'], timestamp)
140140

141141
# ScriptPubKey + Public key + !internal
142-
print("Should not import a scriptPubKey without internal and with public key")
142+
self.log.info("Should not import a scriptPubKey without internal and with public key")
143143
address = self.nodes[0].validateaddress(self.nodes[0].getnewaddress())
144144
request = [{
145145
"scriptPubKey": address['scriptPubKey'],
@@ -156,7 +156,7 @@ def run_test (self):
156156
assert_equal('timestamp' in address_assert, False)
157157

158158
# Address + Private key + !watchonly
159-
print("Should import an address with private key")
159+
self.log.info("Should import an address with private key")
160160
address = self.nodes[0].validateaddress(self.nodes[0].getnewaddress())
161161
result = self.nodes[1].importmulti([{
162162
"scriptPubKey": {
@@ -172,7 +172,7 @@ def run_test (self):
172172
assert_equal(address_assert['timestamp'], timestamp)
173173

174174
# Address + Private key + watchonly
175-
print("Should not import an address with private key and with watchonly")
175+
self.log.info("Should not import an address with private key and with watchonly")
176176
address = self.nodes[0].validateaddress(self.nodes[0].getnewaddress())
177177
result = self.nodes[1].importmulti([{
178178
"scriptPubKey": {
@@ -191,7 +191,7 @@ def run_test (self):
191191
assert_equal('timestamp' in address_assert, False)
192192

193193
# ScriptPubKey + Private key + internal
194-
print("Should import a scriptPubKey with internal and with private key")
194+
self.log.info("Should import a scriptPubKey with internal and with private key")
195195
address = self.nodes[0].validateaddress(self.nodes[0].getnewaddress())
196196
result = self.nodes[1].importmulti([{
197197
"scriptPubKey": address['scriptPubKey'],
@@ -206,7 +206,7 @@ def run_test (self):
206206
assert_equal(address_assert['timestamp'], timestamp)
207207

208208
# ScriptPubKey + Private key + !internal
209-
print("Should not import a scriptPubKey without internal and with private key")
209+
self.log.info("Should not import a scriptPubKey without internal and with private key")
210210
address = self.nodes[0].validateaddress(self.nodes[0].getnewaddress())
211211
result = self.nodes[1].importmulti([{
212212
"scriptPubKey": address['scriptPubKey'],
@@ -233,7 +233,7 @@ def run_test (self):
233233
timestamp = self.nodes[1].getblock(self.nodes[1].getbestblockhash())['mediantime']
234234
transaction = self.nodes[1].gettransaction(transactionid)
235235

236-
print("Should import a p2sh")
236+
self.log.info("Should import a p2sh")
237237
result = self.nodes[1].importmulti([{
238238
"scriptPubKey": {
239239
"address": multi_sig_script['address']
@@ -261,7 +261,7 @@ def run_test (self):
261261
timestamp = self.nodes[1].getblock(self.nodes[1].getbestblockhash())['mediantime']
262262
transaction = self.nodes[1].gettransaction(transactionid)
263263

264-
print("Should import a p2sh with respective redeem script")
264+
self.log.info("Should import a p2sh with respective redeem script")
265265
result = self.nodes[1].importmulti([{
266266
"scriptPubKey": {
267267
"address": multi_sig_script['address']
@@ -289,7 +289,7 @@ def run_test (self):
289289
timestamp = self.nodes[1].getblock(self.nodes[1].getbestblockhash())['mediantime']
290290
transaction = self.nodes[1].gettransaction(transactionid)
291291

292-
print("Should import a p2sh with respective redeem script and private keys")
292+
self.log.info("Should import a p2sh with respective redeem script and private keys")
293293
result = self.nodes[1].importmulti([{
294294
"scriptPubKey": {
295295
"address": multi_sig_script['address']
@@ -316,7 +316,7 @@ def run_test (self):
316316
self.nodes[1].generate(1)
317317
transaction = self.nodes[1].gettransaction(transactionid)
318318

319-
print("Should import a p2sh with respective redeem script and private keys")
319+
self.log.info("Should import a p2sh with respective redeem script and private keys")
320320
result = self.nodes[1].importmulti([{
321321
"scriptPubKey": {
322322
"address": multi_sig_script['address']
@@ -332,7 +332,7 @@ def run_test (self):
332332

333333

334334
# Address + Public key + !Internal + Wrong pubkey
335-
print("Should not import an address with a wrong public key")
335+
self.log.info("Should not import an address with a wrong public key")
336336
address = self.nodes[0].validateaddress(self.nodes[0].getnewaddress())
337337
address2 = self.nodes[0].validateaddress(self.nodes[0].getnewaddress())
338338
result = self.nodes[1].importmulti([{
@@ -352,7 +352,7 @@ def run_test (self):
352352

353353

354354
# ScriptPubKey + Public key + internal + Wrong pubkey
355-
print("Should not import a scriptPubKey with internal and with a wrong public key")
355+
self.log.info("Should not import a scriptPubKey with internal and with a wrong public key")
356356
address = self.nodes[0].validateaddress(self.nodes[0].getnewaddress())
357357
address2 = self.nodes[0].validateaddress(self.nodes[0].getnewaddress())
358358
request = [{
@@ -372,7 +372,7 @@ def run_test (self):
372372

373373

374374
# Address + Private key + !watchonly + Wrong private key
375-
print("Should not import an address with a wrong private key")
375+
self.log.info("Should not import an address with a wrong private key")
376376
address = self.nodes[0].validateaddress(self.nodes[0].getnewaddress())
377377
address2 = self.nodes[0].validateaddress(self.nodes[0].getnewaddress())
378378
result = self.nodes[1].importmulti([{
@@ -392,7 +392,7 @@ def run_test (self):
392392

393393

394394
# ScriptPubKey + Private key + internal + Wrong private key
395-
print("Should not import a scriptPubKey with internal and with a wrong private key")
395+
self.log.info("Should not import a scriptPubKey with internal and with a wrong private key")
396396
address = self.nodes[0].validateaddress(self.nodes[0].getnewaddress())
397397
address2 = self.nodes[0].validateaddress(self.nodes[0].getnewaddress())
398398
result = self.nodes[1].importmulti([{
@@ -418,7 +418,7 @@ def run_test (self):
418418
assert_equal(address_assert['timestamp'], watchonly_timestamp);
419419

420420
# Bad or missing timestamps
421-
print("Should throw on invalid or missing timestamp values")
421+
self.log.info("Should throw on invalid or missing timestamp values")
422422
assert_raises_message(JSONRPCException, 'Missing required timestamp field for key',
423423
self.nodes[1].importmulti, [{
424424
"scriptPubKey": address['scriptPubKey'],

qa/rpc-tests/importprunedfunds.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def setup_network(self, split=False):
2121
self.sync_all()
2222

2323
def run_test(self):
24-
print("Mining blocks...")
24+
self.log.info("Mining blocks...")
2525
self.nodes[0].generate(101)
2626

2727
self.sync_all()

qa/rpc-tests/invalidateblock.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,46 +23,44 @@ def setup_network(self):
2323
self.nodes.append(start_node(2, self.options.tmpdir))
2424

2525
def run_test(self):
26-
print("Make sure we repopulate setBlockIndexCandidates after InvalidateBlock:")
27-
print("Mine 4 blocks on Node 0")
26+
self.log.info("Make sure we repopulate setBlockIndexCandidates after InvalidateBlock:")
27+
self.log.info("Mine 4 blocks on Node 0")
2828
self.nodes[0].generate(4)
2929
assert(self.nodes[0].getblockcount() == 4)
3030
besthash = self.nodes[0].getbestblockhash()
3131

32-
print("Mine competing 6 blocks on Node 1")
32+
self.log.info("Mine competing 6 blocks on Node 1")
3333
self.nodes[1].generate(6)
3434
assert(self.nodes[1].getblockcount() == 6)
3535

36-
print("Connect nodes to force a reorg")
36+
self.log.info("Connect nodes to force a reorg")
3737
connect_nodes_bi(self.nodes,0,1)
3838
sync_blocks(self.nodes[0:2])
3939
assert(self.nodes[0].getblockcount() == 6)
4040
badhash = self.nodes[1].getblockhash(2)
4141

42-
print("Invalidate block 2 on node 0 and verify we reorg to node 0's original chain")
42+
self.log.info("Invalidate block 2 on node 0 and verify we reorg to node 0's original chain")
4343
self.nodes[0].invalidateblock(badhash)
4444
newheight = self.nodes[0].getblockcount()
4545
newhash = self.nodes[0].getbestblockhash()
4646
if (newheight != 4 or newhash != besthash):
4747
raise AssertionError("Wrong tip for node0, hash %s, height %d"%(newhash,newheight))
4848

49-
print("\nMake sure we won't reorg to a lower work chain:")
49+
self.log.info("Make sure we won't reorg to a lower work chain:")
5050
connect_nodes_bi(self.nodes,1,2)
51-
print("Sync node 2 to node 1 so both have 6 blocks")
51+
self.log.info("Sync node 2 to node 1 so both have 6 blocks")
5252
sync_blocks(self.nodes[1:3])
5353
assert(self.nodes[2].getblockcount() == 6)
54-
print("Invalidate block 5 on node 1 so its tip is now at 4")
54+
self.log.info("Invalidate block 5 on node 1 so its tip is now at 4")
5555
self.nodes[1].invalidateblock(self.nodes[1].getblockhash(5))
5656
assert(self.nodes[1].getblockcount() == 4)
57-
print("Invalidate block 3 on node 2, so its tip is now 2")
57+
self.log.info("Invalidate block 3 on node 2, so its tip is now 2")
5858
self.nodes[2].invalidateblock(self.nodes[2].getblockhash(3))
5959
assert(self.nodes[2].getblockcount() == 2)
60-
print("..and then mine a block")
60+
self.log.info("..and then mine a block")
6161
self.nodes[2].generate(1)
62-
print("Verify all nodes are at the right height")
62+
self.log.info("Verify all nodes are at the right height")
6363
time.sleep(5)
64-
for i in range(3):
65-
print(i,self.nodes[i].getblockcount())
6664
assert(self.nodes[2].getblockcount() == 3)
6765
assert(self.nodes[0].getblockcount() == 4)
6866
node1height = self.nodes[1].getblockcount()

qa/rpc-tests/listsinceblock.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def run_test (self):
6262
# generate on both sides
6363
lastblockhash = self.nodes[1].generate(6)[5]
6464
self.nodes[2].generate(7)
65-
print('lastblockhash=%s' % (lastblockhash))
65+
self.log.info('lastblockhash=%s' % (lastblockhash))
6666

6767
self.sync_all()
6868

qa/rpc-tests/maxblocksinflight.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from test_framework.mininode import *
1414
from test_framework.test_framework import BitcoinTestFramework
1515
from test_framework.util import *
16-
import logging
1716

1817
MAX_REQUESTS = 128
1918

@@ -33,7 +32,6 @@ def on_close(self, conn):
3332

3433
def __init__(self):
3534
NodeConnCB.__init__(self)
36-
self.log = logging.getLogger("BlockRelayTest")
3735

3836
def add_new_connection(self, connection):
3937
self.connection = connection
@@ -65,7 +63,7 @@ def run(self):
6563
raise AssertionError("Error, test failed: block %064x requested more than once" % key)
6664
if total_requests > MAX_REQUESTS:
6765
raise AssertionError("Error, too many blocks (%d) requested" % total_requests)
68-
print("Round %d: success (total requests: %d)" % (count, total_requests))
66+
self.log.info("Round %d: success (total requests: %d)" % (count, total_requests))
6967

7068
self.disconnectOkay = True
7169
self.connection.disconnect_node()

0 commit comments

Comments
 (0)