#10275 accidentally forgot to add a test for in_active_chain==False.
This adds a test and also removes the special casing of blockhash.IsNull(), which makes no sense imo.
#10275 accidentally forgot to add a test for in_active_chain==False.
This adds a test and also removes the special casing of blockhash.IsNull(), which makes no sense imo.
removes the special casing of blockhash.IsNull(), which makes no sense
Agree, ParseHashV throws.
77 | + # Undo the blocks and check in_active_chain 78 | + self.nodes[0].invalidateblock(block1) 79 | + gottx = self.nodes[0].getrawtransaction(txid=tx, verbose=True, blockhash=block1) 80 | + assert_equal(gottx['in_active_chain'], False) 81 | + self.nodes[0].reconsiderblock(block1) 82 | + assert_equal(self.nodes[0].getbestblockhash(), block2)
Nit, IMO this check is not really necessary in the context of this test (it's testing reconsiderblockworked). The same could be done above after invalidateblock(block1).
But I guess you want to be sure the state is the same for the remaining script.
ACK fa4c16d.
utACK fa4c16d2e72a8ec1032da49a68c9913c2595dbfe
utACK fa4c16d
154 | @@ -155,14 +155,12 @@ UniValue getrawtransaction(const JSONRPCRequest& request)
155 |
156 | if (!request.params[2].isNull()) {
157 | uint256 blockhash = ParseHashV(request.params[2], "parameter 3");
nit: suggest you add a comment here to say that ParseHashV() will throw if called with a string which isn't a 64 length hex strong.
71 | @@ -72,7 +72,13 @@ def run_test(self): 72 | assert_raises_rpc_error(-8, "parameter 3 must be hexadecimal", self.nodes[0].getrawtransaction, tx, True, True) 73 | assert_raises_rpc_error(-8, "parameter 3 must be hexadecimal", self.nodes[0].getrawtransaction, tx, True, "foobar") 74 | assert_raises_rpc_error(-8, "parameter 3 must be of length 64", self.nodes[0].getrawtransaction, tx, True, "abcd1234") 75 | - assert_raises_rpc_error(-5, "Block hash not found", self.nodes[0].getrawtransaction, tx, True, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") 76 | + assert_raises_rpc_error(-5, "Block hash not found", self.nodes[0].getrawtransaction, tx, True, "0000000000000000000000000000000000000000000000000000000000000000")
nit: prefer assert_raises_rpc_error(-5, "Block hash not found", self.nodes[0].getrawtransaction, tx, True, "0" * 64) to make it clear that this is a valid length 64 hex string
71 | @@ -72,7 +72,13 @@ def run_test(self): 72 | assert_raises_rpc_error(-8, "parameter 3 must be hexadecimal", self.nodes[0].getrawtransaction, tx, True, True) 73 | assert_raises_rpc_error(-8, "parameter 3 must be hexadecimal", self.nodes[0].getrawtransaction, tx, True, "foobar") 74 | assert_raises_rpc_error(-8, "parameter 3 must be of length 64", self.nodes[0].getrawtransaction, tx, True, "abcd1234") 75 | - assert_raises_rpc_error(-5, "Block hash not found", self.nodes[0].getrawtransaction, tx, True, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") 76 | + assert_raises_rpc_error(-5, "Block hash not found", self.nodes[0].getrawtransaction, tx, True, "0000000000000000000000000000000000000000000000000000000000000000") 77 | + # Undo the blocks and check in_active_chain 78 | + self.nodes[0].invalidateblock(block1) 79 | + gottx = self.nodes[0].getrawtransaction(txid=tx, verbose=True, blockhash=block1) 80 | + assert_equal(gottx['in_active_chain'], False)
nit: slight preference for assert not gottx['in_active_chain']
it'd also be nice to test the positive case (call getrawtransaction with a blockhash in the current chain and assert gottx['in_active_chain']
tested ACK fa4c16d2e72a8ec1032da49a68c9913c2595dbfe. A few nits inline.