make RPC tests pass

This commit is contained in:
Holger Schinzel 2016-01-30 09:14:32 +01:00
parent 66ce5f1d60
commit 756c2d7a0d
8 changed files with 39 additions and 37 deletions

View File

@ -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

View File

@ -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)

View File

@ -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))

View File

@ -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])

View File

@ -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

View File

@ -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()

View File

@ -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)

View File

@ -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)