From ec6811d60fbf61680d2b01ab3d2056d46b5d8cf5 Mon Sep 17 00:00:00 2001 From: Anton Lysakov Date: Wed, 21 Nov 2018 15:55:53 +0600 Subject: [PATCH] initial version of multi-nodes testing --- qa/rpc-tests/cryptoconditions.py | 40 ++++++++++++++++++++++++----- qa/rpc-tests/test_framework/util.py | 21 +++++++++++---- 2 files changed, 49 insertions(+), 12 deletions(-) diff --git a/qa/rpc-tests/cryptoconditions.py b/qa/rpc-tests/cryptoconditions.py index 1d2f68777..7fade6c4f 100755 --- a/qa/rpc-tests/cryptoconditions.py +++ b/qa/rpc-tests/cryptoconditions.py @@ -30,7 +30,7 @@ class CryptoConditionsTest (BitcoinTestFramework): def setup_chain(self): print("Initializing CC test directory "+self.options.tmpdir) - self.num_nodes = 1 + self.num_nodes = 2 initialize_chain_clean(self.options.tmpdir, self.num_nodes) def setup_network(self, split = False): @@ -38,6 +38,9 @@ class CryptoConditionsTest (BitcoinTestFramework): self.addr = "RWPg8B91kfK5UtUN7z6s6TeV9cHSGtVY8D" self.pubkey = "02676d00110c2cd14ae24f95969e8598f7ccfaa675498b82654a5b5bd57fc1d8cf" self.privkey = "UqMgxk7ySPNQ4r9nKAFPjkXy6r5t898yhuNCjSZJLg3RAM4WW1m9" + self.addr1 = "RXEXoa1nRmKhMbuZovpcYwQMsicwzccZBp" + self.pubkey1 = "024026d4ad4ecfc1f705a9b42ca64af6d2ad947509c085534a30b8861d756c6ff0" + self.privkey1 = "UtdydP56pGTFmawHzHr1wDrc4oUwCNW1ttX8Pc3KrvH3MA8P49Wi" self.nodes = start_nodes(self.num_nodes, self.options.tmpdir, extra_args=[[ # always give -ac_name as first extra_arg @@ -57,10 +60,28 @@ class CryptoConditionsTest (BitcoinTestFramework): '-daemon', '-rpcuser=rt', '-rpcpassword=rt' - ]] + ], + ['-ac_name=REGTEST', + '-conf='+self.options.tmpdir+'/node1/REGTEST.conf', + '-port=64365', + '-rpcport=64366', + '-regtest', + '-addressindex=1', + '-spentindex=1', + '-ac_supply=5555555', + '-ac_reward=10000000', + '-pubkey=' + self.pubkey1, + '-ac_cc=2', + '-whitelist=127.0.0.1', + '-debug', + '-addnode=127.0.0.1:64367', + '-daemon', + '-rpcuser=rt', + '-rpcpassword=rt']] ) self.is_network_split = split self.rpc = self.nodes[0] + self.rpc1 = self.nodes[1] self.sync_all() print("Done setting up network") @@ -590,6 +611,10 @@ class CryptoConditionsTest (BitcoinTestFramework): def run_oracles_tests(self): rpc = self.nodes[0] + rpc1 = self.nodes[1] + + result = rpc1.oraclesaddress() + result = rpc.oraclesaddress() assert_success(result) for x in ['OraclesCCaddress', 'Oraclesmarker', 'myCCaddress', 'myaddress']: @@ -637,15 +662,16 @@ class CryptoConditionsTest (BitcoinTestFramework): def run_test (self): print("Mining blocks...") rpc = self.nodes[0] - + rpc1 = self.nodes[1] # utxos from block 1 become mature in block 101 - rpc.generate(101) + rpc.generate(10) + rpc.getinfo() + rpc1.getinfo() self.sync_all() - # this corresponds to -pubkey above - print("Importing privkey") + print("Importing privkeys") rpc.importprivkey(self.privkey) - + rpc1.importprivkey(self.privkey1) #self.run_faucet_tests() self.run_rewards_tests() self.run_dice_tests() diff --git a/qa/rpc-tests/test_framework/util.py b/qa/rpc-tests/test_framework/util.py index 5cb0d1b10..6095d8c4d 100644 --- a/qa/rpc-tests/test_framework/util.py +++ b/qa/rpc-tests/test_framework/util.py @@ -80,7 +80,7 @@ def initialize_datadir(dirname, n): # plus CLI arguments. This is for komodod tests print("Writing to " + os.path.join(datadir,"komodo.conf")) with open(os.path.join(datadir, "komodo.conf"), 'w') as f: - f.write("regtest=1\n"); + #f.write("regtest=1\n"); f.write("txindex=1\n"); f.write("server=1\n"); f.write("showmetrics=0\n"); @@ -198,6 +198,19 @@ def start_node(i, dirname, extra_args=None, rpchost=None, timewait=None, binary= Start a komodod and return RPC connection to it """ datadir = os.path.join(dirname, "node"+str(i)) + configpath = datadir + "/REGTEST.conf" + with open(configpath, "w+") as config: + config.write("regtest=1\n") + config.write("rpcuser=rt\n") + config.write("rpcpassword=rt\n") + port = extra_args[3] + config.write("rpcport=" + (port[9:]) + "\n") + config.write("server=1\n") + config.write("txindex=1\n") + config.write("rpcworkqueue=256\n") + config.write("rpcallowip=127.0.0.1\n") + config.write("bind=127.0.0.1\n") + config.write("rpcbind=127.0.0.1") if binary is None: binary = os.getenv("BITCOIND", "komodod") args = [ binary, "-datadir="+datadir, "-keypool=1", "-discover=0", "-rest" ] @@ -223,10 +236,8 @@ def start_node(i, dirname, extra_args=None, rpchost=None, timewait=None, binary= if os.getenv("PYTHON_DEBUG", ""): print "start_node: calling komodo-cli -rpcwait getblockcount returned" devnull.close() - if extra_args[0] == '-ac_name=REGTEST': - url = "http://rt:rt@%s:%d" % (rpchost or '127.0.0.1', 64368) - else: - url = "http://rt:rt@%s:%d" % (rpchost or '127.0.0.1', rpc_port(i)) + port = extra_args[3] + url = "http://rt:rt@%s:%d" % (rpchost or '127.0.0.1', int(port[9:])) print("connecting to " + url) if timewait is not None: proxy = AuthServiceProxy(url, timeout=timewait)