Fix and improve txn_doublespend.py test #5881

pull dgenr8 wants to merge 3 commits into bitcoin:master from dgenr8:better_doublespend_test changing 6 files +234 −27
  1. dgenr8 commented at 1:22 am on March 12, 2015: contributor

    The first commit illustrates a problem with the current txn_doublespend.py test. The test relies on unsupportable behavior in the wallet’s SyncMetaData method. The test is made to produce inconsistent results by making a small change to specific test “amount” parameters.

    The second commit introduces a primitive method CTransaction::IsEquivalentTo and uses it in the wallet to ensure that SyncMetaData is only called for malleability clones, not general conflict (doublespend) transactions. This makes the output of the illustrative version of txn_doublespend.py consistent and predictable.

    The third commit is a revised txn_doublespend.py test that does not rely on broken SyncMetaData. Instead, it expects the fixed version of SyncMetaData. It also removes a dependency on the soon-to-be-deprecated accounting “move” method.

  2. jonasschnelli commented at 7:30 am on March 12, 2015: contributor
    utACK. Travis fails test_bitcoin: chainparams.cpp:286: const CChainParams& Params(): Assertion 'pCurrentParams' failed.. You probably need to rebase because there was a travis error after a certain commit on master.
  3. dgenr8 force-pushed on Mar 12, 2015
  4. laanwj added the label Wallet on Mar 13, 2015
  5. gavinandresen commented at 8:28 pm on March 18, 2015: contributor

    I don’t like the new unit test– you are testing the new "" account gets debited on a non-malleated doublespend.

    But our wallet code will never produce a non-malleated double-spend (at least not without the user jumping through some hoops to copy the wallet to two machines, etc etc etc).

    I’d be happier if the new unit test tested the new code, and created a malleated version of the spend-to-foo and made sure The Right Thing happened.

    I’m also uncertain about changing the SyncMetaData behavior to only work for malleated transactions, but I think I can live with that (mostly because what you get depends on the order your node sees transactions, accounts are being deprecated, and non-malleated double-spends of a “spendfrom” should never happen unless you jump through hoops).

  6. dgenr8 force-pushed on Mar 24, 2015
  7. dgenr8 force-pushed on Mar 24, 2015
  8. dgenr8 commented at 4:28 am on March 24, 2015: contributor

    Per @gavinandresen review:

    • Improved implementation of IsEquivalentTo
    • Added txn_clone.py, which tests malleability clone accounting
    • Updated rpc-tests.sh to call the new test with and without the –mineblock option

    The new test relies on setting nlocktime via createrawtransaction. There is also a stand-alone #5936 for this change.

  9. Implement CTransaction::IsEquivalentTo(...)
    Define CTransaction::IsEquivalentTo(const CTransaction& tx)
    
    True if only scriptSigs are different.  In other words, true if
    the two transactions are malleability clones.  In other words,
    true if the two transactions have the same effect on the
    outside universe.
    
    In the wallet, only SyncMetaData for equivalent transactions.
    b2b3619262
  10. Better txn_doublespend.py test
    Remove reliance on accounting "move" ledger entries.  Instead,
    create funding transactions (and deal with fee complexities).
    
    Do not rely on broken SyncMetaData.  Instead expect double-spend
    amount to be debited from the default "" account.
    defd2d55b7
  11. dgenr8 force-pushed on Apr 12, 2015
  12. dgenr8 commented at 2:35 am on April 12, 2015: contributor
    • Problem illustration squashed, archived here.
    • txn_clone.py updated to use rpc generate(…)
  13. laanwj commented at 10:34 am on April 15, 2015: member
    ACK on new test, for discussion with regard to adding a field to createrawtransaction RPC see #5936
  14. laanwj added the label Tests on Apr 15, 2015
  15. dgenr8 force-pushed on May 12, 2015
  16. dgenr8 commented at 0:08 am on May 12, 2015: contributor
    Removed the change to createrawtransaction.
  17. Add txn_clone.py test
    Does what the old txnmall.sh test did.
    
    Creates an equivalent malleated clone and tests that SyncMetaData
    syncs the accounting effects from the original transaction to the
    confirmed clone.
    5d34e16d3a
  18. dgenr8 force-pushed on May 12, 2015
  19. laanwj merged this on Jul 2, 2015
  20. laanwj closed this on Jul 2, 2015

  21. laanwj referenced this in commit 3203a0832a on Jul 2, 2015
  22. laanwj referenced this in commit 3f16971442 on Jul 2, 2015
  23. laanwj referenced this in commit 5a7304b69d on Jul 2, 2015
  24. jonasschnelli referenced this in commit c9e5cf9688 on Jul 8, 2015
  25. zkbot referenced this in commit 57d420e2f8 on Feb 15, 2017
  26. zkbot referenced this in commit 88c209dba6 on Feb 20, 2017
  27. dgenr8 deleted the branch on Sep 19, 2018
  28. DrahtBot locked this on Sep 8, 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: 2024-12-19 00:12 UTC

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