Skip to content

Commit d6064a8

Browse files
author
MarcoFalke
committed
Merge #9577: Fix docstrings in qa tests
3f95a80 Fix docstrings in qa tests (John Newbery)
2 parents 7146d96 + 3f95a80 commit d6064a8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+389
-484
lines changed

qa/rpc-tests/abandonconflict.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@
22
# Copyright (c) 2014-2016 The Bitcoin Core developers
33
# Distributed under the MIT software license, see the accompanying
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
5-
5+
"""Test the abandontransaction RPC.
6+
7+
The abandontransaction RPC marks a transaction and all its in-wallet
8+
descendants as abandoned which allows their inputs to be respent. It can be
9+
used to replace "stuck" or evicted transactions. It only works on transactions
10+
which are not included in a block and are not currently in the mempool. It has
11+
no effect on transactions which are already conflicted or abandoned.
12+
"""
613

714
from test_framework.test_framework import BitcoinTestFramework
815
from test_framework.util import *

qa/rpc-tests/assumevalid.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
# Copyright (c) 2014-2016 The Bitcoin Core developers
33
# Distributed under the MIT software license, see the accompanying
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
5-
'''
6-
assumevalid.py
5+
"""Test logic for skipping signature validation on old blocks.
76
87
Test logic for skipping signature validation on blocks which we've assumed
98
valid (https://github.com/bitcoin/bitcoin/pull/9484)
@@ -29,7 +28,7 @@
2928
- node2 has -assumevalid set to the hash of block 102. Try to sync to
3029
block 200. node2 will reject block 102 since it's assumed valid, but it
3130
isn't buried by at least two weeks' work.
32-
'''
31+
"""
3332

3433
from test_framework.mininode import *
3534
from test_framework.test_framework import BitcoinTestFramework

qa/rpc-tests/bip65-cltv-p2p.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@
22
# Copyright (c) 2015-2016 The Bitcoin Core developers
33
# Distributed under the MIT software license, see the accompanying
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
5+
"""Test BIP65 (CHECKLOCKTIMEVERIFY).
6+
7+
Connect to a single node.
8+
Mine 2 (version 3) blocks (save the coinbases for later).
9+
Generate 98 more version 3 blocks, verify the node accepts.
10+
Mine 749 version 4 blocks, verify the node accepts.
11+
Check that the new CLTV rules are not enforced on the 750th version 4 block.
12+
Check that the new CLTV rules are enforced on the 751st version 4 block.
13+
Mine 199 new version blocks.
14+
Mine 1 old-version block.
15+
Mine 1 new version block.
16+
Mine 1 old version block, see that the node rejects.
17+
"""
518

619
from test_framework.test_framework import ComparisonTestFramework
720
from test_framework.util import *
@@ -20,19 +33,6 @@ def cltv_invalidate(tx):
2033
tx.vin[0].scriptSig = CScript([OP_1NEGATE, OP_CHECKLOCKTIMEVERIFY, OP_DROP] +
2134
list(CScript(tx.vin[0].scriptSig)))
2235

23-
'''
24-
This test is meant to exercise BIP65 (CHECKLOCKTIMEVERIFY)
25-
Connect to a single node.
26-
Mine 2 (version 3) blocks (save the coinbases for later).
27-
Generate 98 more version 3 blocks, verify the node accepts.
28-
Mine 749 version 4 blocks, verify the node accepts.
29-
Check that the new CLTV rules are not enforced on the 750th version 4 block.
30-
Check that the new CLTV rules are enforced on the 751st version 4 block.
31-
Mine 199 new version blocks.
32-
Mine 1 old-version block.
33-
Mine 1 new version block.
34-
Mine 1 old version block, see that the node rejects.
35-
'''
3636

3737
class BIP65Test(ComparisonTestFramework):
3838

qa/rpc-tests/bip65-cltv.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22
# Copyright (c) 2015-2016 The Bitcoin Core developers
33
# Distributed under the MIT software license, see the accompanying
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
5-
6-
#
7-
# Test the CHECKLOCKTIMEVERIFY (BIP65) soft-fork logic
8-
#
5+
"""Test the CHECKLOCKTIMEVERIFY (BIP65) soft-fork logic."""
96

107
from test_framework.test_framework import BitcoinTestFramework
118
from test_framework.util import *

qa/rpc-tests/bip68-112-113-p2p.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,8 @@
22
# Copyright (c) 2015-2016 The Bitcoin Core developers
33
# Distributed under the MIT software license, see the accompanying
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
5+
"""Test activation of the first version bits soft fork.
56
6-
from test_framework.test_framework import ComparisonTestFramework
7-
from test_framework.util import *
8-
from test_framework.mininode import ToHex, NetworkThread
9-
from test_framework.blocktools import create_coinbase, create_block
10-
from test_framework.comptool import TestInstance, TestManager
11-
from test_framework.script import *
12-
from io import BytesIO
13-
import time
14-
15-
'''
16-
This test is meant to exercise activation of the first version bits soft fork
177
This soft fork will activate the following BIPS:
188
BIP 68 - nSequence relative lock times
199
BIP 112 - CHECKSEQUENCEVERIFY
@@ -51,7 +41,16 @@
5141
bip112txs_vary_OP_CSV - 16 txs with nSequence = 10 evaluated against varying {relative_locktimes of 10} OP_CSV OP_DROP
5242
bip112txs_vary_OP_CSV_9 - 16 txs with nSequence = 9 evaluated against varying {relative_locktimes of 10} OP_CSV OP_DROP
5343
bip112tx_special - test negative argument to OP_CSV
54-
'''
44+
"""
45+
46+
from test_framework.test_framework import ComparisonTestFramework
47+
from test_framework.util import *
48+
from test_framework.mininode import ToHex, CTransaction, NetworkThread
49+
from test_framework.blocktools import create_coinbase, create_block
50+
from test_framework.comptool import TestInstance, TestManager
51+
from test_framework.script import *
52+
from io import BytesIO
53+
import time
5554

5655
base_relative_locktime = 10
5756
seq_disable_flag = 1<<31

qa/rpc-tests/bip68-sequence.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22
# Copyright (c) 2014-2016 The Bitcoin Core developers
33
# Distributed under the MIT software license, see the accompanying
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
5-
6-
#
7-
# Test BIP68 implementation
8-
#
5+
"""Test BIP68 implementation."""
96

107
from test_framework.test_framework import BitcoinTestFramework
118
from test_framework.util import *

qa/rpc-tests/bip9-softforks.py

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,8 @@
22
# Copyright (c) 2015-2016 The Bitcoin Core developers
33
# Distributed under the MIT software license, see the accompanying
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
5+
"""Test BIP 9 soft forks.
56
6-
from test_framework.blockstore import BlockStore
7-
from test_framework.test_framework import ComparisonTestFramework
8-
from test_framework.util import *
9-
from test_framework.mininode import CTransaction, NetworkThread
10-
from test_framework.blocktools import create_coinbase, create_block
11-
from test_framework.comptool import TestInstance, TestManager
12-
from test_framework.script import CScript, OP_1NEGATE, OP_CHECKSEQUENCEVERIFY, OP_DROP
13-
from io import BytesIO
14-
import time
15-
import itertools
16-
17-
'''
18-
This test is meant to exercise BIP forks
197
Connect to a single node.
208
regtest lock-in with 108/144 block signalling
219
activation after a further 144 blocks
@@ -26,8 +14,18 @@
2614
mine a further 143 blocks (LOCKED_IN)
2715
test that enforcement has not triggered (which triggers ACTIVE)
2816
test that enforcement has triggered
29-
'''
17+
"""
3018

19+
from test_framework.blockstore import BlockStore
20+
from test_framework.test_framework import ComparisonTestFramework
21+
from test_framework.util import *
22+
from test_framework.mininode import CTransaction, NetworkThread
23+
from test_framework.blocktools import create_coinbase, create_block
24+
from test_framework.comptool import TestInstance, TestManager
25+
from test_framework.script import CScript, OP_1NEGATE, OP_CHECKSEQUENCEVERIFY, OP_DROP
26+
from io import BytesIO
27+
import time
28+
import itertools
3129

3230
class BIP9SoftForksTest(ComparisonTestFramework):
3331

@@ -225,21 +223,21 @@ def donothing(self, tx):
225223
return
226224

227225
def csv_invalidate(self, tx):
228-
'''Modify the signature in vin 0 of the tx to fail CSV
226+
"""Modify the signature in vin 0 of the tx to fail CSV
229227
Prepends -1 CSV DROP in the scriptSig itself.
230-
'''
228+
"""
231229
tx.vin[0].scriptSig = CScript([OP_1NEGATE, OP_CHECKSEQUENCEVERIFY, OP_DROP] +
232230
list(CScript(tx.vin[0].scriptSig)))
233231

234232
def sequence_lock_invalidate(self, tx):
235-
'''Modify the nSequence to make it fails once sequence lock rule is activated (high timespan)
236-
'''
233+
"""Modify the nSequence to make it fails once sequence lock rule is
234+
activated (high timespan).
235+
"""
237236
tx.vin[0].nSequence = 0x00FFFFFF
238237
tx.nLockTime = 0
239238

240239
def mtp_invalidate(self, tx):
241-
'''Modify the nLockTime to make it fails once MTP rule is activated
242-
'''
240+
"""Modify the nLockTime to make it fails once MTP rule is activated."""
243241
# Disable Sequence lock, Activate nLockTime
244242
tx.vin[0].nSequence = 0x90FFFFFF
245243
tx.nLockTime = self.last_block_time

qa/rpc-tests/bipdersig-p2p.py

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@
22
# Copyright (c) 2015-2016 The Bitcoin Core developers
33
# Distributed under the MIT software license, see the accompanying
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
5+
"""Test BIP66 (DER SIG).
6+
7+
Connect to a single node.
8+
Mine 2 (version 2) blocks (save the coinbases for later).
9+
Generate 98 more version 2 blocks, verify the node accepts.
10+
Mine 749 version 3 blocks, verify the node accepts.
11+
Check that the new DERSIG rules are not enforced on the 750th version 3 block.
12+
Check that the new DERSIG rules are enforced on the 751st version 3 block.
13+
Mine 199 new version blocks.
14+
Mine 1 old-version block.
15+
Mine 1 new version block.
16+
Mine 1 old version block, see that the node rejects.
17+
"""
518

619
from test_framework.test_framework import ComparisonTestFramework
720
from test_framework.util import *
@@ -15,10 +28,10 @@
1528
# A canonical signature consists of:
1629
# <30> <total len> <02> <len R> <R> <02> <len S> <S> <hashtype>
1730
def unDERify(tx):
18-
'''
31+
"""
1932
Make the signature in vin 0 of a tx non-DER-compliant,
2033
by adding padding after the S-value.
21-
'''
34+
"""
2235
scriptSig = CScript(tx.vin[0].scriptSig)
2336
newscript = []
2437
for i in scriptSig:
@@ -27,20 +40,6 @@ def unDERify(tx):
2740
else:
2841
newscript.append(i)
2942
tx.vin[0].scriptSig = CScript(newscript)
30-
31-
'''
32-
This test is meant to exercise BIP66 (DER SIG).
33-
Connect to a single node.
34-
Mine 2 (version 2) blocks (save the coinbases for later).
35-
Generate 98 more version 2 blocks, verify the node accepts.
36-
Mine 749 version 3 blocks, verify the node accepts.
37-
Check that the new DERSIG rules are not enforced on the 750th version 3 block.
38-
Check that the new DERSIG rules are enforced on the 751st version 3 block.
39-
Mine 199 new version blocks.
40-
Mine 1 old-version block.
41-
Mine 1 new version block.
42-
Mine 1 old version block, see that the node rejects.
43-
'''
4443

4544
class BIP66Test(ComparisonTestFramework):
4645

qa/rpc-tests/bipdersig.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22
# Copyright (c) 2014-2016 The Bitcoin Core developers
33
# Distributed under the MIT software license, see the accompanying
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
5-
6-
#
7-
# Test the BIP66 changeover logic
8-
#
5+
"""Test the BIP66 changeover logic."""
96

107
from test_framework.test_framework import BitcoinTestFramework
118
from test_framework.util import *

qa/rpc-tests/blockchain.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22
# Copyright (c) 2014-2016 The Bitcoin Core developers
33
# Distributed under the MIT software license, see the accompanying
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
5+
"""Test RPCs related to blockchainstate.
56
6-
#
7-
# Test RPC calls related to blockchain state. Tests correspond to code in
8-
# rpc/blockchain.cpp.
9-
#
7+
Test the following RPCs:
8+
- gettxoutsetinfo
9+
- verifychain
10+
11+
Tests correspond to code in rpc/blockchain.cpp.
12+
"""
1013

1114
from decimal import Decimal
1215

@@ -23,13 +26,6 @@
2326

2427

2528
class BlockchainTest(BitcoinTestFramework):
26-
"""
27-
Test blockchain-related RPC calls:
28-
29-
- gettxoutsetinfo
30-
- verifychain
31-
32-
"""
3329

3430
def __init__(self):
3531
super().__init__()

0 commit comments

Comments
 (0)