Merge bitcoin/bitcoin#27603: test: added coverage to mining_basic.py

a7b46a1feae60e38fe4bdcacf5034f44cae49222 test: added coverage to mining_basic.py (kevkevin)

Pull request description:

  Included a test that checks if we call submitblock with block.vtx.empty() then it throws an rpc deserialization error, currently we only test if !block.vtx->IsCoinBase() throws an rpc deserialization error

  I've tested to make sure this actually doing what I intended by breaking up this if block into two if blocks with different error messages and running the functional test
  322ec63b01/src/rpc/mining.cpp (L963)

  This change should increase the test coverage for the `submitblock()` rpc in `./src/rpc/mining.cpp`

ACKs for top commit:
  theStack:
    ACK a7b46a1feae60e38fe4bdcacf5034f44cae49222

Tree-SHA512: 4078cb1fa879cc9e34438319f73085b521b90a5a95348b23e494cf8e5ac792ec426bc0e1a63e949645e16afebe54c5f35a194f02e20b7273871163d89a5c44e6
This commit is contained in:
glozow 2023-06-02 14:21:15 +01:00 committed by pasta
parent a21b4b16f7
commit 324db8bb31
No known key found for this signature in database
GPG Key ID: E2F3D7916E722D38

View File

@ -123,6 +123,7 @@ class MiningTest(BitcoinTestFramework):
assert_template(node, bad_block, 'bad-cb-missing') assert_template(node, bad_block, 'bad-cb-missing')
self.log.info("submitblock: Test invalid coinbase transaction") self.log.info("submitblock: Test invalid coinbase transaction")
assert_raises_rpc_error(-22, "Block does not start with a coinbase", node.submitblock, CBlock().serialize().hex())
assert_raises_rpc_error(-22, "Block does not start with a coinbase", node.submitblock, bad_block.serialize().hex()) assert_raises_rpc_error(-22, "Block does not start with a coinbase", node.submitblock, bad_block.serialize().hex())
self.log.info("getblocktemplate: Test truncated final transaction") self.log.info("getblocktemplate: Test truncated final transaction")