diff options
Diffstat (limited to 'qa')
-rwxr-xr-x | qa/pull-tester/rpc-tests.py | 20 | ||||
-rw-r--r-- | qa/rpc-tests/README.md | 4 | ||||
-rwxr-xr-x | qa/rpc-tests/blockchain.py | 52 | ||||
-rwxr-xr-x | qa/rpc-tests/fundrawtransaction.py | 10 | ||||
-rwxr-xr-x | qa/rpc-tests/httpbasics.py | 14 | ||||
-rwxr-xr-x | qa/rpc-tests/pruning.py | 5 |
6 files changed, 91 insertions, 14 deletions
diff --git a/qa/pull-tester/rpc-tests.py b/qa/pull-tester/rpc-tests.py index 09ee9a36a9..7e682d530a 100755 --- a/qa/pull-tester/rpc-tests.py +++ b/qa/pull-tester/rpc-tests.py @@ -38,7 +38,7 @@ for i in range(1,len(sys.argv)): buildDir = BUILDDIR os.environ["BITCOIND"] = buildDir + '/src/bitcoind' + EXEEXT os.environ["BITCOINCLI"] = buildDir + '/src/bitcoin-cli' + EXEEXT - + #Disable Windows tests by default if EXEEXT == ".exe" and "-win" not in opts: print "Win tests currently disabled. Use -win option to enable" @@ -67,6 +67,7 @@ testScripts = [ 'reindex.py', 'decodescript.py', 'p2p-fullblocktest.py', + 'blockchain.py', ] testScriptsExt = [ 'bip65-cltv.py', @@ -82,12 +83,11 @@ testScriptsExt = [ 'invalidateblock.py', 'keypool.py', 'receivedby.py', - 'rpcbind_test.py', -# 'script_test.py', +# 'rpcbind_test.py', #temporary, bug in libevent, see #6655 +# 'script_test.py', #used for manual comparison of 2 binaries 'smartfees.py', 'maxblocksinflight.py', 'invalidblockrequest.py', -# 'forknotify.py', 'p2p-acceptblock.py', 'mempool_packages.py', ] @@ -100,10 +100,10 @@ if(ENABLE_WALLET == 1 and ENABLE_UTILS == 1 and ENABLE_BITCOIND == 1): rpcTestDir = buildDir + '/qa/rpc-tests/' #Run Tests for i in range(len(testScripts)): - if (len(opts) == 0 or (len(opts) == 1 and "-win" in opts ) or '-extended' in opts + if (len(opts) == 0 or (len(opts) == 1 and "-win" in opts ) or '-extended' in opts or testScripts[i] in opts or re.sub(".py$", "", testScripts[i]) in opts ): - print "Running testscript " + testScripts[i] + "..." - subprocess.call(rpcTestDir + testScripts[i] + " --srcdir " + buildDir + '/src ' + passOn,shell=True) + print "Running testscript " + testScripts[i] + "..." + subprocess.check_call(rpcTestDir + testScripts[i] + " --srcdir " + buildDir + '/src ' + passOn,shell=True) #exit if help is called so we print just one set of instructions p = re.compile(" -h| --help") if p.match(passOn): @@ -111,9 +111,9 @@ if(ENABLE_WALLET == 1 and ENABLE_UTILS == 1 and ENABLE_BITCOIND == 1): #Run Extended Tests for i in range(len(testScriptsExt)): - if ('-extended' in opts or testScriptsExt[i] in opts + if ('-extended' in opts or testScriptsExt[i] in opts or re.sub(".py$", "", testScriptsExt[i]) in opts): - print "Running 2nd level testscript " + testScriptsExt[i] + "..." - subprocess.call(rpcTestDir + testScriptsExt[i] + " --srcdir " + buildDir + '/src ' + passOn,shell=True) + print "Running 2nd level testscript " + testScriptsExt[i] + "..." + subprocess.check_call(rpcTestDir + testScriptsExt[i] + " --srcdir " + buildDir + '/src ' + passOn,shell=True) else: print "No rpc tests to run. Wallet, utils, and bitcoind must all be enabled" diff --git a/qa/rpc-tests/README.md b/qa/rpc-tests/README.md index 3391ee03ae..d2db00362f 100644 --- a/qa/rpc-tests/README.md +++ b/qa/rpc-tests/README.md @@ -37,11 +37,11 @@ Helper functions for creating blocks and transactions. Notes ===== -You can run any single test by calling qa/pull-tester/rpc-tests.py <testname> +You can run any single test by calling `qa/pull-tester/rpc-tests.py <testname>`. Or you can run any combination of tests by calling `qa/pull-tester/rpc-tests.py <testname1> <testname2> <testname3> ...` -Run the regression test suite with `qa/pull-tester/rpc-tests.py' +Run the regression test suite with `qa/pull-tester/rpc-tests.py` Run all possible tests with `qa/pull-tester/rpc-tests.py -extended` diff --git a/qa/rpc-tests/blockchain.py b/qa/rpc-tests/blockchain.py new file mode 100755 index 0000000000..a5c98b777e --- /dev/null +++ b/qa/rpc-tests/blockchain.py @@ -0,0 +1,52 @@ +#!/usr/bin/env python2 +# Copyright (c) 2014 The Bitcoin Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. + +# +# Test RPC calls related to blockchain state. +# + +import decimal + +from test_framework.test_framework import BitcoinTestFramework +from test_framework.util import ( + initialize_chain, + assert_equal, + start_nodes, + connect_nodes_bi, +) + +class BlockchainTest(BitcoinTestFramework): + """ + Test blockchain-related RPC calls: + + - gettxoutsetinfo + + """ + + def setup_chain(self): + print("Initializing test directory " + self.options.tmpdir) + initialize_chain(self.options.tmpdir) + + def setup_network(self, split=False): + self.nodes = start_nodes(2, self.options.tmpdir) + connect_nodes_bi(self.nodes, 0, 1) + self.is_network_split = False + self.sync_all() + + 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'transactions'], 200) + assert_equal(res[u'height'], 200) + assert_equal(res[u'txouts'], 200) + assert_equal(res[u'bytes_serialized'], 13000), + assert_equal(len(res[u'bestblock']), 64) + assert_equal(len(res[u'hash_serialized']), 64) + + +if __name__ == '__main__': + BlockchainTest().main() diff --git a/qa/rpc-tests/fundrawtransaction.py b/qa/rpc-tests/fundrawtransaction.py index fc29789218..93d13faa06 100755 --- a/qa/rpc-tests/fundrawtransaction.py +++ b/qa/rpc-tests/fundrawtransaction.py @@ -28,7 +28,15 @@ class RawTransactionsTest(BitcoinTestFramework): def run_test(self): print "Mining blocks..." - feeTolerance = Decimal(0.00000002) #if the fee's positive delta is higher than this value tests will fail, neg. delta always fail the tests + + min_relay_tx_fee = self.nodes[0].getnetworkinfo()['relayfee'] + # if the fee's positive delta is higher than this value tests will fail, + # neg. delta always fail the tests. + # The size of the signature of every input may be at most 2 bytes larger + # than a minimum sized signature. + + # = 2 bytes * minRelayTxFeePerByte + feeTolerance = 2 * min_relay_tx_fee/1000 self.nodes[2].generate(1) self.sync_all() diff --git a/qa/rpc-tests/httpbasics.py b/qa/rpc-tests/httpbasics.py index b66533543d..7888114c54 100755 --- a/qa/rpc-tests/httpbasics.py +++ b/qa/rpc-tests/httpbasics.py @@ -97,5 +97,19 @@ class HTTPBasicsTest (BitcoinTestFramework): 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 + # Check excessive request size + conn = httplib.HTTPConnection(urlNode2.hostname, urlNode2.port) + conn.connect() + conn.request('GET', '/' + ('x'*1000), '', headers) + out1 = conn.getresponse() + assert_equal(out1.status, httplib.NOT_FOUND) + + conn = httplib.HTTPConnection(urlNode2.hostname, urlNode2.port) + conn.connect() + conn.request('GET', '/' + ('x'*10000), '', headers) + out1 = conn.getresponse() + assert_equal(out1.status, httplib.BAD_REQUEST) + + if __name__ == '__main__': HTTPBasicsTest ().main () diff --git a/qa/rpc-tests/pruning.py b/qa/rpc-tests/pruning.py index 2824c51ce7..21f8d69382 100755 --- a/qa/rpc-tests/pruning.py +++ b/qa/rpc-tests/pruning.py @@ -61,6 +61,9 @@ class PruneTest(BitcoinTestFramework): self.address[0] = self.nodes[0].getnewaddress() self.address[1] = self.nodes[1].getnewaddress() + # Determine default relay fee + self.relayfee = self.nodes[0].getnetworkinfo()["relayfee"] + connect_nodes(self.nodes[0], 1) connect_nodes(self.nodes[1], 2) connect_nodes(self.nodes[2], 0) @@ -239,7 +242,7 @@ class PruneTest(BitcoinTestFramework): outputs = {} t = self.utxo.pop() inputs.append({ "txid" : t["txid"], "vout" : t["vout"]}) - remchange = t["amount"] - Decimal("0.001000") + remchange = t["amount"] - 100*self.relayfee # Fee must be above min relay rate for 66kb tx outputs[address]=remchange # Create a basic transaction that will send change back to ourself after account for a fee # And then insert the 128 generated transaction outs in the middle rawtx[92] is where the # |