Skip to content

Conversation

maflcko
Copy link
Member

@maflcko maflcko commented Dec 6, 2017

#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.

@promag
Copy link
Contributor

promag commented Dec 6, 2017

removes the special casing of blockhash.IsNull(), which makes no sense

Agree, ParseHashV throws.

Copy link
Contributor

@promag promag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK fa4c16d.

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)
Copy link
Contributor

@promag promag Dec 6, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@kallewoof
Copy link
Contributor

utACK fa4c16d

@laanwj
Copy link
Member

laanwj commented Dec 7, 2017

utACK fa4c16d

@laanwj laanwj merged commit fa4c16d into bitcoin:master Dec 7, 2017
laanwj added a commit that referenced this pull request Dec 7, 2017
fa4c16d qa: Add getrawtransaction in_active_chain=False test (MarcoFalke)

Pull request description:

  #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.

Tree-SHA512: 6c51295820b3dcd53b0b48020ab2b8c8f5864cd5061ddab2b35d35d643eb3e60ef95ff20c06c985a2e47f7080e82f27f3e00ee61c85dce627776d5ea6febee8f
Copy link
Contributor

@jnewbery jnewbery left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tested ACK fa4c16d. A few nits inline.

@@ -155,14 +155,12 @@ UniValue getrawtransaction(const JSONRPCRequest& request)

if (!request.params[2].isNull()) {
uint256 blockhash = ParseHashV(request.params[2], "parameter 3");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@@ -72,7 +72,13 @@ def run_test(self):
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 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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

# 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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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']

@maflcko maflcko deleted the Mf1712-qaRpcRawTx branch February 22, 2018 01:40
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Feb 13, 2020
…test

fa4c16d qa: Add getrawtransaction in_active_chain=False test (MarcoFalke)

Pull request description:

  bitcoin#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.

Tree-SHA512: 6c51295820b3dcd53b0b48020ab2b8c8f5864cd5061ddab2b35d35d643eb3e60ef95ff20c06c985a2e47f7080e82f27f3e00ee61c85dce627776d5ea6febee8f
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Feb 27, 2020
…test

fa4c16d qa: Add getrawtransaction in_active_chain=False test (MarcoFalke)

Pull request description:

  bitcoin#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.

Tree-SHA512: 6c51295820b3dcd53b0b48020ab2b8c8f5864cd5061ddab2b35d35d643eb3e60ef95ff20c06c985a2e47f7080e82f27f3e00ee61c85dce627776d5ea6febee8f
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Feb 27, 2020
…test

fa4c16d qa: Add getrawtransaction in_active_chain=False test (MarcoFalke)

Pull request description:

  bitcoin#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.

Tree-SHA512: 6c51295820b3dcd53b0b48020ab2b8c8f5864cd5061ddab2b35d35d643eb3e60ef95ff20c06c985a2e47f7080e82f27f3e00ee61c85dce627776d5ea6febee8f
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants