Skip to content

Commit 7777994

Browse files
author
MarcoFalke
committed
[qa] Fix pyton syntax in rpc tests
1 parent 17ef279 commit 7777994

34 files changed

+80
-129
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from test_framework.blocktools import create_coinbase, create_block
1111
from test_framework.comptool import TestInstance, TestManager
1212
from test_framework.script import CScript, OP_1NEGATE, OP_CHECKLOCKTIMEVERIFY, OP_DROP
13-
from binascii import hexlify, unhexlify
13+
from binascii import unhexlify
1414
import cStringIO
1515
import time
1616

qa/rpc-tests/bip65-cltv.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
from test_framework.test_framework import BitcoinTestFramework
1111
from test_framework.util import *
12-
import os
13-
import shutil
1412

1513
class BIP65Test(BitcoinTestFramework):
1614

@@ -46,7 +44,7 @@ def run_test(self):
4644
self.nodes[2].generate(1)
4745
self.sync_all()
4846
if (self.nodes[0].getblockcount() != cnt + 851):
49-
raise AssertionFailure("Failed to mine a version=4 blocks")
47+
raise AssertionError("Failed to mine a version=4 blocks")
5048

5149
# TODO: check that new CHECKLOCKTIMEVERIFY rules are enforced
5250

qa/rpc-tests/bipdersig-p2p.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from test_framework.blocktools import create_coinbase, create_block
1111
from test_framework.comptool import TestInstance, TestManager
1212
from test_framework.script import CScript
13-
from binascii import hexlify, unhexlify
13+
from binascii import unhexlify
1414
import cStringIO
1515
import time
1616

qa/rpc-tests/bipdersig.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
from test_framework.test_framework import BitcoinTestFramework
1111
from test_framework.util import *
12-
import os
13-
import shutil
1412

1513
class BIP66Test(BitcoinTestFramework):
1614

@@ -46,7 +44,7 @@ def run_test(self):
4644
self.nodes[2].generate(1)
4745
self.sync_all()
4846
if (self.nodes[0].getblockcount() != cnt + 851):
49-
raise AssertionFailure("Failed to mine a version=3 blocks")
47+
raise AssertionError("Failed to mine a version=3 blocks")
5048

5149
# TODO: check that new DERSIG rules are enforced
5250

qa/rpc-tests/blockchain.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# Test RPC calls related to blockchain state.
88
#
99

10-
import decimal
10+
from decimal import Decimal
1111

1212
from test_framework.test_framework import BitcoinTestFramework
1313
from test_framework.util import (
@@ -39,7 +39,7 @@ def run_test(self):
3939
node = self.nodes[0]
4040
res = node.gettxoutsetinfo()
4141

42-
assert_equal(res[u'total_amount'], decimal.Decimal('8725.00000000'))
42+
assert_equal(res[u'total_amount'], Decimal('8725.00000000'))
4343
assert_equal(res[u'transactions'], 200)
4444
assert_equal(res[u'height'], 200)
4545
assert_equal(res[u'txouts'], 200)

qa/rpc-tests/disablewallet.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from test_framework.test_framework import BitcoinTestFramework
1111
from test_framework.util import *
1212

13+
1314
class DisableWalletTest (BitcoinTestFramework):
1415

1516
def setup_chain(self):

qa/rpc-tests/forknotify.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
from test_framework.test_framework import BitcoinTestFramework
1111
from test_framework.util import *
12-
import os
13-
import shutil
1412

1513
class ForkNotifyTest(BitcoinTestFramework):
1614

qa/rpc-tests/fundrawtransaction.py

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55

66
from test_framework.test_framework import BitcoinTestFramework
77
from test_framework.util import *
8-
from pprint import pprint
9-
from time import sleep
108

119
# Create one-input, one-output, no-fee transaction:
1210
class RawTransactionsTest(BitcoinTestFramework):
@@ -53,11 +51,11 @@ def run_test(self):
5351
watchonly_amount = 200
5452
self.nodes[3].importpubkey(watchonly_pubkey, "", True)
5553
watchonly_txid = self.nodes[0].sendtoaddress(watchonly_address, watchonly_amount)
56-
self.nodes[0].sendtoaddress(self.nodes[3].getnewaddress(), watchonly_amount / 10);
54+
self.nodes[0].sendtoaddress(self.nodes[3].getnewaddress(), watchonly_amount / 10)
5755

58-
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(),1.5);
59-
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(),1.0);
60-
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(),5.0);
56+
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 1.5)
57+
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 1.0)
58+
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 5.0)
6159

6260
self.sync_all()
6361
self.nodes[0].generate(1)
@@ -130,7 +128,7 @@ def run_test(self):
130128
for aUtx in listunspent:
131129
if aUtx['amount'] == 5.0:
132130
utx = aUtx
133-
break;
131+
break
134132

135133
assert_equal(utx!=False, True)
136134

@@ -159,7 +157,7 @@ def run_test(self):
159157
for aUtx in listunspent:
160158
if aUtx['amount'] == 5.0:
161159
utx = aUtx
162-
break;
160+
break
163161

164162
assert_equal(utx!=False, True)
165163

@@ -189,7 +187,7 @@ def run_test(self):
189187
for aUtx in listunspent:
190188
if aUtx['amount'] == 1.0:
191189
utx = aUtx
192-
break;
190+
break
193191

194192
assert_equal(utx!=False, True)
195193

@@ -314,7 +312,7 @@ def run_test(self):
314312
except JSONRPCException,e:
315313
errorString = e.error['message']
316314

317-
assert_equal("Insufficient" in errorString, True);
315+
assert("Insufficient" in errorString)
318316

319317

320318

@@ -326,11 +324,11 @@ def run_test(self):
326324
fundedTx = self.nodes[0].fundrawtransaction(rawTx)
327325

328326
#create same transaction over sendtoaddress
329-
txId = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 1.1);
327+
txId = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 1.1)
330328
signedFee = self.nodes[0].getrawmempool(True)[txId]['fee']
331329

332330
#compare fee
333-
feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee);
331+
feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee)
334332
assert(feeDelta >= 0 and feeDelta <= feeTolerance)
335333
############################################################
336334

@@ -341,11 +339,11 @@ def run_test(self):
341339
rawTx = self.nodes[0].createrawtransaction(inputs, outputs)
342340
fundedTx = self.nodes[0].fundrawtransaction(rawTx)
343341
#create same transaction over sendtoaddress
344-
txId = self.nodes[0].sendmany("", outputs);
342+
txId = self.nodes[0].sendmany("", outputs)
345343
signedFee = self.nodes[0].getrawmempool(True)[txId]['fee']
346344

347345
#compare fee
348-
feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee);
346+
feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee)
349347
assert(feeDelta >= 0 and feeDelta <= feeTolerance)
350348
############################################################
351349

@@ -368,11 +366,11 @@ def run_test(self):
368366
fundedTx = self.nodes[0].fundrawtransaction(rawTx)
369367

370368
#create same transaction over sendtoaddress
371-
txId = self.nodes[0].sendtoaddress(mSigObj, 1.1);
369+
txId = self.nodes[0].sendtoaddress(mSigObj, 1.1)
372370
signedFee = self.nodes[0].getrawmempool(True)[txId]['fee']
373371

374372
#compare fee
375-
feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee);
373+
feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee)
376374
assert(feeDelta >= 0 and feeDelta <= feeTolerance)
377375
############################################################
378376

@@ -401,11 +399,11 @@ def run_test(self):
401399
fundedTx = self.nodes[0].fundrawtransaction(rawTx)
402400

403401
#create same transaction over sendtoaddress
404-
txId = self.nodes[0].sendtoaddress(mSigObj, 1.1);
402+
txId = self.nodes[0].sendtoaddress(mSigObj, 1.1)
405403
signedFee = self.nodes[0].getrawmempool(True)[txId]['fee']
406404

407405
#compare fee
408-
feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee);
406+
feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee)
409407
assert(feeDelta >= 0 and feeDelta <= feeTolerance)
410408
############################################################
411409

@@ -424,7 +422,7 @@ def run_test(self):
424422

425423

426424
# send 1.2 BTC to msig addr
427-
txId = self.nodes[0].sendtoaddress(mSigObj, 1.2);
425+
txId = self.nodes[0].sendtoaddress(mSigObj, 1.2)
428426
self.sync_all()
429427
self.nodes[1].generate(1)
430428
self.sync_all()
@@ -466,7 +464,7 @@ def run_test(self):
466464

467465
error = False
468466
try:
469-
self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), 1.2);
467+
self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), 1.2)
470468
except:
471469
error = True
472470
assert(error)
@@ -496,13 +494,13 @@ def run_test(self):
496494
###############################################
497495

498496
#empty node1, send some small coins from node0 to node1
499-
self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), self.nodes[1].getbalance(), "", "", True);
497+
self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), self.nodes[1].getbalance(), "", "", True)
500498
self.sync_all()
501499
self.nodes[0].generate(1)
502500
self.sync_all()
503501

504502
for i in range(0,20):
505-
self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.01);
503+
self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.01)
506504
self.sync_all()
507505
self.nodes[0].generate(1)
508506
self.sync_all()
@@ -514,11 +512,11 @@ def run_test(self):
514512
fundedTx = self.nodes[1].fundrawtransaction(rawTx)
515513

516514
#create same transaction over sendtoaddress
517-
txId = self.nodes[1].sendmany("", outputs);
515+
txId = self.nodes[1].sendmany("", outputs)
518516
signedFee = self.nodes[1].getrawmempool(True)[txId]['fee']
519517

520518
#compare fee
521-
feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee);
519+
feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee)
522520
assert(feeDelta >= 0 and feeDelta <= feeTolerance*19) #~19 inputs
523521

524522

@@ -527,13 +525,13 @@ def run_test(self):
527525
#############################################
528526

529527
#again, empty node1, send some small coins from node0 to node1
530-
self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), self.nodes[1].getbalance(), "", "", True);
528+
self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), self.nodes[1].getbalance(), "", "", True)
531529
self.sync_all()
532530
self.nodes[0].generate(1)
533531
self.sync_all()
534532

535533
for i in range(0,20):
536-
self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.01);
534+
self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.01)
537535
self.sync_all()
538536
self.nodes[0].generate(1)
539537
self.sync_all()

qa/rpc-tests/getchaintips.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ def run_test (self):
2323

2424
# Split the network and build two chains of different lengths.
2525
self.split_network ()
26-
self.nodes[0].generate(10);
27-
self.nodes[2].generate(20);
26+
self.nodes[0].generate(10)
27+
self.nodes[2].generate(20)
2828
self.sync_all ()
2929

3030
tips = self.nodes[1].getchaintips ()

qa/rpc-tests/httpbasics.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ def run_test(self):
3636
conn = httplib.HTTPConnection(url.hostname, url.port)
3737
conn.connect()
3838
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
39-
out1 = conn.getresponse().read();
39+
out1 = conn.getresponse().read()
4040
assert_equal('"error":null' in out1, True)
4141
assert_equal(conn.sock!=None, True) #according to http/1.1 connection must still be open!
4242

4343
#send 2nd request without closing connection
4444
conn.request('POST', '/', '{"method": "getchaintips"}', headers)
45-
out2 = conn.getresponse().read();
45+
out2 = conn.getresponse().read()
4646
assert_equal('"error":null' in out1, True) #must also response with a correct json-rpc message
4747
assert_equal(conn.sock!=None, True) #according to http/1.1 connection must still be open!
4848
conn.close()
@@ -53,13 +53,13 @@ def run_test(self):
5353
conn = httplib.HTTPConnection(url.hostname, url.port)
5454
conn.connect()
5555
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
56-
out1 = conn.getresponse().read();
56+
out1 = conn.getresponse().read()
5757
assert_equal('"error":null' in out1, True)
5858
assert_equal(conn.sock!=None, True) #according to http/1.1 connection must still be open!
5959

6060
#send 2nd request without closing connection
6161
conn.request('POST', '/', '{"method": "getchaintips"}', headers)
62-
out2 = conn.getresponse().read();
62+
out2 = conn.getresponse().read()
6363
assert_equal('"error":null' in out1, True) #must also response with a correct json-rpc message
6464
assert_equal(conn.sock!=None, True) #according to http/1.1 connection must still be open!
6565
conn.close()
@@ -70,7 +70,7 @@ def run_test(self):
7070
conn = httplib.HTTPConnection(url.hostname, url.port)
7171
conn.connect()
7272
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
73-
out1 = conn.getresponse().read();
73+
out1 = conn.getresponse().read()
7474
assert_equal('"error":null' in out1, True)
7575
assert_equal(conn.sock!=None, False) #now the connection must be closed after the response
7676

@@ -82,7 +82,7 @@ def run_test(self):
8282
conn = httplib.HTTPConnection(urlNode1.hostname, urlNode1.port)
8383
conn.connect()
8484
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
85-
out1 = conn.getresponse().read();
85+
out1 = conn.getresponse().read()
8686
assert_equal('"error":null' in out1, True)
8787

8888
#node2 (third node) is running with standard keep-alive parameters which means keep-alive is on
@@ -93,7 +93,7 @@ def run_test(self):
9393
conn = httplib.HTTPConnection(urlNode2.hostname, urlNode2.port)
9494
conn.connect()
9595
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
96-
out1 = conn.getresponse().read();
96+
out1 = conn.getresponse().read()
9797
assert_equal('"error":null' in out1, True)
9898
assert_equal(conn.sock!=None, True) #connection must be closed because bitcoind should use keep-alive by default
9999

0 commit comments

Comments
 (0)