~ubuntu-branches/debian/stretch/bitcoin/stretch

« back to all changes in this revision

Viewing changes to qa/rpc-tests/merkle_blocks.py

  • Committer: Package Import Robot
  • Author(s): Anthony Towns
  • Date: 2016-10-21 17:13:13 UTC
  • mfrom: (1.3.2)
  • Revision ID: package-import@ubuntu.com-20161021171313-7eu2ltpbk0xag3q1
Tags: 0.13.0-0.1
* Non-maintainer upload.
* New upstream release.
* Allow compilation with gcc/g++ 6. (Closes: Bug#835963)
* Additional fixes for openssl 1.1 compatibility. (See Bug#828248)
* Check if -latomic is needed (it is on mips*).
* Remove reproducible build patch, since leveldb build system is
  no longer used in 0.13. (See Bug#791834)
* Update description since the blockchain is much more than "several GB"
  now. (Closes: Bug#835809)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env python2
2
 
# Copyright (c) 2014-2015 The Bitcoin Core developers
 
1
#!/usr/bin/env python3
 
2
# Copyright (c) 2014-2016 The Bitcoin Core developers
3
3
# Distributed under the MIT software license, see the accompanying
4
4
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
5
 
12
12
 
13
13
class MerkleBlockTest(BitcoinTestFramework):
14
14
 
15
 
    def setup_chain(self):
16
 
        print("Initializing test directory "+self.options.tmpdir)
17
 
        initialize_chain_clean(self.options.tmpdir, 4)
 
15
    def __init__(self):
 
16
        super().__init__()
 
17
        self.setup_clean_chain = True
 
18
        self.num_nodes = 4
18
19
 
19
20
    def setup_network(self):
20
21
        self.nodes = []
32
33
        self.sync_all()
33
34
 
34
35
    def run_test(self):
35
 
        print "Mining blocks..."
 
36
        print("Mining blocks...")
36
37
        self.nodes[0].generate(105)
37
38
        self.sync_all()
38
39
 
42
43
        assert_equal(self.nodes[2].getbalance(), 0)
43
44
 
44
45
        node0utxos = self.nodes[0].listunspent(1)
45
 
        tx1 = self.nodes[0].createrawtransaction([node0utxos.pop()], {self.nodes[1].getnewaddress(): 50})
 
46
        tx1 = self.nodes[0].createrawtransaction([node0utxos.pop()], {self.nodes[1].getnewaddress(): 49.99})
46
47
        txid1 = self.nodes[0].sendrawtransaction(self.nodes[0].signrawtransaction(tx1)["hex"])
47
 
        tx2 = self.nodes[0].createrawtransaction([node0utxos.pop()], {self.nodes[1].getnewaddress(): 50})
 
48
        tx2 = self.nodes[0].createrawtransaction([node0utxos.pop()], {self.nodes[1].getnewaddress(): 49.99})
48
49
        txid2 = self.nodes[0].sendrawtransaction(self.nodes[0].signrawtransaction(tx2)["hex"])
49
50
        assert_raises(JSONRPCException, self.nodes[0].gettxoutproof, [txid1])
50
51
 
62
63
        assert_equal(self.nodes[2].verifytxoutproof(self.nodes[2].gettxoutproof([txid1, txid2], blockhash)), txlist)
63
64
 
64
65
        txin_spent = self.nodes[1].listunspent(1).pop()
65
 
        tx3 = self.nodes[1].createrawtransaction([txin_spent], {self.nodes[0].getnewaddress(): 50})
 
66
        tx3 = self.nodes[1].createrawtransaction([txin_spent], {self.nodes[0].getnewaddress(): 49.98})
66
67
        self.nodes[0].sendrawtransaction(self.nodes[1].signrawtransaction(tx3)["hex"])
67
68
        self.nodes[0].generate(1)
68
69
        self.sync_all()
70
71
        txid_spent = txin_spent["txid"]
71
72
        txid_unspent = txid1 if txin_spent["txid"] != txid1 else txid2
72
73
 
73
 
        # We cant find the block from a fully-spent tx
 
74
        # We can't find the block from a fully-spent tx
74
75
        assert_raises(JSONRPCException, self.nodes[2].gettxoutproof, [txid_spent])
75
76
        # ...but we can if we specify the block
76
77
        assert_equal(self.nodes[2].verifytxoutproof(self.nodes[2].gettxoutproof([txid_spent], blockhash)), [txid_spent])