Skip to content

Commit

Permalink
Merge pull request #7335
Browse files Browse the repository at this point in the history
7777994 [qa] Fix pyton syntax in rpc tests (MarcoFalke)
  • Loading branch information
laanwj committed Jan 18, 2016
2 parents 5e00147 + 7777994 commit 3ec5bb0
Show file tree
Hide file tree
Showing 34 changed files with 80 additions and 129 deletions.
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 @@ -10,7 +10,7 @@
from test_framework.blocktools import create_coinbase, create_block
from test_framework.comptool import TestInstance, TestManager
from test_framework.script import CScript, OP_1NEGATE, OP_CHECKLOCKTIMEVERIFY, OP_DROP
from binascii import hexlify, unhexlify
from binascii import unhexlify
import cStringIO
import time

Expand Down
4 changes: 1 addition & 3 deletions qa/rpc-tests/bip65-cltv.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
import os
import shutil

class BIP65Test(BitcoinTestFramework):

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

# TODO: check that new CHECKLOCKTIMEVERIFY rules are enforced

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 @@ -10,7 +10,7 @@
from test_framework.blocktools import create_coinbase, create_block
from test_framework.comptool import TestInstance, TestManager
from test_framework.script import CScript
from binascii import hexlify, unhexlify
from binascii import unhexlify
import cStringIO
import time

Expand Down
4 changes: 1 addition & 3 deletions qa/rpc-tests/bipdersig.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
import os
import shutil

class BIP66Test(BitcoinTestFramework):

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

# TODO: check that new DERSIG rules are enforced

Expand Down
4 changes: 2 additions & 2 deletions qa/rpc-tests/blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# Test RPC calls related to blockchain state.
#

import decimal
from decimal import Decimal

from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
Expand Down Expand Up @@ -39,7 +39,7 @@ def run_test(self):
node = self.nodes[0]
res = node.gettxoutsetinfo()

assert_equal(res[u'total_amount'], decimal.Decimal('8725.00000000'))
assert_equal(res[u'total_amount'], Decimal('8725.00000000'))
assert_equal(res[u'transactions'], 200)
assert_equal(res[u'height'], 200)
assert_equal(res[u'txouts'], 200)
Expand Down
1 change: 1 addition & 0 deletions qa/rpc-tests/disablewallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *


class DisableWalletTest (BitcoinTestFramework):

def setup_chain(self):
Expand Down
2 changes: 0 additions & 2 deletions qa/rpc-tests/forknotify.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
import os
import shutil

class ForkNotifyTest(BitcoinTestFramework):

Expand Down
50 changes: 24 additions & 26 deletions qa/rpc-tests/fundrawtransaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
from pprint import pprint
from time import sleep

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

self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(),1.5);
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(),1.0);
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(),5.0);
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 1.5)
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 1.0)
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 5.0)

self.sync_all()
self.nodes[0].generate(1)
Expand Down Expand Up @@ -130,7 +128,7 @@ def run_test(self):
for aUtx in listunspent:
if aUtx['amount'] == 5.0:
utx = aUtx
break;
break

assert_equal(utx!=False, True)

Expand Down Expand Up @@ -159,7 +157,7 @@ def run_test(self):
for aUtx in listunspent:
if aUtx['amount'] == 5.0:
utx = aUtx
break;
break

assert_equal(utx!=False, True)

Expand Down Expand Up @@ -189,7 +187,7 @@ def run_test(self):
for aUtx in listunspent:
if aUtx['amount'] == 1.0:
utx = aUtx
break;
break

assert_equal(utx!=False, True)

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

assert_equal("Insufficient" in errorString, True);
assert("Insufficient" in errorString)



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

#create same transaction over sendtoaddress
txId = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 1.1);
txId = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 1.1)
signedFee = self.nodes[0].getrawmempool(True)[txId]['fee']

#compare fee
feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee);
feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee)
assert(feeDelta >= 0 and feeDelta <= feeTolerance)
############################################################

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

#compare fee
feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee);
feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee)
assert(feeDelta >= 0 and feeDelta <= feeTolerance)
############################################################

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

#create same transaction over sendtoaddress
txId = self.nodes[0].sendtoaddress(mSigObj, 1.1);
txId = self.nodes[0].sendtoaddress(mSigObj, 1.1)
signedFee = self.nodes[0].getrawmempool(True)[txId]['fee']

#compare fee
feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee);
feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee)
assert(feeDelta >= 0 and feeDelta <= feeTolerance)
############################################################

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

#create same transaction over sendtoaddress
txId = self.nodes[0].sendtoaddress(mSigObj, 1.1);
txId = self.nodes[0].sendtoaddress(mSigObj, 1.1)
signedFee = self.nodes[0].getrawmempool(True)[txId]['fee']

#compare fee
feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee);
feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee)
assert(feeDelta >= 0 and feeDelta <= feeTolerance)
############################################################

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


# send 1.2 BTC to msig addr
txId = self.nodes[0].sendtoaddress(mSigObj, 1.2);
txId = self.nodes[0].sendtoaddress(mSigObj, 1.2)
self.sync_all()
self.nodes[1].generate(1)
self.sync_all()
Expand Down Expand Up @@ -466,7 +464,7 @@ def run_test(self):

error = False
try:
self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), 1.2);
self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), 1.2)
except:
error = True
assert(error)
Expand Down Expand Up @@ -496,13 +494,13 @@ def run_test(self):
###############################################

#empty node1, send some small coins from node0 to node1
self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), self.nodes[1].getbalance(), "", "", True);
self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), self.nodes[1].getbalance(), "", "", True)
self.sync_all()
self.nodes[0].generate(1)
self.sync_all()

for i in range(0,20):
self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.01);
self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.01)
self.sync_all()
self.nodes[0].generate(1)
self.sync_all()
Expand All @@ -514,11 +512,11 @@ def run_test(self):
fundedTx = self.nodes[1].fundrawtransaction(rawTx)

#create same transaction over sendtoaddress
txId = self.nodes[1].sendmany("", outputs);
txId = self.nodes[1].sendmany("", outputs)
signedFee = self.nodes[1].getrawmempool(True)[txId]['fee']

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


Expand All @@ -527,13 +525,13 @@ def run_test(self):
#############################################

#again, empty node1, send some small coins from node0 to node1
self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), self.nodes[1].getbalance(), "", "", True);
self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), self.nodes[1].getbalance(), "", "", True)
self.sync_all()
self.nodes[0].generate(1)
self.sync_all()

for i in range(0,20):
self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.01);
self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.01)
self.sync_all()
self.nodes[0].generate(1)
self.sync_all()
Expand Down
4 changes: 2 additions & 2 deletions qa/rpc-tests/getchaintips.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def run_test (self):

# Split the network and build two chains of different lengths.
self.split_network ()
self.nodes[0].generate(10);
self.nodes[2].generate(20);
self.nodes[0].generate(10)
self.nodes[2].generate(20)
self.sync_all ()

tips = self.nodes[1].getchaintips ()
Expand Down
14 changes: 7 additions & 7 deletions qa/rpc-tests/httpbasics.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ def run_test(self):
conn = httplib.HTTPConnection(url.hostname, url.port)
conn.connect()
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
out1 = conn.getresponse().read();
out1 = conn.getresponse().read()
assert_equal('"error":null' in out1, True)
assert_equal(conn.sock!=None, True) #according to http/1.1 connection must still be open!

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

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

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

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

Expand Down
2 changes: 0 additions & 2 deletions qa/rpc-tests/invalidblockrequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
from test_framework.test_framework import ComparisonTestFramework
from test_framework.util import *
from test_framework.comptool import TestManager, TestInstance, RejectResult
from test_framework.mininode import *
from test_framework.blocktools import *
import logging
import copy
import time

Expand Down
4 changes: 0 additions & 4 deletions qa/rpc-tests/invalidtxrequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@
#

from test_framework.test_framework import ComparisonTestFramework
from test_framework.util import *
from test_framework.comptool import TestManager, TestInstance, RejectResult
from test_framework.mininode import *
from test_framework.blocktools import *
import logging
import copy
import time


Expand Down
2 changes: 1 addition & 1 deletion qa/rpc-tests/mempool_limit.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def run_test(self):

# by now, the tx should be evicted, check confirmation state
assert(txid not in self.nodes[0].getrawmempool())
txdata = self.nodes[0].gettransaction(txid);
txdata = self.nodes[0].gettransaction(txid)
assert(txdata['confirmations'] == 0) #confirmation should still be 0

if __name__ == '__main__':
Expand Down
Loading

0 comments on commit 3ec5bb0

Please sign in to comment.