Browse Source

qa: Add getrawtransaction in_active_chain=False test

0.16
MarcoFalke 7 years ago
parent
commit
fa4c16d2e7
  1. 2
      src/rpc/rawtransaction.cpp
  2. 8
      test/functional/rawtransactions.py

2
src/rpc/rawtransaction.cpp

@ -155,7 +155,6 @@ UniValue getrawtransaction(const JSONRPCRequest& request)
if (!request.params[2].isNull()) { if (!request.params[2].isNull()) {
uint256 blockhash = ParseHashV(request.params[2], "parameter 3"); uint256 blockhash = ParseHashV(request.params[2], "parameter 3");
if (!blockhash.IsNull()) {
BlockMap::iterator it = mapBlockIndex.find(blockhash); BlockMap::iterator it = mapBlockIndex.find(blockhash);
if (it == mapBlockIndex.end()) { if (it == mapBlockIndex.end()) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block hash not found"); throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block hash not found");
@ -163,7 +162,6 @@ UniValue getrawtransaction(const JSONRPCRequest& request)
blockindex = it->second; blockindex = it->second;
in_active_chain = chainActive.Contains(blockindex); in_active_chain = chainActive.Contains(blockindex);
} }
}
CTransactionRef tx; CTransactionRef tx;
uint256 hash_block; uint256 hash_block;

8
test/functional/rawtransactions.py

@ -72,7 +72,13 @@ class RawTransactionsTest(BitcoinTestFramework):
assert_raises_rpc_error(-8, "parameter 3 must be hexadecimal", self.nodes[0].getrawtransaction, tx, True, True) assert_raises_rpc_error(-8, "parameter 3 must be hexadecimal", self.nodes[0].getrawtransaction, tx, True, True)
assert_raises_rpc_error(-8, "parameter 3 must be hexadecimal", self.nodes[0].getrawtransaction, tx, True, "foobar") assert_raises_rpc_error(-8, "parameter 3 must be hexadecimal", self.nodes[0].getrawtransaction, tx, True, "foobar")
assert_raises_rpc_error(-8, "parameter 3 must be of length 64", self.nodes[0].getrawtransaction, tx, True, "abcd1234") assert_raises_rpc_error(-8, "parameter 3 must be of length 64", self.nodes[0].getrawtransaction, tx, True, "abcd1234")
assert_raises_rpc_error(-5, "Block hash not found", self.nodes[0].getrawtransaction, tx, True, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") assert_raises_rpc_error(-5, "Block hash not found", self.nodes[0].getrawtransaction, tx, True, "0000000000000000000000000000000000000000000000000000000000000000")
# Undo the blocks and check in_active_chain
self.nodes[0].invalidateblock(block1)
gottx = self.nodes[0].getrawtransaction(txid=tx, verbose=True, blockhash=block1)
assert_equal(gottx['in_active_chain'], False)
self.nodes[0].reconsiderblock(block1)
assert_equal(self.nodes[0].getbestblockhash(), block2)
######################### #########################
# RAW TX MULTISIG TESTS # # RAW TX MULTISIG TESTS #

Loading…
Cancel
Save