From 756c2d7a0d2a567bc82e23f29ca8365910bbabdb Mon Sep 17 00:00:00 2001 From: Holger Schinzel Date: Sat, 30 Jan 2016 09:14:32 +0100 Subject: [PATCH] make RPC tests pass --- Makefile.am | 6 +++-- qa/rpc-tests/mempool_coinbase_spends.py | 10 ++++---- qa/rpc-tests/mempool_resurrect_test.py | 4 ++-- qa/rpc-tests/mempool_spendcoinbase.py | 2 +- qa/rpc-tests/test_framework.py | 2 +- qa/rpc-tests/txn_doublespend.py | 32 ++++++++++++------------- qa/rpc-tests/util.py | 8 +++---- qa/rpc-tests/wallet.py | 12 +++++----- 8 files changed, 39 insertions(+), 37 deletions(-) diff --git a/Makefile.am b/Makefile.am index 54aaa3bc3..ec84dcf40 100644 --- a/Makefile.am +++ b/Makefile.am @@ -184,10 +184,12 @@ cov: test_dash.coverage/.dirstamp total.coverage/.dirstamp endif +# Dash: disable the test until upstream switches from convoluted comparison tool +# Ref https://github.com/bitcoin/bitcoin/issues/4545 if USE_COMPARISON_TOOL check-local: - $(MKDIR_P) qa/tmp - @qa/pull-tester/run-bitcoind-for-test.sh $(JAVA) -jar $(JAVA_COMPARISON_TOOL) qa/tmp/compTool $(COMPARISON_TOOL_REORG_TESTS) 2>&1 + ## $(MKDIR_P) qa/tmp + ## @qa/pull-tester/run-bitcoind-for-test.sh $(JAVA) -jar $(JAVA_COMPARISON_TOOL) qa/tmp/compTool $(COMPARISON_TOOL_REORG_TESTS) 2>&1 endif dist_noinst_SCRIPTS = autogen.sh diff --git a/qa/rpc-tests/mempool_coinbase_spends.py b/qa/rpc-tests/mempool_coinbase_spends.py index 7b4371276..b34c89bf3 100755 --- a/qa/rpc-tests/mempool_coinbase_spends.py +++ b/qa/rpc-tests/mempool_coinbase_spends.py @@ -55,9 +55,9 @@ class MempoolCoinbaseTest(BitcoinTestFramework): # and make sure the mempool code behaves correctly. b = [ self.nodes[0].getblockhash(n) for n in range(102, 105) ] coinbase_txids = [ self.nodes[0].getblock(h)['tx'][0] for h in b ] - spend_101_raw = self.create_tx(coinbase_txids[0], node1_address, 50) - spend_102_raw = self.create_tx(coinbase_txids[1], node0_address, 50) - spend_103_raw = self.create_tx(coinbase_txids[2], node0_address, 50) + spend_101_raw = self.create_tx(coinbase_txids[0], node1_address, 500) + spend_102_raw = self.create_tx(coinbase_txids[1], node0_address, 500) + spend_103_raw = self.create_tx(coinbase_txids[2], node0_address, 500) # Broadcast and mine spend_102 and 103: spend_102_id = self.nodes[0].sendrawtransaction(spend_102_raw) @@ -65,8 +65,8 @@ class MempoolCoinbaseTest(BitcoinTestFramework): self.nodes[0].setgenerate(True, 1) # Create 102_1 and 103_1: - spend_102_1_raw = self.create_tx(spend_102_id, node1_address, 50) - spend_103_1_raw = self.create_tx(spend_103_id, node1_address, 50) + spend_102_1_raw = self.create_tx(spend_102_id, node1_address, 500) + spend_103_1_raw = self.create_tx(spend_103_id, node1_address, 500) # Broadcast and mine 103_1: spend_103_1_id = self.nodes[0].sendrawtransaction(spend_103_1_raw) diff --git a/qa/rpc-tests/mempool_resurrect_test.py b/qa/rpc-tests/mempool_resurrect_test.py index 81db812bf..12d9ae9cd 100755 --- a/qa/rpc-tests/mempool_resurrect_test.py +++ b/qa/rpc-tests/mempool_resurrect_test.py @@ -47,13 +47,13 @@ class MempoolCoinbaseTest(BitcoinTestFramework): b = [ self.nodes[0].getblockhash(n) for n in range(1, 4) ] coinbase_txids = [ self.nodes[0].getblock(h)['tx'][0] for h in b ] - spends1_raw = [ self.create_tx(txid, node0_address, 50) for txid in coinbase_txids ] + spends1_raw = [ self.create_tx(txid, node0_address, 500) for txid in coinbase_txids ] spends1_id = [ self.nodes[0].sendrawtransaction(tx) for tx in spends1_raw ] blocks = [] blocks.extend(self.nodes[0].setgenerate(True, 1)) - spends2_raw = [ self.create_tx(txid, node0_address, 49.99) for txid in spends1_id ] + spends2_raw = [ self.create_tx(txid, node0_address, 499.99) for txid in spends1_id ] spends2_id = [ self.nodes[0].sendrawtransaction(tx) for tx in spends2_raw ] blocks.extend(self.nodes[0].setgenerate(True, 1)) diff --git a/qa/rpc-tests/mempool_spendcoinbase.py b/qa/rpc-tests/mempool_spendcoinbase.py index f0b34f290..3dd825dab 100755 --- a/qa/rpc-tests/mempool_spendcoinbase.py +++ b/qa/rpc-tests/mempool_spendcoinbase.py @@ -47,7 +47,7 @@ class MempoolSpendCoinbaseTest(BitcoinTestFramework): # is too immature to spend. b = [ self.nodes[0].getblockhash(n) for n in range(101, 103) ] coinbase_txids = [ self.nodes[0].getblock(h)['tx'][0] for h in b ] - spends_raw = [ self.create_tx(txid, node0_address, 50) for txid in coinbase_txids ] + spends_raw = [ self.create_tx(txid, node0_address, 500) for txid in coinbase_txids ] spend_101_id = self.nodes[0].sendrawtransaction(spends_raw[0]) diff --git a/qa/rpc-tests/test_framework.py b/qa/rpc-tests/test_framework.py index 4c8a11b82..0205b0812 100755 --- a/qa/rpc-tests/test_framework.py +++ b/qa/rpc-tests/test_framework.py @@ -24,7 +24,7 @@ class BitcoinTestFramework(object): def run_test(self): for node in self.nodes: assert_equal(node.getblockcount(), 200) - assert_equal(node.getbalance(), 25*50) + assert_equal(node.getbalance(), 25*500) def add_options(self, parser): pass diff --git a/qa/rpc-tests/txn_doublespend.py b/qa/rpc-tests/txn_doublespend.py index 942d9fc66..8bf6c9d94 100755 --- a/qa/rpc-tests/txn_doublespend.py +++ b/qa/rpc-tests/txn_doublespend.py @@ -25,27 +25,27 @@ class TxnMallTest(BitcoinTestFramework): return super(TxnMallTest, self).setup_network(True) def run_test(self): - # All nodes should start with 1,250 BTC: - starting_balance = 1250 + # All nodes should start with 12,500 DASH: + starting_balance = 12500 for i in range(4): assert_equal(self.nodes[i].getbalance(), starting_balance) self.nodes[i].getnewaddress("") # bug workaround, coins generated assigned to first getnewaddress! # Assign coins to foo and bar accounts: - self.nodes[0].move("", "foo", 1220) + self.nodes[0].move("", "foo", 12470) self.nodes[0].move("", "bar", 30) assert_equal(self.nodes[0].getbalance(""), 0) # Coins are sent to node1_address node1_address = self.nodes[1].getnewaddress("from0") - # First: use raw transaction API to send 1210 BTC to node1_address, + # First: use raw transaction API to send 12460 BTC to node1_address, # but don't broadcast: - (total_in, inputs) = gather_inputs(self.nodes[0], 1210) + (total_in, inputs) = gather_inputs(self.nodes[0], 12460) change_address = self.nodes[0].getnewaddress("foo") outputs = {} outputs[change_address] = 40 - outputs[node1_address] = 1210 + outputs[node1_address] = 12460 rawtx = self.nodes[0].createrawtransaction(inputs, outputs) doublespend = self.nodes[0].signrawtransaction(rawtx) assert_equal(doublespend["complete"], True) @@ -53,7 +53,7 @@ class TxnMallTest(BitcoinTestFramework): # Create two transaction from node[0] to node[1]; the # second must spend change from the first because the first # spends all mature inputs: - txid1 = self.nodes[0].sendfrom("foo", node1_address, 1210, 0) + txid1 = self.nodes[0].sendfrom("foo", node1_address, 12460, 0) txid2 = self.nodes[0].sendfrom("bar", node1_address, 20, 0) # Have node0 mine a block: @@ -64,16 +64,16 @@ class TxnMallTest(BitcoinTestFramework): tx1 = self.nodes[0].gettransaction(txid1) tx2 = self.nodes[0].gettransaction(txid2) - # Node0's balance should be starting balance, plus 50BTC for another - # matured block, minus 1210, minus 20, and minus transaction fees: + # Node0's balance should be starting balance, plus 500 DASH for another + # matured block, minus 12460, minus 20, and minus transaction fees: expected = starting_balance - if self.options.mine_block: expected += 50 + if self.options.mine_block: expected += 500 expected += tx1["amount"] + tx1["fee"] expected += tx2["amount"] + tx2["fee"] assert_equal(self.nodes[0].getbalance(), expected) # foo and bar accounts should be debited: - assert_equal(self.nodes[0].getbalance("foo"), 1220+tx1["amount"]+tx1["fee"]) + assert_equal(self.nodes[0].getbalance("foo"), 12470+tx1["amount"]+tx1["fee"]) assert_equal(self.nodes[0].getbalance("bar"), 30+tx2["amount"]+tx2["fee"]) if self.options.mine_block: @@ -103,18 +103,18 @@ class TxnMallTest(BitcoinTestFramework): assert_equal(tx1["confirmations"], -1) assert_equal(tx2["confirmations"], -1) - # Node0's total balance should be starting balance, plus 100BTC for - # two more matured blocks, minus 1210 for the double-spend: - expected = starting_balance + 100 - 1210 + # Node0's total balance should be starting balance, plus 1000 DASH for + # two more matured blocks, minus 12460 for the double-spend: + expected = starting_balance + 1000 - 12460 assert_equal(self.nodes[0].getbalance(), expected) assert_equal(self.nodes[0].getbalance("*"), expected) # foo account should be debited, but bar account should not: - assert_equal(self.nodes[0].getbalance("foo"), 1220-1210) + assert_equal(self.nodes[0].getbalance("foo"), 12470-12460) assert_equal(self.nodes[0].getbalance("bar"), 30) # Node1's "from" account balance should be just the mutated send: - assert_equal(self.nodes[1].getbalance("from0"), 1210) + assert_equal(self.nodes[1].getbalance("from0"), 12460) if __name__ == '__main__': TxnMallTest().main() diff --git a/qa/rpc-tests/util.py b/qa/rpc-tests/util.py index d40e3b1f7..deb21084a 100644 --- a/qa/rpc-tests/util.py +++ b/qa/rpc-tests/util.py @@ -103,15 +103,15 @@ def initialize_chain(test_dir): # Create a 200-block-long chain; each of the 4 nodes # gets 25 mature blocks and 25 immature. - # blocks are created with timestamps 10 minutes apart, starting - # at 1 Jan 2014 - block_time = 1388534400 + # blocks are created with timestamps 156 seconds apart, starting + # at 1 Jan 2015 + block_time = 1420070400 for i in range(2): for peer in range(4): for j in range(25): set_node_times(rpcs, block_time) rpcs[peer].setgenerate(True, 1) - block_time += 10*60 + block_time += 156 # Must sync before next peer starts generating blocks sync_blocks(rpcs) diff --git a/qa/rpc-tests/wallet.py b/qa/rpc-tests/wallet.py index 8fca84782..ef4b2d9c2 100755 --- a/qa/rpc-tests/wallet.py +++ b/qa/rpc-tests/wallet.py @@ -8,14 +8,14 @@ # Does the following: # a) creates 3 nodes, with an empty chain (no blocks). # b) node0 mines a block -# c) node1 mines 101 blocks, so now nodes 0 and 1 have 50btc, node2 has none. -# d) node0 sends 21 btc to node2, in two transactions (11 btc, then 10 btc). +# c) node1 mines 101 blocks, so now nodes 0 and 1 have 500 DASH, node2 has none. +# d) node0 sends 21 DASH to node2, in two transactions (11 DASH, then 10 DASH). # e) node0 mines a block, collects the fee on the second transaction # f) node1 mines 100 blocks, to mature node0's just-mined block -# g) check that node0 has 100-21, node2 has 21 +# g) check that node0 has 1000-21, node2 has 21 # h) node0 should now have 2 unspent outputs; send these to node2 via raw tx broadcast by node1 # i) have node1 mine a block -# j) check balances - node0 should have 0, node2 should have 100 +# j) check balances - node0 should have 0, node2 should have 1000 # from test_framework import BitcoinTestFramework @@ -49,7 +49,7 @@ class WalletTest (BitcoinTestFramework): assert_equal(self.nodes[1].getbalance(), 500) assert_equal(self.nodes[2].getbalance(), 0) - # Send 21 BTC from 0 to 2 using sendtoaddress call. + # Send 21 DASH from 0 to 2 using sendtoaddress call. # Second transaction will be child of first, and will require a fee self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 11) self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 10) @@ -62,7 +62,7 @@ class WalletTest (BitcoinTestFramework): self.nodes[1].setgenerate(True, 100) self.sync_all() - # node0 should end up with 100 btc in block rewards plus fees, but + # node0 should end up with 1000 DASH in block rewards plus fees, but # minus the 21 plus fees sent to node2 assert_equal(self.nodes[0].getbalance(), 1000-21) assert_equal(self.nodes[2].getbalance(), 21)