diff options
author | Jonas Schnelli <jonas.schnelli@include7.ch> | 2014-11-28 20:32:52 +0100 |
---|---|---|
committer | Jonas Schnelli <jonas.schnelli@include7.ch> | 2014-12-09 16:05:50 +0100 |
commit | 73351c3686094158c3a61f1f11126569c5c3ed3f (patch) | |
tree | e44ae151addbc2fc2129004c1d2e64f99f9ddf21 /qa | |
parent | 0a1d03ca5265293e6419b0ffb68d277da6b1d9a0 (diff) |
[REST] /rest/block response with full tx details
- rest block request returns full unfolded tx details
- /rest/block/notxdetails/<HASH> returns block where transactions are only represented by its hash
Diffstat (limited to 'qa')
-rwxr-xr-x | qa/rpc-tests/rest.py | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/qa/rpc-tests/rest.py b/qa/rpc-tests/rest.py index c62a96fbb8..cb1868de36 100755 --- a/qa/rpc-tests/rest.py +++ b/qa/rpc-tests/rest.py @@ -48,7 +48,7 @@ class RESTTest (BitcoinTestFramework): assert_equal(json_obj['hash'], bb_hash) # do tx test - tx_hash = json_obj['tx'][0]; + tx_hash = json_obj['tx'][0]['txid']; json_string = http_get_call(url.hostname, url.port, '/rest/tx/'+tx_hash+self.FORMAT_SEPARATOR+"json") json_obj = json.loads(json_string) assert_equal(json_obj['txid'], tx_hash) @@ -57,6 +57,33 @@ class RESTTest (BitcoinTestFramework): hex_string = http_get_call(url.hostname, url.port, '/rest/tx/'+tx_hash+self.FORMAT_SEPARATOR+"hex", True) assert_equal(response.status, 200) assert_greater_than(int(response.getheader('content-length')), 10) + + # check block tx details + # let's make 3 tx and mine them on node 1 + txs = [] + txs.append(self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 11)) + txs.append(self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 11)) + txs.append(self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 11)) + self.sync_all() + + # now mine the transactions + newblockhash = self.nodes[1].setgenerate(True, 1) + self.sync_all() + + #check if the 3 tx show up in the new block + json_string = http_get_call(url.hostname, url.port, '/rest/block/'+newblockhash[0]+self.FORMAT_SEPARATOR+'json') + json_obj = json.loads(json_string) + for tx in json_obj['tx']: + if not 'coinbase' in tx['vin'][0]: #exclude coinbase + assert_equal(tx['txid'] in txs, True) + + #check the same but without tx details + json_string = http_get_call(url.hostname, url.port, '/rest/block/notxdetails/'+newblockhash[0]+self.FORMAT_SEPARATOR+'json') + json_obj = json.loads(json_string) + for tx in txs: + assert_equal(tx in json_obj['tx'], True) + + if __name__ == '__main__': RESTTest ().main () |