aboutsummaryrefslogtreecommitdiff
path: root/qa/rpc-tests/test_framework.py
diff options
context:
space:
mode:
authorSuhas Daftuar <sdaftuar@gmail.com>2015-04-28 12:39:47 -0400
committerSuhas Daftuar <sdaftuar@gmail.com>2015-04-28 12:40:56 -0400
commitb93974c3f32a5398a94db275cd23b7ff78f269bf (patch)
tree315905c0afd9b8f8d4bec71f71b9d2f9b29d4f95 /qa/rpc-tests/test_framework.py
parent6c1d1ba6fccd76e3690bac8341687c0921758e30 (diff)
downloadbitcoin-b93974c3f32a5398a94db275cd23b7ff78f269bf.tar.xz
Add comparison tool test runner, built on mininode
comptool.py creates a tool for running a test suite on top of the mininode p2p framework. It supports two types of tests: those for which we expect certain behavior (acceptance or rejection of a block or transaction) and those for which we are just comparing that the behavior of 2 or more nodes is the same. blockstore.py defines BlockStore and TxStore, which provide db-backed maps between block/tx hashes and the corresponding block or tx. blocktools.py defines utility functions for creating and manipulating blocks and transactions. invalidblockrequest.py is an example test in the comptool framework, which tests the behavior of a single node when sent two different types of invalid blocks (a block with a duplicated transaction and a block with a bad coinbase value).
Diffstat (limited to 'qa/rpc-tests/test_framework.py')
-rwxr-xr-xqa/rpc-tests/test_framework.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/qa/rpc-tests/test_framework.py b/qa/rpc-tests/test_framework.py
index 4c8a11b821..f61b13dfe6 100755
--- a/qa/rpc-tests/test_framework.py
+++ b/qa/rpc-tests/test_framework.py
@@ -140,3 +140,32 @@ class BitcoinTestFramework(object):
else:
print("Failed")
sys.exit(1)
+
+
+# Test framework for doing p2p comparison testing, which sets up some bitcoind
+# binaries:
+# 1 binary: test binary
+# 2 binaries: 1 test binary, 1 ref binary
+# n>2 binaries: 1 test binary, n-1 ref binaries
+
+class ComparisonTestFramework(BitcoinTestFramework):
+
+ # Can override the num_nodes variable to indicate how many nodes to run.
+ def __init__(self):
+ self.num_nodes = 2
+
+ def add_options(self, parser):
+ parser.add_option("--testbinary", dest="testbinary", default="bitcoind",
+ help="bitcoind binary to test")
+ parser.add_option("--refbinary", dest="refbinary", default="bitcoind",
+ help="bitcoind binary to use for reference nodes (if any)")
+
+ def setup_chain(self):
+ print "Initializing test directory "+self.options.tmpdir
+ initialize_chain_clean(self.options.tmpdir, self.num_nodes)
+
+ def setup_network(self):
+ self.nodes = start_nodes(self.num_nodes, self.options.tmpdir,
+ extra_args=[['-debug', '-whitelist=127.0.0.1']] * self.num_nodes,
+ binary=[self.options.testbinary] +
+ [self.options.refbinary]*(self.num_nodes-1))