aboutsummaryrefslogtreecommitdiff
path: root/test/functional/p2p_segwit.py
AgeCommit message (Collapse)Author
2020-08-25[test] Remove final references to mininodeJohn Newbery
2020-08-21scripted-diff: Rename mininode to p2pJohn Newbery
-BEGIN VERIFY SCRIPT- sed -i 's/\.mininode/\.p2p/g' $(git grep -l "mininode") git mv test/functional/test_framework/mininode.py test/functional/test_framework/p2p.py -END VERIFY SCRIPT-
2020-08-21scripted-diff: Rename mininode_lock to p2p_lockJohn Newbery
-BEGIN VERIFY SCRIPT- sed -i 's/mininode_lock/p2p_lock/g' $(git grep -l "mininode_lock") -END VERIFY SCRIPT-
2020-08-11Merge #19674: refactor: test: use throwaway _ variable for unused loop countersfanquake
dac7a111bdd3b0233d94cf68dae7a8bfc6ac9c64 refactor: test: use _ variable for unused loop counters (Sebastian Falbesoner) Pull request description: This tiny PR substitutes Python loops in the form of `for x in range(N): ...` by `for _ in range(N): ...` where applicable. The idea is indicating to the reader that a block (or statement, in list comprehensions) is just repeated N times, and that the loop counter is not used in the body, hence using the throwaway variable. This is already done quite often in the current tests (see e.g. `$ git grep "for _ in range("`). Another alternative would be using `itertools.repeat` (according to Python core developer Raymond Hettinger it's [even faster](https://twitter.com/raymondh/status/1144527183341375488)), but that doesn't seem to be widespread in use and I'm not sure about a readability increase. The only drawback I see is that whenever one wants to debug loop iterations, one would need to introduce a loop variable again. Reviewing this is basically a no-brainer, since tests would fail immediately if a a substitution has taken place on a loop where the variable is used. Instances to replace were found by `$ git grep "for.*in range("` and manually checked. ACKs for top commit: darosior: ACK dac7a111bdd3b0233d94cf68dae7a8bfc6ac9c64 instagibbs: manual inspection ACK https://github.com/bitcoin/bitcoin/pull/19674/commits/dac7a111bdd3b0233d94cf68dae7a8bfc6ac9c64 practicalswift: ACK dac7a111bdd3b0233d94cf68dae7a8bfc6ac9c64 -- the updated code is easier to reason about since the throwaway nature of a variable is expressed explicitly (using the Pythonic `_` idiom) instead of implicitly. Explicit is better than implicit was we all know by now :) Tree-SHA512: 5f43ded9ce14e5e00b3876ec445b90acda1842f813149ae7bafa93f3ac3d510bb778e2c701187fd2c73585e6b87797bb2d2987139bd1a9ba7d58775a59392406
2020-08-09Merge #19649: Restore test case for p2p transaction blindingWladimir J. van der Laan
566aada386e181c2ff40ef18ee660a819f485415 Test that wtxid relay peers add wtxid to reject filter (Gregory Sanders) 0fea6ede1b46f5137e8ea0fbacce169d97e4a5ee Restore test case for p2p transaction blinding (Gregory Sanders) Pull request description: Introduced in ca10a03addf70421893791c2c499e82fc494d60b then erroneously removed in 8d8099e97ab8af2126f6fbd223fbd82c52f2e85e. The restored line is how we are checking that the node will still re-request a specific txid given a witness-related failure. ACKs for top commit: fjahr: tACK 566aada386e181c2ff40ef18ee660a819f485415 Tree-SHA512: be2b75b5eddb88019b79cc798f9922ca7347ccbb2210b8d4eae93fdde62e2cbb614b5247cb2fbd7ee3577dbe053875a9b62c5747aace8617f12790b8fccdeab4
2020-08-07Merge #19620: Add txids with non-standard inputs to reject filterfanquake
9f88ded82b2898ca63d44c08072f1ba52f0e18d7 test addition of unknown segwit spends to txid reject filter (Gregory Sanders) 7989901c7eb62ca28b3d1e5d5831041a7267e495 Add txids with non-standard inputs to reject filter (Suhas Daftuar) Pull request description: Our policy checks for non-standard inputs depend only on the non-witness portion of a transaction: we look up the scriptPubKey of the input being spent from our UTXO set (which is covered by the input txid), and the p2sh checks only rely on the scriptSig portion of the input. Consequently it's safe to add txids of transactions that fail these checks to the reject filter, as the witness is irrelevant to the failure. This is helpful for any situation where we might request the transaction again via txid (either from txid-relay peers, or if we might fetch the transaction via txid due to parent-fetching of orphans). Further, in preparation for future witness versions being deployed on the network, ensure that WITNESS_UNKNOWN transactions are rejected in AreInputsStandard(), so that transactions spending v1 (or greater) witness outputs will fall into this category of having their txid added to the reject filter. ACKs for top commit: ajtowns: ACK 9f88ded82b2898ca63d44c08072f1ba52f0e18d7 - code review jnewbery: Code review ACK 9f88ded82b2898ca63d44c08072f1ba52f0e18d7 ariard: Code Review/Tested ACK 9f88ded naumenkogs: utACK 9f88ded82b2898ca63d44c08072f1ba52f0e18d7 jonatack: ACK 9f88ded82b2 Tree-SHA512: 1e93c0a5b68cb432524780ffc0093db893911fdfed9e2ed17f888e59114cc75d2a07062aefad4e5ce2e87c9270886117a8abb3c78fb889c9b9f31967f1777148
2020-08-06refactor: test: use _ variable for unused loop countersSebastian Falbesoner
substitutes "for x in range(N):" by "for _ in range(N):" indicates to the reader that a block is just repeated N times, and that the loop counter is not used in the body
2020-08-04test addition of unknown segwit spends to txid reject filterGregory Sanders
2020-08-02Test that wtxid relay peers add wtxid to reject filterGregory Sanders
h/t Anthony Towns
2020-08-02Restore test case for p2p transaction blindingGregory Sanders
Introduced in ca10a03addf70421893791c2c499e82fc494d60b then erroneously removed in 8d8099e97ab8af2126f6fbd223fbd82c52f2e85e. The restored line is how we are checking that the node will still re-request a specific txid given a witness-related failure.
2020-07-30test: request parents of orphan from wtxid relay peerAnthony Towns
2020-07-19test: Use wtxid relay generally in functional testsFabian Jahr
2020-07-19test: Add tests for wtxid tx relay in segwit testFabian Jahr
Also cleans up some doublicate lines in the rest of the test. co-authored-by: Anthony Towns <aj@erisian.com.au>
2020-07-19Add support for tx-relay via wtxidSuhas Daftuar
This adds a field to CNodeState that tracks whether to relay transactions with that peer via wtxid, instead of txid. As of this commit the field will always be false, but in a later commit we will add a way to negotiate turning this on via p2p messages exchanged with the peer.
2020-06-22test: refactor functional tests to use restart_nodeChristopher Coverdale
2020-06-02This PR adds initial support for type hints checking in python scripts.Kiminuo
Support for type hints was introduced in Python 3.5. Type hints make it easier to read and review code in my opinion. Also an IDE may discover a potential bug sooner. Yet, as PEP 484 says: "It should also be emphasized that Python will remain a dynamically typed language, and the authors have no desire to ever make type hints mandatory, even by convention." Mypy is used in lint-python.sh to do the type checking. The package is standard so there is little chance that it will be abandoned. Mypy checks that type hints in source code are correct when they are not, it fails with an error. Useful resources: * https://docs.python.org/3.5/library/typing.html * https://www.python.org/dev/peps/pep-0484/
2020-05-07test: replace inv type magic numbers by constantsSebastian Falbesoner
2020-05-01test: Fix intermittent p2p_segwit issueMarcoFalke
2020-04-24Merge #18745: test: Check submitblock return valuesMarcoFalke
fa262712ca0981cb0ee68cd3dd99a214a20dcbf1 test: Check submitblock return values (MarcoFalke) Pull request description: Add `assert_equal` in some tests to check the `submitblock` return value ACKs for top commit: robot-visions: ACK fa262712ca0981cb0ee68cd3dd99a214a20dcbf1 Tree-SHA512: 25d9effe82a4f6852184b9ac848f96336cc2cafb0bb07edb2792f00cd363f0759575bc9c164dd62f64425d3754028b4acd0675600c07d51277aa80bf66c6f960
2020-04-22test: Check submitblock return valuesMarcoFalke
2020-04-22test: check for matching object hashes in wait_for_getdataDanny Lee
2020-04-16scripted-diff: Bump copyright headersMarcoFalke
-BEGIN VERIFY SCRIPT- ./contrib/devtools/copyright_header.py update ./ -END VERIFY SCRIPT-
2020-04-03test: remaining replacements of (send_message+sync_with_ping) with send_and_pingSebastian Falbesoner
2020-04-01test: replace (send_message + sync_with_ping) with send_and_pingJon Atack
2020-03-12Merge #18213: test: Fix race in p2p_segwitMarcoFalke
fa2cf85e6f366d62ebf173bf0bd51af45806afe1 test: Fix race in p2p_segwit (MarcoFalke) Pull request description: Fixes #11696 Top commit has no ACKs. Tree-SHA512: 09de07ea26236547586f5c373a0df2b68d84af5cfa8f40bd2ca9f951fc083c5f4b8a472a60668d99118bbd9f3942ec3d6a34f05944d47345acca41c95475bb27
2020-02-28test: Fix race in p2p_segwitMarcoFalke
Co-Authored-By: Suhas Daftuar <sdaftuar@gmail.com>
2020-02-26test: Reduce unneeded whitelist permissions in testsMarcoFalke
2020-01-23test: Make msg_tx a witness txMarcoFalke
2019-12-06tests: Mark functional tests not supporting bitcoin-cli (--usecli) as suchpracticalswift
2019-11-11test: Use proper MAX_SCRIPT_ELEMENT_SIZEHennadii Stepanov
2019-10-14[test] rename SegwitVersion1SignatureHash()John Newbery
The function implementing segwit v0 signature hash was originally named SegwitVersion1SignatureHash() (presumably before segwit v0 was named segwit v0). Rename it to SegwitV0SignatureHash(). Also rename SignatureHash() to LegacySignatureHash() for disambiguation.
2019-08-14[Consensus] Bury segwit deploymentJohn Newbery
Hardcode segwit deployment height to 481824 for mainnet.
2019-06-21test: Require standard txs in regtestMarcoFalke
2019-06-17Merge #15982: tests: Make msg_block a witness blockMarcoFalke
fa1d766717 tests: Make msg_block a witness block (MarcoFalke) fa52eb55c9 test: Remove True argument to CBlock::serialize (MarcoFalke) Pull request description: Unnamed arguments are confusing as to what they mean without looking up the function signature. Since segwit is active by default in regtest, and all blocks are serialized with witness (#15664), remove the argument `with_witness=True` from all calls to `CBlock::serialize` and `BlockTransactions::serialize`. ACKs for commit fa1d76: laanwj: code-review ACK fa1d7667173eeae363d3729e3fc654057335cb44 Tree-SHA512: 2c550646f99c9ca86a223ca988c61a730f5e6646807adeaa7174fb2424a32cea3fef8bcd3e0b12e162e7ff192877d0c02fd0654df6ee1a9b821b065707c2dcbc
2019-05-14Disallow extended encoding for non-witness transactions (take 3)MarcoFalke
2019-05-08tests: Make msg_block a witness blockMarcoFalke
This diff has been generated with the following script, but is better reviewed without looking at the script. # -BEGIN VERIFY SCRIPT- echo "Use msg_witness_block everywhere, except for tests that require msg_block" # This could be a separate commit, but it is combined with the # following scripts to reduce the overall diff sed -i -e 's/msg_block/msg_witness_block/g' ./test/functional/{feature_assumevalid,feature_cltv,feature_dersig,feature_versionbits_warning,p2p_fingerprint,p2p_sendheaders,p2p_unrequested_blocks,example_test,rpc_blockchain}.py echo "Rename msg_block to msg_no_witness_block" # Rename msg_block to msg_no_witness_block in all tests (not the # framework) sed -i -e 's/msg_block/msg_no_witness_block/g' $(git grep -l msg_block ./test/functional/*.py) # Derive msg_no_witness_block from msg_block # Make msg_block a witness block in messages.py patch -p1 --fuzz 0 << EOF diff --git a/test/functional/test_framework/messages.py b/test/functional/test_framework/messages.py index 00190e4cbd..e454ed5987 100755 --- a/test/functional/test_framework/messages.py +++ b/test/functional/test_framework/messages.py @@ -1133 +1133 @@ class msg_block: - return self.block.serialize(with_witness=False) + return self.block.serialize() @@ -1155 +1155 @@ class msg_generic: -class msg_witness_block(msg_block): +class msg_no_witness_block(msg_block): @@ -1158,2 +1158 @@ class msg_witness_block(msg_block): - r = self.block.serialize() - return r + return self.block.serialize(with_witness=False) @@ -1445 +1444 @@ class msg_blocktxn: - r += self.block_transactions.serialize(with_witness=False) + r += self.block_transactions.serialize() @@ -1452 +1451 @@ class msg_blocktxn: -class msg_witness_blocktxn(msg_blocktxn): +class msg_no_witness_blocktxn(msg_blocktxn): @@ -1456,3 +1455 @@ class msg_witness_blocktxn(msg_blocktxn): - r = b"" - r += self.block_transactions.serialize() - return r + return self.block_transactions.serialize(with_witness=False) EOF # Conclude rename of msg_block to msg_no_witness_block sed -i -e 's/msg_witness_block/msg_block/g' $(git grep -l msg_witness_block) # -END VERIFY SCRIPT-
2019-05-08test: Remove True argument to CBlock::serializeMarcoFalke
Unnamed arguments are confusing as to what they mean without looking up the function signature. Since segwit is active by default in regtest, and all blocks are serialized with witness (#15664, c459c5f), remove the argument `with_witness=True` from all calls to `CBlock::serialize` and `BlockTransactions::serialize`. This diff has been created with a script, but is better reviewed without a scripted diff. sed -i --regexp-extended -e 's/block(_?[2a-z]*)\.serialize\([a-z_]*=?True/block\1.serialize(/g' $(git grep -l serialize ./test)
2019-04-27Merge #15846: [POLICY] Make sending to future native witness outputs standardMeshCollider
c634b1e20 [POLICY] Make sending to future native witness outputs standard (Pieter Wuille) Pull request description: As discussed in the April 18 2019 IRC meeting. This makes sending to future Segwit versions via native outputs (bech32) standard for relay, mempool acceptance, and mining. The reasons are: * This may interfere with smooth adoption of future segwit versions, if they're defined (by the sender wallet/node). * It violates BIP173 ("Version 0 witness addresses are always 42 or 62 characters, but implementations MUST allow the use of any version."), though admittedly this code was written before BIP173. * It doesn't protect much, as P2SH-embedded segwit cannot be filtered in this way. * As a general policy, the sender shouldn't care what the receiver likes his outputs to be. Note that _spending_ such outputs (including P2SH-embedded ones) remains nonstandard, as that is actually required for softfork safety. ACKs for commit c634b1: MarcoFalke: utACK c634b1e2076d8e15a8284638475e26c691d4e100 harding: Tested ACK c634b1e2076d8e15a8284638475e26c691d4e100 meshcollider: utACK https://github.com/bitcoin/bitcoin/pull/15846/commits/c634b1e2076d8e15a8284638475e26c691d4e100 Tree-SHA512: e37168a1be9f445a04d4280593f0a92bdae33eee00ecd803d5eb16acb5c9cfc0f1f0a1dfbd5a0cc73da2c9928ec11cbdac7911513a78f85b789ae0d00e1b5962
2019-04-25Add test for superfluous witness record in deserializationGregory Sanders
2019-04-18[POLICY] Make sending to future native witness outputs standardPieter Wuille
2019-04-18Pure python ECPieter Wuille
This removes the dependency on OpenSSL for the interaction tests, by providing a pure-Python toy implementation of secp256k1.
2019-04-09test: Remove unused importsMarcoFalke
2019-04-09scripted-diff: use self.sync_* methodsMarcoFalke
-BEGIN VERIFY SCRIPT- sed -i -e 's/sync_blocks(self.nodes)/self.sync_blocks()/g' $(git grep -l 'sync_blocks(self.nodes)' ./test/functional/*.py) sed -i -e 's/sync_mempools(self.nodes)/self.sync_mempools()/g' $(git grep -l 'sync_mempools(self.nodes)' ./test/functional/*.py) sed -i -e 's/ sync_blocks(/ self.sync_blocks(/g' $(git grep -l sync_blocks ./test/functional/*.py) sed -i -e 's/ sync_mempools(/ self.sync_mempools(/g' $(git grep -l sync_mempools ./test/functional/*.py) -END VERIFY SCRIPT-
2019-03-02scripted-diff: Update copyright in ./testMarcoFalke
-BEGIN VERIFY SCRIPT- ./contrib/devtools/copyright_header.py update ./test/ -END VERIFY SCRIPT-
2019-03-02scripted-diff: test: Remove brackets after assertMarcoFalke
-BEGIN VERIFY SCRIPT- sed -i --regexp-extended -e 's/assert ?\((.+)\)(( )*)?(#.*)?$/assert \1\3\3\4/g' $(git grep -l --extended-regexp 'assert ?\(' test) -END VERIFY SCRIPT-
2019-03-02scripted-diff: test: Use py3.5 bytes::hex() methodMarcoFalke
-BEGIN VERIFY SCRIPT- sed -i -e "s/def bytes_to_hex_str/def b_2_x/g" $(git grep -l bytes_to_hex_str) export RE_B_0="[^()]*" # match no bracket export RE_B_1="${RE_B_0}\(${RE_B_0}\)${RE_B_0}" # match exactly one () export RE_B_2="${RE_B_0}\(${RE_B_1}\)${RE_B_0}" # match wrapped (()) export RE_M="(b2x|bytes_to_hex_str)\(((${RE_B_0}|${RE_B_1}|${RE_B_2})*)\)" sed -i --regexp-extended -e "s/${RE_M}/\2.hex()/g" $(git grep -l -E '(b2x|bytes_to_hex_str)') sed -i --regexp-extended -e "/ +bytes_to_hex_str( as b2x)?,/d" $(git grep -l bytes_to_hex_str) sed -i --regexp-extended -e "s/ +bytes_to_hex_str( as b2x)?,//g" $(git grep -l bytes_to_hex_str) sed -i --regexp-extended -e "s/, bytes_to_hex_str( as b2x)?//g" $(git grep -l bytes_to_hex_str) export RE_M="(binascii\.)?hexlify\(((${RE_B_0}|${RE_B_1}|${RE_B_2})*)\).decode\(${RE_B_0}\)" sed -i --regexp-extended -e "s/${RE_M}/\2.hex()/g" $(git grep -l hexlify -- ':(exclude)share') sed -i --regexp-extended -e "/from binascii import hexlify$/d" $(git grep -l hexlify -- ':(exclude)share') sed -i --regexp-extended -e "s/(from binascii import) .*hexlify/\1 unhexlify/g" $(git grep -l hexlify -- ':(exclude)share') sed -i -e 's/ignore-names "/ignore-names "b_2_x,/g' ./test/lint/lint-python-dead-code.sh -END VERIFY SCRIPT-
2019-01-22Default -whitelistforcerelay to offSuhas Daftuar
2018-12-10[mining] segwit option must be set in GBTJohn Newbery
Calling getblocktemplate without the segwit rule specified is most likely a client error, since it results in lower fees for the miner. Prevent this client error by failing getblocktemplate if called without the segwit rule specified.
2018-09-26Check for specific tx acceptance failures based on script signatureJustin Turner Arthur
2018-09-23Fix for incorrect version attr set on functional test segwit block.Justin Turner Arthur