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. laanwj commented at 6:16 am on September 29, 2016: member
  5. MarcoFalke commented at 8:43 am on September 29, 2016: member
    utACK 54e5d7c1b81e1b76f5789abfa2cb1f5963cd9d72
  6. MarcoFalke merged this on Sep 29, 2016
  7. MarcoFalke closed this on Sep 29, 2016

  8. MarcoFalke referenced this in commit 8ca69a2a88 on Sep 29, 2016
  9. MarcoFalke added the label Needs backport on Sep 29, 2016
  10. MarcoFalke added this to the milestone 0.13.1 on Sep 29, 2016
  11. 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

  12. 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. :)
  13. 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:

    0version |number in|number out|out1 amount     |out1 script length|nlocktime
    101000000 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:

     0$ bitcoin-tx -json -create outscript=0:"OP_DROP"
     1{
     2    "txid": "f0851b68202f736b792649cfc960259c2374badcb644ab20cac726b5f72f61c9",
     3    "version": 1,
     4    "locktime": 0,
     5    "vin": [
     6    ],
     7    "vout": [
     8        {
     9            "value": 0.00,
    10            "n": 0,
    11            "scriptPubKey": {
    12                "asm": "OP_DROP",
    13                "hex": "75",
    14                "type": "nonstandard"
    15            }
    16        }
    17    ],
    18    "hex": "0100000000010000000000000000017500000000"
    19}
    

    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.

  14. jnewbery deleted the branch on Sep 29, 2016
  15. sipa commented at 12:39 pm on September 29, 2016: member
    Zero-value outputs are perfectly valid according to consensus rules.
  16. 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.
  17. 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 :)
  18. 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.
  19. 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.
  20. 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.
  21. MarcoFalke referenced this in commit 2a8bca465d on Oct 3, 2016
  22. MarcoFalke removed the label Needs backport on Oct 13, 2016
  23. laanwj commented at 6:04 pm on October 13, 2016: member
    This was backported in #8832, removing tag
  24. codablock referenced this in commit 1eba1e1962 on Sep 19, 2017
  25. codablock referenced this in commit 963f6a6f3a on Jan 12, 2018
  26. lateminer referenced this in commit c7f6a2e815 on Nov 10, 2018
  27. andvgal referenced this in commit c13d3c3fa1 on Jan 6, 2019
  28. zkbot referenced this in commit 44f5ef7c9d on Nov 9, 2020
  29. zkbot referenced this in commit bd5ff7c889 on Nov 9, 2020
  30. 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 12:12 UTC

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