Skip to content

Add bitcoin-tx JSON tests #8829

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 29, 2016
Merged

Conversation

jnewbery
Copy link
Contributor

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

@laanwj
Copy link
Member

laanwj commented Sep 29, 2016

Awesome, thanks!
utACK 54e5d7c

@maflcko
Copy link
Member

maflcko commented Sep 29, 2016

utACK 54e5d7c

@maflcko maflcko merged commit 54e5d7c into bitcoin:master Sep 29, 2016
maflcko pushed a commit that referenced this pull request Sep 29, 2016
54e5d7c Add bitcoin-tx JSON tests (jnewbery)
@maflcko maflcko added this to the 0.13.1 milestone Sep 29, 2016
@paveljanik
Copy link
Contributor

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

postmerge ACK 54e5d7c

@droark
Copy link
Contributor

droark commented Sep 29, 2016

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

@jnewbery
Copy link
Contributor Author

jnewbery commented Sep 29, 2016

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.

@jnewbery jnewbery deleted the test-bitcoin-tx-json branch September 29, 2016 12:36
@sipa
Copy link
Member

sipa commented Sep 29, 2016 via email

@jnewbery
Copy link
Contributor Author

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

@laanwj
Copy link
Member

laanwj commented Sep 29, 2016

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

@jnewbery
Copy link
Contributor Author

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.

@sipa
Copy link
Member

sipa commented Sep 29, 2016 via email

@jnewbery
Copy link
Contributor Author

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.

maflcko pushed a commit to maflcko/bitcoin-core that referenced this pull request Oct 3, 2016
Github-Pull: bitcoin#8829
Rebased-From: 54e5d7c
@laanwj
Copy link
Member

laanwj commented Oct 13, 2016

This was backported in #8832, removing tag

codablock pushed a commit to codablock/dash that referenced this pull request Jan 12, 2018
54e5d7c Add bitcoin-tx JSON tests (jnewbery)
lateminer pushed a commit to lateminer/bitcoin that referenced this pull request Nov 10, 2018
Github-Pull: bitcoin#8829
Rebased-From: 54e5d7c
andvgal pushed a commit to energicryptocurrency/gen2-energi that referenced this pull request Jan 6, 2019
54e5d7c Add bitcoin-tx JSON tests (jnewbery)
zkbot added a commit to zcash/zcash that referenced this pull request Nov 9, 2020
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants