While playing with invalidateblock, I unintentionally tried to invalidate an unknown block and it threw an error. Looking at the tests I just realized there is no test coverage for this case. This PR adds it.
test: invalidating an unknown block throws an error #26038
pull brunoerg wants to merge 1 commits into bitcoin:master from brunoerg:2022-09-unknown-block-invalidate changing 1 files +6 −0-
brunoerg commented at 5:53 PM on September 7, 2022: contributor
-
in test/functional/rpc_invalidateblock.py:91 in 94783c9923 outdated
83 | @@ -83,6 +84,9 @@ def run_test(self): 84 | # Should be back at the tip by now 85 | assert_equal(self.nodes[1].getbestblockhash(), blocks[-1]) 86 | 87 | + self.log.info("Verify that invalidating an unknown block throws an error") 88 | + assert_raises_rpc_error(-5, "Block not found", self.nodes[1].invalidateblock, "00" * 32) 89 | +
instagibbs commented at 5:54 PM on September 7, 2022:might as well check it didn't effect chaintips, the important thing :)
brunoerg commented at 5:58 PM on September 7, 2022:Perfect, thanks! Gonna do it.
DrahtBot added the label Tests on Sep 7, 2022brunoerg force-pushed on Sep 8, 2022test: invalidating an unknown block throws an error 4b1d5a1053instagibbs commented at 2:06 PM on September 8, 2022: memberACK 9e3eb46b740937eb03116b9408d7f7a4fab04eb6
brunoerg force-pushed on Sep 8, 2022MarcoFalke merged this on Sep 8, 2022MarcoFalke closed this on Sep 8, 2022sidhujag referenced this in commit ffe590469a on Sep 8, 2022in test/functional/rpc_invalidateblock.py:91 in 4b1d5a1053
83 | @@ -83,6 +84,11 @@ def run_test(self): 84 | # Should be back at the tip by now 85 | assert_equal(self.nodes[1].getbestblockhash(), blocks[-1]) 86 | 87 | + self.log.info("Verify that invalidating an unknown block throws an error") 88 | + chain_tips = self.nodes[1].getchaintips() 89 | + assert_raises_rpc_error(-5, "Block not found", self.nodes[1].invalidateblock, "00" * 32) 90 | + assert_equal(chain_tips, self.nodes[1].getchaintips()) 91 | +
MarcoFalke commented at 6:02 AM on September 9, 2022:
brunoerg commented at 9:52 AM on September 9, 2022:I'm gonna fix it.
brunoerg commented at 4:16 PM on September 9, 2022:bitcoin locked this on Sep 9, 2023ContributorsLabels
github-metadata-mirror
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-02 03:13 UTC
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-02 03:13 UTC
This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me
More mirrored repositories can be found on mirror.b10c.me