Commit graph

33 commits

Author SHA1 Message Date
Seleme Topuz
1343c86c7c test: Update wait_until usage in tests not to use the one from utils
Replace "wait_until()" usage from utils, with the ones from BitcoinTestFramework and P2PInterface.
closes #19080
2020-08-26 18:01:59 +02:00
John Newbery
85165d4332 scripted-diff: Rename mininode to p2p
-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-21 15:52:20 +01:00
John Newbery
9e2897d020 scripted-diff: Rename mininode_lock to p2p_lock
-BEGIN VERIFY SCRIPT-
sed -i 's/mininode_lock/p2p_lock/g' $(git grep -l "mininode_lock")
-END VERIFY SCRIPT-
2020-08-21 15:52:13 +01:00
fanquake
cb1ee1551c
Merge #19674: refactor: test: use throwaway _ variable for unused loop counters
dac7a111bd 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 dac7a111bd
  instagibbs:
    manual inspection ACK dac7a111bd
  practicalswift:
    ACK dac7a111bd -- 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-11 09:24:50 +08:00
Sebastian Falbesoner
dac7a111bd refactor: test: use _ variable for unused loop counters
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-06 18:39:33 +02:00
Ben Woosley
9e165d0de4
test: Wait for 'cmpctblock' in p2p_compactblocks when it is expected
This is a more narrowly-construed wait which eliminates the possibility of the
wait being triggered by other messages.

Co-authored-by: Billy Garrison <billygarrison.btc@gmail.com>
2020-07-30 16:13:48 -07:00
John Newbery
edae6075aa [tests] Only acquire lock once in p2p_compactblocks.py 2020-06-05 10:57:13 -04:00
Sebastian Falbesoner
b35e1d2471 test: add inventory type constant MSG_CMPCT_BLOCK 2020-05-07 14:34:55 +02:00
Sebastian Falbesoner
eeaaa58d2c test: replace inv type magic numbers by constants 2020-05-07 14:34:55 +02:00
Sebastian Falbesoner
c4027e7350 refactor: test: use wait_for_getdata() in p2p_compactblocks.py 2020-04-24 13:55:20 +02:00
John Newbery
0328dcdcfc [Consensus] Bury segwit deployment
Hardcode segwit deployment height to 481824 for mainnet.
2019-08-14 15:52:52 -04:00
MarcoFalke
fa89badf88
test: Require standard txs in regtest 2019-06-21 16:45:16 -04:00
MarcoFalke
fa1d766717
tests: Make msg_block a witness block
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-08 11:53:02 -04:00
Suhas Daftuar
7813eb1db1 [qa] Overhaul p2p_compactblocks.py
Remove tests of:
 - compactblock behavior in a simulated pre-segwit version of bitcoind
   This should have been removed a long time ago, as it is not generally
   necessary for us to test the behavior of old nodes (except perhaps if we
   want to test that upgrading from an old node to a new one behaves properly)

 - compactblock behavior during segwit upgrade (ie verifying that network
   behavior before and after activation was as expected)
   This is unnecessary to test now that segwit activation has already happened.

Includes changes by John Newbery.
2019-04-01 17:08:54 -04:00
MarcoFalke
faa7cdf764
scripted-diff: Update copyright in ./test
-BEGIN VERIFY SCRIPT-
./contrib/devtools/copyright_header.py update ./test/
-END VERIFY SCRIPT-
2019-03-02 10:58:35 -05:00
MarcoFalke
fa0e65b772
scripted-diff: test: Remove brackets after assert
-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-02 10:51:35 -05:00
MarcoFalke
9dda5fdf64
Merge #14296: [wallet] Remove addwitnessaddress
2b91e42ece [docs] Add release note for removing getwitnessaddress (John Newbery)
ebec90ac97 [wallet] Remove deprecated addwitnessaddress RPC method (John Newbery)
07e3f585ab [test] Remove deprecated addwitnessaddress from feature_segwit.py (John Newbery)
82f2fa03a5 [test] Remove deprecated addwitnessaddress from wallet_bumpfee.py (John Newbery)
9d7ee187a3 [test] Remove deprecated addwitnessaddress from p2p_compactblocks.py (John Newbery)
3cf77f0b3e [tests] Remove deprecated addwitnessaddress call from wallet_dump.py (John Newbery)
bdefc9705d [tests] Remove deprecated addwitnessaddress call from feature_nulldummy (John Newbery)
67d7d67cf3 [test] Fix flake8 warnings in tests (John Newbery)

Pull request description:

  Fully removes the `addwitnessaddress` RPC method, which was deprecated in V0.17

Tree-SHA512: 8fa8a2a721a81262fbdedbe1cef031e6a07aa6abbc9760dbc62738fc4f688b44bd737d0f3cdb1aec046866a6395befbfecde0f34e76a99e11d3cf566cad1d0de
2018-10-24 08:09:48 -04:00
MarcoFalke
37612099ec
Merge #13424: Consistently validate txid / blockhash length and encoding in rpc calls
5eb20f81d9 Consistently use ParseHashV to validate hash inputs in rpc (Ben Woosley)

Pull request description:

  ParseHashV validates the length and encoding of the string and throws
  an informative RPC error on failure, which is as good or better than
  these alternative calls.

  Note I switched ParseHashV to check string length first, because
  IsHex tests that the length is even, and an error like:
  "must be of length 64 (not 63, for X)" is much more informative than
  "must be hexadecimal string (not X)" in that case.

  Split from #13420

Tree-SHA512: f0786b41c0d7793ff76e4b2bb35547873070bbf7561d510029e8edb93f59176277efcd4d183b3185532ea69fc0bbbf3dbe9e19362e8017007ae9d51266cd78ae
2018-09-24 15:09:11 -04:00
John Newbery
9d7ee187a3 [test] Remove deprecated addwitnessaddress from p2p_compactblocks.py 2018-09-23 08:51:57 -04:00
John Newbery
67d7d67cf3 [test] Fix flake8 warnings in tests
Fix all flake8 warnings in tests that are about to be updated
to remove addwitnessaddress
2018-09-23 08:50:47 -04:00
MarcoFalke
fac9539836
qa: Run all tests even if wallet is not compiled 2018-09-10 17:53:21 -04:00
practicalswift
68400d8b96 tests: Use explicit imports 2018-08-13 14:13:39 +02:00
MarcoFalke
8ac7125d59
Merge #13916: qa: wait_for_verack by default
fa5587fe71 qa: wait_for_verack by default (MarcoFalke)

Pull request description:

  This removes the need to do so manually every time a connection is added.

Tree-SHA512: a46c92cb4df41e30778b42b9fd3dcbd8d2d82aa7503d1213cb1c1165034f648d8caee01c292e2d87d05b0f71696996eef5be8a753f35ab49e5f66b0e3bf29f21
2018-08-09 08:07:28 -04:00
MarcoFalke
fa5587fe71
qa: wait_for_verack by default 2018-08-08 17:22:35 -04:00
Ben Woosley
5eb20f81d9
Consistently use ParseHashV to validate hash inputs in rpc
ParseHashV validates the length and encoding of the string and throws
an informative RPC error on failure, which is as good or better than
these alternative calls.

Note I switched ParseHashV to check string length first, because
IsHex tests that the length is even, and an error like:
"must be of length 64 (not 63, for X)" is much more informative than
"must be hexadecimal string (not X)"
2018-08-07 12:47:39 -04:00
DrahtBot
eb7daf4d60 Update copyright headers to 2018 2018-07-27 07:15:02 -04:00
MarcoFalke
fa87da2f17
qa: Avoid start/stop of the network thread mid-test 2018-06-25 14:06:41 -04:00
MarcoFalke
fa1eac9cdb
[qa] mininode: Expose connection state through is_connected 2018-06-22 12:00:00 -04:00
MarcoFalke
364bae5f7a qa: Pad scriptPubKeys to get minimum sized txs 2018-05-05 04:59:55 +08:00
MarcoFalke
4ad3b3c72c
Merge #12716: Fix typos and cleanup in various files
4d9b4256d8 Fix typos (Dimitris Apostolou)

Pull request description:

  Unfortunately I messed up my repo while trying to squash #12593 so I created a PR with just the correct fixes.

Tree-SHA512: 295d77b51bd2a9381f1802c263de7ffb2edd670d9647391e32f9a414705b3c8b483bb0e469a9b85ab6a70919ea13397fa8dfda2aea7a398b64b187f178fe6a06
2018-03-21 11:17:43 -04:00
Dimitris Apostolou
4d9b4256d8 Fix typos 2018-03-21 08:34:44 +02:00
John Newbery
728667b771 scripted-diff: rename TestNode to TestP2PConn in tests
Several test scripts define a subclass of P2PInterface called TestNode.
This commit renames those to TestP2PConn since we already have a
TestNode class in the test framework.

-BEGIN VERIFY SCRIPT-
sed -i s/TestNode/TestP2PConn/ test/functional/*py test/functional/test_framework/comptool.py
_END VERIFY SCRIPT-
2018-03-19 14:58:00 -04:00
Anthony Towns
61b8f7f273 [tests] Rename p2p_* functional tests. 2018-01-25 09:44:29 +10:00
Renamed from test/functional/p2p-compactblocks.py (Browse further)