Skip to content
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

test: replace tx hash with txid in rawtransaction test #16078

Merged
merged 2 commits into from May 24, 2019

Conversation

LongShao007
Copy link
Contributor

The transaction hash is different from txid for witness transactions, so we should use txid instead of hash.

@fanquake fanquake added the Tests label May 23, 2019
@maflcko
Copy link
Member

maflcko commented May 23, 2019

ACK a65dafa

@instagibbs
Copy link
Member

utACK a65dafa

@maflcko
Copy link
Member

maflcko commented May 23, 2019

Please remove the legacy setting with the following diff:

diff --git a/test/functional/rpc_rawtransaction.py b/test/functional/rpc_rawtransaction.py
index 6a23891611..4338675270 100755
--- a/test/functional/rpc_rawtransaction.py
+++ b/test/functional/rpc_rawtransaction.py
@@ -42,7 +42,11 @@ class RawTransactionsTest(BitcoinTestFramework):
     def set_test_params(self):
         self.setup_clean_chain = True
         self.num_nodes = 3
-        self.extra_args = [["-addresstype=legacy", "-txindex"], ["-addresstype=legacy", "-txindex"], ["-addresstype=legacy", "-txindex"]]
+        self.extra_args = [
+            ["-txindex"],
+            ["-txindex"],
+            ["-txindex"],
+        ]
 
     def skip_test_if_missing_module(self):
         self.skip_if_no_wallet()
@@ -438,7 +442,7 @@ class RawTransactionsTest(BitcoinTestFramework):
         rawTx = self.nodes[2].createrawtransaction(inputs, outputs)
         rawTxSigned = self.nodes[2].signrawtransactionwithwallet(rawTx)
         assert_equal(rawTxSigned['complete'], True)
-        # 1000 sat fee, ~200 b transaction, fee rate should land around 5 sat/b = 0.00005000 BTC/kB
+        # 1000 sat fee, ~100 b transaction, fee rate should land around 10 sat/b = 0.00010000 BTC/kB
         # Thus, testmempoolaccept should reject
         testres = self.nodes[2].testmempoolaccept([rawTxSigned['hex']], 0.00001000)[0]
         assert_equal(testres['allowed'], False)
@@ -446,9 +450,9 @@ class RawTransactionsTest(BitcoinTestFramework):
         # and sendrawtransaction should throw
         assert_raises_rpc_error(-26, "absurdly-high-fee", self.nodes[2].sendrawtransaction, rawTxSigned['hex'], 0.00001000)
         # And below calls should both succeed
-        testres = self.nodes[2].testmempoolaccept(rawtxs=[rawTxSigned['hex']], maxfeerate='0.00007000')[0]
+        testres = self.nodes[2].testmempoolaccept(rawtxs=[rawTxSigned['hex']], maxfeerate='0.00070000')[0]
         assert_equal(testres['allowed'], True)
-        self.nodes[2].sendrawtransaction(hexstring=rawTxSigned['hex'], maxfeerate='0.00007000')
+        self.nodes[2].sendrawtransaction(hexstring=rawTxSigned['hex'], maxfeerate='0.00070000')
 
 
 if __name__ == '__main__':

@maflcko maflcko added this to the 0.19.0 milestone May 23, 2019
@maflcko maflcko changed the title replace tx hash with txid in test rawtransaction test: replace tx hash with txid in rawtransaction test May 23, 2019
@gmaxwell
Copy link
Contributor

gmaxwell commented May 24, 2019

Hash is the stronger of the two-- if hash is the same txid will be the same. Is weakening the test the correct change here? (I have no idea, I just don't see a justification).

I am not suggesting that weakening the tests is bad: overly exact tests have greatly diminished value when their exactitude turns them into hyper-active "something changed" detectors when they would otherwise be more useful as "something isn't right" detectors if constructed more in terms of invariants instead of strict behaviour.

As a plea to contributors: The code itself tells us what it does but it less often tells us why. The essential thing for commit messages and pull requests text to do is to tell us why. Of course, summarizing "what" can be good too. "Why" is also essential to review because if the why doesn't make sense the what probably doesn't matter. Sometimes things are really self apparent, but when in doubt no one was ever hurt by a little more explanation.

@sipa
Copy link
Member

sipa commented May 24, 2019

@gmaxwell txid is correct here, as it's about arguments to the gettransansaction RPC. It just happens to work with non-witness transactions, as hash equals txid there.

@gmaxwell
Copy link
Contributor

gmaxwell commented May 24, 2019

@sipa Thanks!

Concept ACK

@LongShao007 LongShao007 force-pushed the pytest branch 2 times, most recently from ed46e91 to 294dd1b Compare May 24, 2019 08:33
@LongShao007
Copy link
Contributor Author

I did it @MarcoFalke

@maflcko maflcko merged commit 0784af1 into bitcoin:master May 24, 2019
maflcko pushed a commit that referenced this pull request May 24, 2019
0784af1 remove parameters -addresstype=legacy in rpc_rawtransaction test (LongShao007)
a65dafa replace tx hash with txid in test rawtransaction (LongShao007)

Pull request description:

  The transaction hash is different from txid for witness transactions, so we should use txid instead of hash.

ACKs for commit 0784af:

Tree-SHA512: 98b699eb5f25c3a603b11eb7072efe9bc69c0c0ecc7f996405de31bc45d92105970e09fd8e4f75b42a46498817f596d36d9b28eae7d24e63a4f2f2abfcee0eab
@maflcko
Copy link
Member

maflcko commented May 24, 2019

Indeed, it would fail (after git revert a65dafa8f1) using the hash instead of the txid:

Traceback (most recent call last):
...
    self.run_test()
  File "./test/functional/rpc_rawtransaction.py", line 369, in run_test
    assert_equal(self.nodes[0].getrawtransaction(txHash), rawTxSigned['hex'])
test_framework.authproxy.JSONRPCException: No such mempool or blockchain transaction. Use gettransaction for wallet transactions. (-5)

sidhujag pushed a commit to syscoin/syscoin that referenced this pull request May 25, 2019
…n test

0784af1 remove parameters -addresstype=legacy in rpc_rawtransaction test (LongShao007)
a65dafa replace tx hash with txid in test rawtransaction (LongShao007)

Pull request description:

  The transaction hash is different from txid for witness transactions, so we should use txid instead of hash.

ACKs for commit 0784af:

Tree-SHA512: 98b699eb5f25c3a603b11eb7072efe9bc69c0c0ecc7f996405de31bc45d92105970e09fd8e4f75b42a46498817f596d36d9b28eae7d24e63a4f2f2abfcee0eab
jasonbcox pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Oct 22, 2020
Summary:
Comment by @sipa:
> txid is correct here, as it's about arguments to the gettransansaction RPC.

This is a partial backport of Core [[bitcoin/bitcoin#16078 | PR16078]]
Commit bitcoin/bitcoin@a65dafa

The next commit is not needed as its changes are overwritten in D8027 / PR16251

See D1556 for why we have additional lines changed.

Test Plan: `ninja && ninja && test/functional/test_runner.py rpc_rawtransaction.py`

Reviewers: O1 Bitcoin ABC, #bitcoin_abc, deadalnix

Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D8050
Munkybooty pushed a commit to Munkybooty/dash that referenced this pull request Oct 17, 2021
…n test

0784af1 remove parameters -addresstype=legacy in rpc_rawtransaction test (LongShao007)
a65dafa replace tx hash with txid in test rawtransaction (LongShao007)

Pull request description:

  The transaction hash is different from txid for witness transactions, so we should use txid instead of hash.

ACKs for commit 0784af:

Tree-SHA512: 98b699eb5f25c3a603b11eb7072efe9bc69c0c0ecc7f996405de31bc45d92105970e09fd8e4f75b42a46498817f596d36d9b28eae7d24e63a4f2f2abfcee0eab
Munkybooty pushed a commit to Munkybooty/dash that referenced this pull request Oct 25, 2021
…n test

0784af1 remove parameters -addresstype=legacy in rpc_rawtransaction test (LongShao007)
a65dafa replace tx hash with txid in test rawtransaction (LongShao007)

Pull request description:

  The transaction hash is different from txid for witness transactions, so we should use txid instead of hash.

ACKs for commit 0784af:

Tree-SHA512: 98b699eb5f25c3a603b11eb7072efe9bc69c0c0ecc7f996405de31bc45d92105970e09fd8e4f75b42a46498817f596d36d9b28eae7d24e63a4f2f2abfcee0eab
Munkybooty pushed a commit to Munkybooty/dash that referenced this pull request Oct 26, 2021
…n test

0784af1 remove parameters -addresstype=legacy in rpc_rawtransaction test (LongShao007)
a65dafa replace tx hash with txid in test rawtransaction (LongShao007)

Pull request description:

  The transaction hash is different from txid for witness transactions, so we should use txid instead of hash.

ACKs for commit 0784af:

Tree-SHA512: 98b699eb5f25c3a603b11eb7072efe9bc69c0c0ecc7f996405de31bc45d92105970e09fd8e4f75b42a46498817f596d36d9b28eae7d24e63a4f2f2abfcee0eab
Munkybooty pushed a commit to Munkybooty/dash that referenced this pull request Nov 9, 2021
…n test

0784af1 remove parameters -addresstype=legacy in rpc_rawtransaction test (LongShao007)
a65dafa replace tx hash with txid in test rawtransaction (LongShao007)

Pull request description:

  The transaction hash is different from txid for witness transactions, so we should use txid instead of hash.

ACKs for commit 0784af:

Tree-SHA512: 98b699eb5f25c3a603b11eb7072efe9bc69c0c0ecc7f996405de31bc45d92105970e09fd8e4f75b42a46498817f596d36d9b28eae7d24e63a4f2f2abfcee0eab
pravblockc pushed a commit to pravblockc/dash that referenced this pull request Nov 18, 2021
…n test

0784af1 remove parameters -addresstype=legacy in rpc_rawtransaction test (LongShao007)
a65dafa replace tx hash with txid in test rawtransaction (LongShao007)

Pull request description:

  The transaction hash is different from txid for witness transactions, so we should use txid instead of hash.

ACKs for commit 0784af:

Tree-SHA512: 98b699eb5f25c3a603b11eb7072efe9bc69c0c0ecc7f996405de31bc45d92105970e09fd8e4f75b42a46498817f596d36d9b28eae7d24e63a4f2f2abfcee0eab
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Dec 16, 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.

None yet

6 participants