Closes #3178 by adding verbosity level improvements to getblock RPC.

This is a follow-up commit for d0a1d833520d120bb5a2ac4cf4192047af6afe24
found in PR #3095 in order to fix nits and add a test.
This commit is contained in:
Simon
2018-04-30 11:51:59 -07:00
parent bf911b3038
commit 9bd8f092c6
3 changed files with 28 additions and 9 deletions

View File

@@ -7,6 +7,7 @@
# Test merkleblock fetch/validation
#
import string
from test_framework.test_framework import BitcoinTestFramework
from test_framework.authproxy import JSONRPCException
from test_framework.util import assert_equal, assert_raises, \
@@ -86,5 +87,13 @@ class MerkleBlockTest(BitcoinTestFramework):
# ...or if we have a -txindex
assert_equal(self.nodes[2].verifytxoutproof(self.nodes[3].gettxoutproof([txid_spent])), [txid_spent])
# Quick test of getblock using blockhash and different levels of verbosity
result = self.nodes[0].getblock(blockhash, 2)
coinbase_txid = result["tx"][0]["txid"]
result = self.nodes[0].getblock(blockhash, 1)
assert_equal(coinbase_txid, result["tx"][0]) # verbosity 1 only lists txids
result = self.nodes[0].getblock(blockhash, 0)
assert(c in string.hexdigits for c in result) # verbosity 0 returns raw hex
if __name__ == '__main__':
MerkleBlockTest().main()