Changeset View
Changeset View
Standalone View
Standalone View
test/functional/rpc_blockchain.py
Show First 20 Lines • Show All 194 Lines • ▼ Show 20 Lines | def _test_getchaintxstats(self): | ||||
assert_raises_rpc_error( | assert_raises_rpc_error( | ||||
-8, "Invalid block count: should be between 0 and the block's height - 1", self.nodes[0].getchaintxstats, -1) | -8, "Invalid block count: should be between 0 and the block's height - 1", self.nodes[0].getchaintxstats, -1) | ||||
assert_raises_rpc_error(-8, "Invalid block count: should be between 0 and the block's height - 1", self.nodes[ | assert_raises_rpc_error(-8, "Invalid block count: should be between 0 and the block's height - 1", self.nodes[ | ||||
0].getchaintxstats, self.nodes[0].getblockcount()) | 0].getchaintxstats, self.nodes[0].getblockcount()) | ||||
# Test `getchaintxstats` invalid `blockhash` | # Test `getchaintxstats` invalid `blockhash` | ||||
assert_raises_rpc_error( | assert_raises_rpc_error( | ||||
-1, "JSON value is not a string as expected", self.nodes[0].getchaintxstats, blockhash=0) | -1, "JSON value is not a string as expected", self.nodes[0].getchaintxstats, blockhash=0) | ||||
assert_raises_rpc_error(-8, | |||||
"blockhash must be of length 64 (not 1, for '0')", | |||||
self.nodes[0].getchaintxstats, | |||||
blockhash='0') | |||||
assert_raises_rpc_error( | assert_raises_rpc_error( | ||||
-5, "Block not found", self.nodes[0].getchaintxstats, blockhash='0') | -8, | ||||
"blockhash must be hexadecimal string (not 'ZZZ0000000000000000000000000000000000000000000000000000000000000')", | |||||
self.nodes[0].getchaintxstats, | |||||
blockhash='ZZZ0000000000000000000000000000000000000000000000000000000000000') | |||||
assert_raises_rpc_error( | |||||
-5, | |||||
"Block not found", | |||||
self.nodes[0].getchaintxstats, | |||||
blockhash='0000000000000000000000000000000000000000000000000000000000000000') | |||||
blockhash = self.nodes[0].getblockhash(200) | blockhash = self.nodes[0].getblockhash(200) | ||||
self.nodes[0].invalidateblock(blockhash) | self.nodes[0].invalidateblock(blockhash) | ||||
assert_raises_rpc_error( | assert_raises_rpc_error( | ||||
-8, "Block is not in main chain", self.nodes[0].getchaintxstats, blockhash=blockhash) | -8, "Block is not in main chain", self.nodes[0].getchaintxstats, blockhash=blockhash) | ||||
self.nodes[0].reconsiderblock(blockhash) | self.nodes[0].reconsiderblock(blockhash) | ||||
chaintxstats = self.nodes[0].getchaintxstats(nblocks=1) | chaintxstats = self.nodes[0].getchaintxstats(nblocks=1) | ||||
# 200 txs plus genesis tx | # 200 txs plus genesis tx | ||||
▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | def _test_gettxoutsetinfo(self): | ||||
assert_equal(res['txouts'], res3['txouts']) | assert_equal(res['txouts'], res3['txouts']) | ||||
assert_equal(res['bogosize'], res3['bogosize']) | assert_equal(res['bogosize'], res3['bogosize']) | ||||
assert_equal(res['bestblock'], res3['bestblock']) | assert_equal(res['bestblock'], res3['bestblock']) | ||||
assert_equal(res['hash_serialized'], res3['hash_serialized']) | assert_equal(res['hash_serialized'], res3['hash_serialized']) | ||||
def _test_getblockheader(self): | def _test_getblockheader(self): | ||||
node = self.nodes[0] | node = self.nodes[0] | ||||
assert_raises_rpc_error(-5, "Block not found", | assert_raises_rpc_error(-8, | ||||
node.getblockheader, "nonsense") | "hash must be of length 64 (not 8, for 'nonsense')", | ||||
node.getblockheader, | |||||
"nonsense") | |||||
assert_raises_rpc_error( | |||||
-8, | |||||
"hash must be hexadecimal string (not 'ZZZ7bb8b1697ea987f3b223ba7819250cae33efacb068d23dc24859824a77844')", | |||||
node.getblockheader, | |||||
"ZZZ7bb8b1697ea987f3b223ba7819250cae33efacb068d23dc24859824a77844") | |||||
assert_raises_rpc_error(-5, "Block not found", node.getblockheader, | |||||
"0cf7bb8b1697ea987f3b223ba7819250cae33efacb068d23dc24859824a77844") | |||||
besthash = node.getbestblockhash() | besthash = node.getbestblockhash() | ||||
secondbesthash = node.getblockhash(199) | secondbesthash = node.getblockhash(199) | ||||
header = node.getblockheader(blockhash=besthash) | header = node.getblockheader(blockhash=besthash) | ||||
assert_equal(header['hash'], besthash) | assert_equal(header['hash'], besthash) | ||||
assert_equal(header['height'], 200) | assert_equal(header['height'], 200) | ||||
assert_equal(header['confirmations'], 1) | assert_equal(header['confirmations'], 1) | ||||
▲ Show 20 Lines • Show All 121 Lines • Show Last 20 Lines |