test: Cover `IsNull()` for PSBT, PSBTInput, PSBTOutput #35848

pull nebula-21 wants to merge 1 commits into bitcoin:master from nebula-21:add-psbt-isnull-test changing 1 files +70 −0
  1. nebula-21 commented at 3:49 PM on July 30, 2026: contributor

    The motivation for this PR came while reviewing PR#35553, I noticed on corecheck that the IsNull() functions of PartiallySignedTransaction, PSBTInput, PSBTOutput weren't covered by any test.

    This PR adds coverage for all of them.

    This cases can be tested with the next diffs that don't cause test failure prior to this PR, but with this new test do:

    <details> <summary>Diff for <code>PartiallySignedTransaction</code></summary>

    diff --git a/src/psbt.cpp b/src/psbt.cpp
    index 8f2e9ab16f..59bb05822d 100644
    --- a/src/psbt.cpp
    +++ b/src/psbt.cpp
    @@ -33,7 +33,7 @@ PartiallySignedTransaction::PartiallySignedTransaction(const CMutableTransaction
     
     bool PartiallySignedTransaction::IsNull() const
     {
    -    return inputs.empty() && outputs.empty() && unknown.empty();
    +    return inputs.empty() && outputs.empty() && !unknown.empty();
     }
    

    </details>

    <details> <summary>Diff for <code>PSBTInput</code></summary>

    diff --git a/src/psbt.cpp b/src/psbt.cpp
    index 8f2e9ab16f..20c745f7a4 100644
    --- a/src/psbt.cpp
    +++ b/src/psbt.cpp
    @@ -291,7 +291,7 @@ COutPoint PSBTInput::GetOutPoint() const
     
     bool PSBTInput::IsNull() const
     {
    -    return !non_witness_utxo && witness_utxo.IsNull() && partial_sigs.empty() && unknown.empty() && hd_keypaths.empty() && redeem_script.empty() && witness_script.empty();
    +    return non_witness_utxo && witness_utxo.IsNull() && partial_sigs.empty() && unknown.empty() && hd_keypaths.empty() && redeem_script.empty() && witness_script.empty();
     }
    

    </details>

    <details> <summary>Diff for <code>PSBTOutput</code></summary>

    diff --git a/src/psbt.cpp b/src/psbt.cpp
    index 8f2e9ab16f..fdfdfe903f 100644
    --- a/src/psbt.cpp
    +++ b/src/psbt.cpp
    @@ -530,7 +530,7 @@ void PSBTOutput::FromSignatureData(const SignatureData& sigdata)
     
     bool PSBTOutput::IsNull() const
     {
    -    return redeem_script.empty() && witness_script.empty() && hd_keypaths.empty() && unknown.empty();
    +    return !redeem_script.empty() && witness_script.empty() && hd_keypaths.empty() && unknown.empty();
     }
    

    </details>

  2. DrahtBot added the label Tests on Jul 30, 2026
  3. DrahtBot commented at 3:49 PM on July 30, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/35848.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process. A summary of reviews will appear here.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #35797 (psbt: support output metadata updates before inputs are added by l0rinc)
    • #35747 (wallet: Fix FillPSBT failing to sign owned inputs when UTXOs disagree by nervana21)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  4. nebula-21 renamed this:
    test: Cover IsNull() for PSBT, PSBTInput, PSBTOutput
    test: Cover `IsNull()` for PSBT, PSBTInput, PSBTOutput
    on Jul 30, 2026
  5. test: Cover IsNull() for PSBT, PSBTInput, PSBTOutput 5be681b00b
  6. nebula-21 force-pushed on Jul 30, 2026
  7. DrahtBot added the label CI failed on Jul 30, 2026
  8. DrahtBot commented at 4:15 PM on July 30, 2026: contributor

    <!--85328a0da195eb286784d51f73fa0af9-->

    🚧 At least one of the CI tasks failed. <sub>Task tidy: https://github.com/bitcoin/bitcoin/actions/runs/30558606139/job/90925472611</sub> <sub>LLM reason (✨ experimental): CI failed because clang-tidy reported a bugprone-argument-comment warning-as-error: the comment argument name amount in test/psbt_tests.cpp doesn’t match the parameter name nValueIn.</sub>

    <details><summary>Hints</summary>

    Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example:

    • Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch.

    • A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test.

    • An intermittent issue.

    Leave a comment here, if you need help tracking down a confusing failure.

    </details>

  9. DrahtBot removed the label CI failed on Jul 30, 2026
  10. jeanpablojp commented at 11:31 PM on August 12, 2026: contributor

    The test works and I have no objections to the code. But other than this PR's test, the only caller of the three IsNull() in the tree is the fuzz target, and I couldn't find any other test in the codebase with this pattern (covering a function with no production use).

    I have a concept question: does it make sense to cover these methods, or would it be better to remove them (and the fuzzer calls)?

  11. maflcko commented at 7:19 AM on August 18, 2026: member

    @nebula-21 Are you still working on this, or can it be closed?

  12. DrahtBot added the label Needs rebase on Aug 18, 2026
  13. DrahtBot commented at 12:12 PM on August 18, 2026: contributor

    <!--cf906140f33d8803c4a75a2196329ecb-->

    🐙 This pull request conflicts with the target branch and needs rebase.

  14. maflcko closed this on Aug 18, 2026

  15. nebula-21 commented at 6:32 PM on August 18, 2026: contributor

    The test works and I have no objections to the code. But other than this PR's test, the only caller of the three IsNull() in the tree is the fuzz target, and I couldn't find any other test in the codebase with this pattern (covering a function with no production use).

    I have a concept question: does it make sense to cover these methods, or would it be better to remove them (and the fuzzer calls)?

    Agree, opened a new PR removing the methods and added you as coauthor.

  16. nebula-21 deleted the branch on Aug 18, 2026

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-08-21 05:51 UTC

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