tests: Make msg_block a witness block #15982

pull MarcoFalke wants to merge 2 commits into bitcoin:master from MarcoFalke:1905-testWitnessTrue changing 6 files +39 −42
  1. MarcoFalke commented at 2:00 PM on May 8, 2019: member

    Unnamed arguments are confusing as to what they mean without looking up the function signature.

    Since segwit is active by default in regtest, and all blocks are serialized with witness (#15664), remove the argument with_witness=True from all calls to CBlock::serialize and BlockTransactions::serialize.

  2. MarcoFalke added the label Refactoring on May 8, 2019
  3. MarcoFalke added the label Tests on May 8, 2019
  4. test: Remove True argument to CBlock::serialize
    Unnamed arguments are confusing as to what they mean without looking up
    the function signature.
    
    Since segwit is active by default in regtest, and all blocks are
    serialized with witness (#15664, c459c5f), remove the argument
    `with_witness=True` from all calls to `CBlock::serialize` and
    `BlockTransactions::serialize`.
    
    This diff has been created with a script, but is better reviewed without
    a scripted diff.
    
    sed -i --regexp-extended -e 's/block(_?[2a-z]*)\.serialize\([a-z_]*=?True/block\1.serialize(/g' $(git grep -l serialize ./test)
    fa52eb55c9
  5. MarcoFalke force-pushed on May 8, 2019
  6. MarcoFalke force-pushed on May 8, 2019
  7. MarcoFalke force-pushed on May 8, 2019
  8. MarcoFalke force-pushed on May 8, 2019
  9. jnewbery commented at 3:51 PM on May 8, 2019: member

    Please correct PR title CBlock::serialize -> CBlock.serialize so it's clear that this is a change to the Python code and not C++.

  10. tests: Make msg_block a witness block
    This diff has been generated with the following script, but is better
    reviewed without looking at the script.
    
     # -BEGIN VERIFY SCRIPT-
    echo "Use msg_witness_block everywhere, except for tests that require msg_block"
     # This could be a separate commit, but it is combined with the
     # following scripts to reduce the overall diff
    sed -i -e 's/msg_block/msg_witness_block/g' ./test/functional/{feature_assumevalid,feature_cltv,feature_dersig,feature_versionbits_warning,p2p_fingerprint,p2p_sendheaders,p2p_unrequested_blocks,example_test,rpc_blockchain}.py
    
    echo "Rename msg_block to msg_no_witness_block"
     # Rename msg_block to msg_no_witness_block in all tests (not the
     # framework)
    sed -i -e 's/msg_block/msg_no_witness_block/g' $(git grep -l msg_block ./test/functional/*.py)
     # Derive msg_no_witness_block from msg_block
     # Make msg_block a witness block in messages.py
    patch -p1 --fuzz 0 << EOF
    diff --git a/test/functional/test_framework/messages.py b/test/functional/test_framework/messages.py
    index 00190e4cbd..e454ed5987 100755
    --- a/test/functional/test_framework/messages.py
    +++ b/test/functional/test_framework/messages.py
    @@ -1133 +1133 @@ class msg_block:
    -        return self.block.serialize(with_witness=False)
    +        return self.block.serialize()
    @@ -1155 +1155 @@ class msg_generic:
    -class msg_witness_block(msg_block):
    +class msg_no_witness_block(msg_block):
    @@ -1158,2 +1158 @@ class msg_witness_block(msg_block):
    -        r = self.block.serialize()
    -        return r
    +        return self.block.serialize(with_witness=False)
    @@ -1445 +1444 @@ class msg_blocktxn:
    -        r += self.block_transactions.serialize(with_witness=False)
    +        r += self.block_transactions.serialize()
    @@ -1452 +1451 @@ class msg_blocktxn:
    -class msg_witness_blocktxn(msg_blocktxn):
    +class msg_no_witness_blocktxn(msg_blocktxn):
    @@ -1456,3 +1455 @@ class msg_witness_blocktxn(msg_blocktxn):
    -        r = b""
    -        r += self.block_transactions.serialize()
    -        return r
    +        return self.block_transactions.serialize(with_witness=False)
    EOF
     # Conclude rename of msg_block to msg_no_witness_block
    sed -i -e 's/msg_witness_block/msg_block/g' $(git grep -l msg_witness_block)
     # -END VERIFY SCRIPT-
    fa1d766717
  11. MarcoFalke force-pushed on May 8, 2019
  12. MarcoFalke renamed this:
    test: Remove True argument to CBlock::serialize
    tests: Make msg_block a witness block
    on May 8, 2019
  13. MarcoFalke commented at 3:56 PM on May 8, 2019: member

    I just went all the way to make msg_block a witness block

  14. laanwj commented at 2:12 PM on June 17, 2019: member

    code-review ACK fa1d7667173eeae363d3729e3fc654057335cb44

  15. MarcoFalke referenced this in commit d9bafca20c on Jun 17, 2019
  16. MarcoFalke merged this on Jun 17, 2019
  17. MarcoFalke closed this on Jun 17, 2019

  18. MarcoFalke deleted the branch on Jun 17, 2019
  19. sidhujag referenced this in commit bf5a4f0d80 on Jun 19, 2019
  20. laanwj referenced this in commit 3b69310beb on Jan 30, 2020
  21. sidhujag referenced this in commit 3cf24efd34 on Feb 1, 2020
  22. sidhujag referenced this in commit bd95d473cf on Nov 10, 2020
  23. Munkybooty referenced this in commit 03b35b48f9 on Oct 25, 2021
  24. Munkybooty referenced this in commit 3271fd7fe4 on Oct 25, 2021
  25. Munkybooty referenced this in commit 196dac9c61 on Oct 29, 2021
  26. Munkybooty referenced this in commit 6e79013ac3 on Oct 30, 2021
  27. Munkybooty referenced this in commit 0864890b3f on Nov 2, 2021
  28. Munkybooty referenced this in commit 1223f60dc9 on Nov 2, 2021
  29. DrahtBot locked this on Dec 16, 2021

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-04-17 06:14 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me