Add bitcoin-tx JSON tests #8829

pull jnewbery wants to merge 1 commits into bitcoin:master from jnewbery:test-bitcoin-tx-json changing 12 files +997 −1
  1. jnewbery commented at 5:39 PM on September 28, 2016: member

    This PR adds new test cases to test bitcoin-tx JSON output, as suggested by @sipa in #8817 .

  2. Add bitcoin-tx JSON tests 54e5d7c1b8
  3. MarcoFalke added the label Tests on Sep 28, 2016
  4. jnewbery cross-referenced this on Sep 28, 2016 from issue [test] Add option to run bitcoin-util-test.py manually by jnewbery
  5. jnewbery cross-referenced this on Sep 28, 2016 from issue update bitcoin-tx to output witness data by jnewbery
  6. laanwj commented at 6:16 AM on September 29, 2016: member
  7. MarcoFalke commented at 8:43 AM on September 29, 2016: member

    utACK 54e5d7c1b81e1b76f5789abfa2cb1f5963cd9d72

  8. MarcoFalke merged this on Sep 29, 2016
  9. MarcoFalke closed this on Sep 29, 2016

  10. MarcoFalke referenced this in commit 8ca69a2a88 on Sep 29, 2016
  11. MarcoFalke added the label Needs backport on Sep 29, 2016
  12. MarcoFalke added this to the milestone 0.13.1 on Sep 29, 2016
  13. paveljanik commented at 9:00 AM on September 29, 2016: contributor

    ups, merged in the middle of my testing :-)

    postmerge ACK https://github.com/bitcoin/bitcoin/commit/54e5d7c1b81e1b76f5789abfa2cb1f5963cd9d72

  14. droark commented at 11:32 AM on September 29, 2016: contributor

    Question: Was txcreate2.json supposed to be empty? I'm assuming some test data was supposed to be in it. :)

  15. jnewbery commented at 12:35 PM on September 29, 2016: member

    Interesting. The txcreate2 test is attempting to create a transaction with a single pay-to-script output for zero satoshi. When outputting as json, bitcoin-tx returns the empty string. When outputting as hex, it returns 01000000000100000000000000000000000000, ie:

    version |number in|number out|out1 amount     |out1 script length|nlocktime
    01000000 00        01         0000000000000000 00                 00000000
    

    I think that's garbage and bitcoin-tx should reject any attempt to add an output with zero satoshi. I'll open a PR to fix that.

    Interestingly, bitcoin-tx does output a json object if I try to create a zero-value transaction output to a non-empty script:

    $ bitcoin-tx -json -create outscript=0:"OP_DROP"
    {
        "txid": "f0851b68202f736b792649cfc960259c2374badcb644ab20cac726b5f72f61c9",
        "version": 1,
        "locktime": 0,
        "vin": [
        ],
        "vout": [
            {
                "value": 0.00,
                "n": 0,
                "scriptPubKey": {
                    "asm": "OP_DROP",
                    "hex": "75",
                    "type": "nonstandard"
                }
            }
        ],
        "hex": "0100000000010000000000000000017500000000"
    }
    

    txcreate2 is also the only test case that tests creating a pay-to-script, so we should add a new test case that tests adding a valid pay-to-script output.

  16. jnewbery deleted the branch on Sep 29, 2016
  17. sipa commented at 12:39 PM on September 29, 2016: member

    Zero-value outputs are perfectly valid according to consensus rules.

  18. jnewbery commented at 12:45 PM on September 29, 2016: member

    ah, ok. Thanks. Then the fix is in bitcoin-tx to properly output zero-value, empty-script outputs.

  19. laanwj commented at 12:48 PM on September 29, 2016: member

    Good to see that we're finding bugs in bitcoin-tx by adding tests :)

  20. jnewbery commented at 1:02 PM on September 29, 2016: member

    I've mischaracterised the problem here. bitcoin-tx is outputting the transaction correctly in hex and json. However, when I try to pipe that same hex transaction back into bitcoin-tx, it fails with error: invalid transaction encoding.

  21. sipa commented at 1:09 PM on September 29, 2016: member

    Ah, that seems to be due to the segwit ambiguity for 0-input transactions. IIRC, DecodeTransaction in core_io.h has a boolean parameter for attempting to decode partial transactions. It should be set to true in calls from bitcoin-tx.

  22. jnewbery commented at 2:29 PM on September 29, 2016: member

    Thanks @sipa . New PR here: #8837 to make bitcoin-tx set the flag correctly and parse partial transactions. @droark - I've added #8836 to fix the fact that bitcoin-util-test.py would always succeed if the output comparison file was empty. That PR also fixes txcreate2.json so it's no longer empty.

  23. MarcoFalke referenced this in commit 2a8bca465d on Oct 3, 2016
  24. MarcoFalke removed the label Needs backport on Oct 13, 2016
  25. laanwj commented at 6:04 PM on October 13, 2016: member

    This was backported in #8832, removing tag

  26. codablock referenced this in commit 1eba1e1962 on Sep 19, 2017
  27. codablock referenced this in commit 963f6a6f3a on Jan 12, 2018
  28. dagurval cross-referenced this on Apr 27, 2018 from issue bitcoin-tx JSON tests + test util improvements by dagurval
  29. lateminer referenced this in commit c7f6a2e815 on Nov 10, 2018
  30. andvgal referenced this in commit c13d3c3fa1 on Jan 6, 2019
  31. str4d cross-referenced this on Oct 28, 2020 from issue bitcoin-util-test.py backports by str4d
  32. zkbot referenced this in commit 44f5ef7c9d on Nov 9, 2020
  33. zkbot referenced this in commit bd5ff7c889 on Nov 9, 2020
  34. bitcoin 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: 2026-05-19 06:55 UTC