Skip to content

Commit 37f5386

Browse files
author
MacroFake
committed
Merge bitcoin/bitcoin#26038: test: invalidating an unknown block throws an error
4b1d5a1 test: invalidating an unknown block throws an error (brunoerg) Pull request description: 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. Top commit has no ACKs. Tree-SHA512: 25286ead809b3ad022e759127ef3134b271fbe76cb7b50ec2b0c7e2409da8d1b01dc5e80afe73e4564cc9c9c03487a1fe772aea3456988552d2f9c8fb34c730b
2 parents 2557429 + 4b1d5a1 commit 37f5386

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

test/functional/rpc_invalidateblock.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from test_framework.address import ADDRESS_BCRT1_UNSPENDABLE_DESCRIPTOR
99
from test_framework.util import (
1010
assert_equal,
11+
assert_raises_rpc_error,
1112
)
1213

1314

@@ -83,6 +84,11 @@ def run_test(self):
8384
# Should be back at the tip by now
8485
assert_equal(self.nodes[1].getbestblockhash(), blocks[-1])
8586

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+
8692

8793
if __name__ == '__main__':
8894
InvalidateTest().main()

0 commit comments

Comments
 (0)