Browse Source

Fix docstrings in qa tests

This commit fixes the module-level docstrings for the tests and helper
modules in qa. Many of these tests were uncommented previously - this
commit ensures that every test case has at least a minimum level of
commenting.
0.15
John Newbery 8 years ago
parent
commit
3f95a806b1
  1. 9
      qa/rpc-tests/abandonconflict.py
  2. 5
      qa/rpc-tests/assumevalid.py
  3. 26
      qa/rpc-tests/bip65-cltv-p2p.py
  4. 5
      qa/rpc-tests/bip65-cltv.py
  5. 23
      qa/rpc-tests/bip68-112-113-p2p.py
  6. 5
      qa/rpc-tests/bip68-sequence.py
  7. 38
      qa/rpc-tests/bip9-softforks.py
  8. 31
      qa/rpc-tests/bipdersig-p2p.py
  9. 5
      qa/rpc-tests/bipdersig.py
  10. 18
      qa/rpc-tests/blockchain.py
  11. 1
      qa/rpc-tests/bumpfee.py
  12. 9
      qa/rpc-tests/create_cache.py
  13. 4
      qa/rpc-tests/decodescript.py
  14. 8
      qa/rpc-tests/disablewallet.py
  15. 5
      qa/rpc-tests/forknotify.py
  16. 1
      qa/rpc-tests/fundrawtransaction.py
  17. 5
      qa/rpc-tests/getblocktemplate_longpoll.py
  18. 4
      qa/rpc-tests/getblocktemplate_proposals.py
  19. 9
      qa/rpc-tests/getchaintips.py
  20. 5
      qa/rpc-tests/httpbasics.py
  21. 4
      qa/rpc-tests/import-rescan.py
  22. 2
      qa/rpc-tests/importmulti.py
  23. 2
      qa/rpc-tests/importprunedfunds.py
  24. 5
      qa/rpc-tests/invalidateblock.py
  25. 17
      qa/rpc-tests/invalidblockrequest.py
  26. 7
      qa/rpc-tests/invalidtxrequest.py
  27. 3
      qa/rpc-tests/keypool.py
  28. 1
      qa/rpc-tests/listsinceblock.py
  29. 3
      qa/rpc-tests/listtransactions.py
  30. 13
      qa/rpc-tests/maxblocksinflight.py
  31. 16
      qa/rpc-tests/maxuploadtarget.py
  32. 3
      qa/rpc-tests/mempool_limit.py
  33. 3
      qa/rpc-tests/mempool_packages.py
  34. 8
      qa/rpc-tests/mempool_reorg.py
  35. 6
      qa/rpc-tests/mempool_resurrect_test.py
  36. 19
      qa/rpc-tests/mempool_spendcoinbase.py
  37. 5
      qa/rpc-tests/merkle_blocks.py
  38. 5
      qa/rpc-tests/multi_rpc.py
  39. 5
      qa/rpc-tests/nodehandling.py
  40. 21
      qa/rpc-tests/nulldummy.py
  41. 18
      qa/rpc-tests/p2p-acceptblock.py
  42. 12
      qa/rpc-tests/p2p-compactblocks.py
  43. 5
      qa/rpc-tests/p2p-feefilter.py
  44. 16
      qa/rpc-tests/p2p-fullblocktest.py
  45. 14
      qa/rpc-tests/p2p-leaktests.py
  46. 5
      qa/rpc-tests/p2p-mempool.py
  47. 4
      qa/rpc-tests/p2p-segwit.py
  48. 2
      qa/rpc-tests/p2p-timeouts.py
  49. 12
      qa/rpc-tests/p2p-versionbits-warning.py
  50. 5
      qa/rpc-tests/preciousblock.py
  51. 5
      qa/rpc-tests/prioritise_transaction.py
  52. 29
      qa/rpc-tests/proxy_test.py
  53. 12
      qa/rpc-tests/pruning.py
  54. 16
      qa/rpc-tests/rawtransactions.py
  55. 4
      qa/rpc-tests/receivedby.py
  56. 9
      qa/rpc-tests/reindex.py
  57. 7
      qa/rpc-tests/replace-by-fee.py
  58. 6
      qa/rpc-tests/rest.py
  59. 3
      qa/rpc-tests/rpcbind_test.py
  60. 1
      qa/rpc-tests/rpcnamedargs.py
  61. 5
      qa/rpc-tests/segwit.py
  62. 17
      qa/rpc-tests/sendheaders.py
  63. 3
      qa/rpc-tests/signmessages.py
  64. 7
      qa/rpc-tests/signrawtransactions.py
  65. 21
      qa/rpc-tests/smartfees.py
  66. 7
      qa/rpc-tests/test_framework/address.py
  67. 67
      qa/rpc-tests/test_framework/authproxy.py
  68. 10
      qa/rpc-tests/test_framework/bignum.py
  69. 12
      qa/rpc-tests/test_framework/blockstore.py
  70. 2
      qa/rpc-tests/test_framework/blocktools.py
  71. 33
      qa/rpc-tests/test_framework/comptool.py
  72. 9
      qa/rpc-tests/test_framework/coverage.py
  73. 10
      qa/rpc-tests/test_framework/key.py
  74. 32
      qa/rpc-tests/test_framework/mininode.py
  75. 5
      qa/rpc-tests/test_framework/netutil.py
  76. 12
      qa/rpc-tests/test_framework/script.py
  77. 7
      qa/rpc-tests/test_framework/siphash.py
  78. 14
      qa/rpc-tests/test_framework/socks5.py
  79. 3
      qa/rpc-tests/test_framework/test_framework.py
  80. 6
      qa/rpc-tests/test_framework/util.py
  81. 5
      qa/rpc-tests/txn_clone.py
  82. 5
      qa/rpc-tests/txn_doublespend.py
  83. 10
      qa/rpc-tests/wallet-accounts.py
  84. 1
      qa/rpc-tests/wallet-dump.py
  85. 1
      qa/rpc-tests/wallet-hd.py
  86. 2
      qa/rpc-tests/wallet.py
  87. 4
      qa/rpc-tests/walletbackup.py
  88. 9
      qa/rpc-tests/zapwallettxes.py
  89. 5
      qa/rpc-tests/zmq_test.py

9
qa/rpc-tests/abandonconflict.py

@ -2,7 +2,14 @@ @@ -2,7 +2,14 @@
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test the abandontransaction RPC.
The abandontransaction RPC marks a transaction and all its in-wallet
descendants as abandoned which allows their inputs to be respent. It can be
used to replace "stuck" or evicted transactions. It only works on transactions
which are not included in a block and are not currently in the mempool. It has
no effect on transactions which are already conflicted or abandoned.
"""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *

5
qa/rpc-tests/assumevalid.py

@ -2,8 +2,7 @@ @@ -2,8 +2,7 @@
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
'''
assumevalid.py
"""Test logic for skipping signature validation on old blocks.
Test logic for skipping signature validation on blocks which we've assumed
valid (https://github.com/bitcoin/bitcoin/pull/9484)
@ -29,7 +28,7 @@ Start three nodes: @@ -29,7 +28,7 @@ Start three nodes:
- node2 has -assumevalid set to the hash of block 102. Try to sync to
block 200. node2 will reject block 102 since it's assumed valid, but it
isn't buried by at least two weeks' work.
'''
"""
from test_framework.mininode import *
from test_framework.test_framework import BitcoinTestFramework

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

@ -2,6 +2,19 @@ @@ -2,6 +2,19 @@
# Copyright (c) 2015-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test BIP65 (CHECKLOCKTIMEVERIFY).
Connect to a single node.
Mine 2 (version 3) blocks (save the coinbases for later).
Generate 98 more version 3 blocks, verify the node accepts.
Mine 749 version 4 blocks, verify the node accepts.
Check that the new CLTV rules are not enforced on the 750th version 4 block.
Check that the new CLTV rules are enforced on the 751st version 4 block.
Mine 199 new version blocks.
Mine 1 old-version block.
Mine 1 new version block.
Mine 1 old version block, see that the node rejects.
"""
from test_framework.test_framework import ComparisonTestFramework
from test_framework.util import *
@ -20,19 +33,6 @@ def cltv_invalidate(tx): @@ -20,19 +33,6 @@ def cltv_invalidate(tx):
tx.vin[0].scriptSig = CScript([OP_1NEGATE, OP_CHECKLOCKTIMEVERIFY, OP_DROP] +
list(CScript(tx.vin[0].scriptSig)))
'''
This test is meant to exercise BIP65 (CHECKLOCKTIMEVERIFY)
Connect to a single node.
Mine 2 (version 3) blocks (save the coinbases for later).
Generate 98 more version 3 blocks, verify the node accepts.
Mine 749 version 4 blocks, verify the node accepts.
Check that the new CLTV rules are not enforced on the 750th version 4 block.
Check that the new CLTV rules are enforced on the 751st version 4 block.
Mine 199 new version blocks.
Mine 1 old-version block.
Mine 1 new version block.
Mine 1 old version block, see that the node rejects.
'''
class BIP65Test(ComparisonTestFramework):

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

@ -2,10 +2,7 @@ @@ -2,10 +2,7 @@
# Copyright (c) 2015-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#
# Test the CHECKLOCKTIMEVERIFY (BIP65) soft-fork logic
#
"""Test the CHECKLOCKTIMEVERIFY (BIP65) soft-fork logic."""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *

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

@ -2,18 +2,8 @@ @@ -2,18 +2,8 @@
# Copyright (c) 2015-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test activation of the first version bits soft fork.
from test_framework.test_framework import ComparisonTestFramework
from test_framework.util import *
from test_framework.mininode import ToHex, NetworkThread
from test_framework.blocktools import create_coinbase, create_block
from test_framework.comptool import TestInstance, TestManager
from test_framework.script import *
from io import BytesIO
import time
'''
This test is meant to exercise activation of the first version bits soft fork
This soft fork will activate the following BIPS:
BIP 68 - nSequence relative lock times
BIP 112 - CHECKSEQUENCEVERIFY
@ -51,7 +41,16 @@ bip112txs_vary_nSequence_9 - 16 txs with nSequence relative_locktimes of 9 evalu @@ -51,7 +41,16 @@ bip112txs_vary_nSequence_9 - 16 txs with nSequence relative_locktimes of 9 evalu
bip112txs_vary_OP_CSV - 16 txs with nSequence = 10 evaluated against varying {relative_locktimes of 10} OP_CSV OP_DROP
bip112txs_vary_OP_CSV_9 - 16 txs with nSequence = 9 evaluated against varying {relative_locktimes of 10} OP_CSV OP_DROP
bip112tx_special - test negative argument to OP_CSV
'''
"""
from test_framework.test_framework import ComparisonTestFramework
from test_framework.util import *
from test_framework.mininode import ToHex, CTransaction, NetworkThread
from test_framework.blocktools import create_coinbase, create_block
from test_framework.comptool import TestInstance, TestManager
from test_framework.script import *
from io import BytesIO
import time
base_relative_locktime = 10
seq_disable_flag = 1<<31

5
qa/rpc-tests/bip68-sequence.py

@ -2,10 +2,7 @@ @@ -2,10 +2,7 @@
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#
# Test BIP68 implementation
#
"""Test BIP68 implementation."""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *

38
qa/rpc-tests/bip9-softforks.py

@ -2,20 +2,8 @@ @@ -2,20 +2,8 @@
# Copyright (c) 2015-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test BIP 9 soft forks.
from test_framework.blockstore import BlockStore
from test_framework.test_framework import ComparisonTestFramework
from test_framework.util import *
from test_framework.mininode import CTransaction, NetworkThread
from test_framework.blocktools import create_coinbase, create_block
from test_framework.comptool import TestInstance, TestManager
from test_framework.script import CScript, OP_1NEGATE, OP_CHECKSEQUENCEVERIFY, OP_DROP
from io import BytesIO
import time
import itertools
'''
This test is meant to exercise BIP forks
Connect to a single node.
regtest lock-in with 108/144 block signalling
activation after a further 144 blocks
@ -26,8 +14,18 @@ mine 108 blocks signalling readiness and 36 blocks not signalling readiness (STA @@ -26,8 +14,18 @@ mine 108 blocks signalling readiness and 36 blocks not signalling readiness (STA
mine a further 143 blocks (LOCKED_IN)
test that enforcement has not triggered (which triggers ACTIVE)
test that enforcement has triggered
'''
"""
from test_framework.blockstore import BlockStore
from test_framework.test_framework import ComparisonTestFramework
from test_framework.util import *
from test_framework.mininode import CTransaction, NetworkThread
from test_framework.blocktools import create_coinbase, create_block
from test_framework.comptool import TestInstance, TestManager
from test_framework.script import CScript, OP_1NEGATE, OP_CHECKSEQUENCEVERIFY, OP_DROP
from io import BytesIO
import time
import itertools
class BIP9SoftForksTest(ComparisonTestFramework):
@ -225,21 +223,21 @@ class BIP9SoftForksTest(ComparisonTestFramework): @@ -225,21 +223,21 @@ class BIP9SoftForksTest(ComparisonTestFramework):
return
def csv_invalidate(self, tx):
'''Modify the signature in vin 0 of the tx to fail CSV
"""Modify the signature in vin 0 of the tx to fail CSV
Prepends -1 CSV DROP in the scriptSig itself.
'''
"""
tx.vin[0].scriptSig = CScript([OP_1NEGATE, OP_CHECKSEQUENCEVERIFY, OP_DROP] +
list(CScript(tx.vin[0].scriptSig)))
def sequence_lock_invalidate(self, tx):
'''Modify the nSequence to make it fails once sequence lock rule is activated (high timespan)
'''
"""Modify the nSequence to make it fails once sequence lock rule is
activated (high timespan).
"""
tx.vin[0].nSequence = 0x00FFFFFF
tx.nLockTime = 0
def mtp_invalidate(self, tx):
'''Modify the nLockTime to make it fails once MTP rule is activated
'''
"""Modify the nLockTime to make it fails once MTP rule is activated."""
# Disable Sequence lock, Activate nLockTime
tx.vin[0].nSequence = 0x90FFFFFF
tx.nLockTime = self.last_block_time

31
qa/rpc-tests/bipdersig-p2p.py

@ -2,6 +2,19 @@ @@ -2,6 +2,19 @@
# Copyright (c) 2015-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test BIP66 (DER SIG).
Connect to a single node.
Mine 2 (version 2) blocks (save the coinbases for later).
Generate 98 more version 2 blocks, verify the node accepts.
Mine 749 version 3 blocks, verify the node accepts.
Check that the new DERSIG rules are not enforced on the 750th version 3 block.
Check that the new DERSIG rules are enforced on the 751st version 3 block.
Mine 199 new version blocks.
Mine 1 old-version block.
Mine 1 new version block.
Mine 1 old version block, see that the node rejects.
"""
from test_framework.test_framework import ComparisonTestFramework
from test_framework.util import *
@ -15,10 +28,10 @@ import time @@ -15,10 +28,10 @@ import time
# A canonical signature consists of:
# <30> <total len> <02> <len R> <R> <02> <len S> <S> <hashtype>
def unDERify(tx):
'''
"""
Make the signature in vin 0 of a tx non-DER-compliant,
by adding padding after the S-value.
'''
"""
scriptSig = CScript(tx.vin[0].scriptSig)
newscript = []
for i in scriptSig:
@ -27,20 +40,6 @@ def unDERify(tx): @@ -27,20 +40,6 @@ def unDERify(tx):
else:
newscript.append(i)
tx.vin[0].scriptSig = CScript(newscript)
'''
This test is meant to exercise BIP66 (DER SIG).
Connect to a single node.
Mine 2 (version 2) blocks (save the coinbases for later).
Generate 98 more version 2 blocks, verify the node accepts.
Mine 749 version 3 blocks, verify the node accepts.
Check that the new DERSIG rules are not enforced on the 750th version 3 block.
Check that the new DERSIG rules are enforced on the 751st version 3 block.
Mine 199 new version blocks.
Mine 1 old-version block.
Mine 1 new version block.
Mine 1 old version block, see that the node rejects.
'''
class BIP66Test(ComparisonTestFramework):

5
qa/rpc-tests/bipdersig.py

@ -2,10 +2,7 @@ @@ -2,10 +2,7 @@
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#
# Test the BIP66 changeover logic
#
"""Test the BIP66 changeover logic."""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *

18
qa/rpc-tests/blockchain.py

@ -2,11 +2,14 @@ @@ -2,11 +2,14 @@
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test RPCs related to blockchainstate.
#
# Test RPC calls related to blockchain state. Tests correspond to code in
# rpc/blockchain.cpp.
#
Test the following RPCs:
- gettxoutsetinfo
- verifychain
Tests correspond to code in rpc/blockchain.cpp.
"""
from decimal import Decimal
@ -23,13 +26,6 @@ from test_framework.util import ( @@ -23,13 +26,6 @@ from test_framework.util import (
class BlockchainTest(BitcoinTestFramework):
"""
Test blockchain-related RPC calls:
- gettxoutsetinfo
- verifychain
"""
def __init__(self):
super().__init__()

1
qa/rpc-tests/bumpfee.py

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
# Copyright (c) 2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test the bumpfee RPC."""
from segwit import send_to_witness
from test_framework.test_framework import BitcoinTestFramework

9
qa/rpc-tests/create_cache.py

@ -2,11 +2,12 @@ @@ -2,11 +2,12 @@
# Copyright (c) 2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Create a blockchain cache.
#
# Helper script to create the cache
# (see BitcoinTestFramework.setup_chain)
#
Creating a cache of the blockchain speeds up test execution when running
multiple qa tests. This helper script is executed by rpc-tests when multiple
tests are being run in parallel.
"""
from test_framework.test_framework import BitcoinTestFramework

4
qa/rpc-tests/decodescript.py

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
# Copyright (c) 2015-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test decoding scripts via decodescript RPC command."""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
@ -9,7 +10,6 @@ from test_framework.mininode import * @@ -9,7 +10,6 @@ from test_framework.mininode import *
from io import BytesIO
class DecodeScriptTest(BitcoinTestFramework):
"""Tests decoding scripts via RPC command "decodescript"."""
def __init__(self):
super().__init__()
@ -111,7 +111,7 @@ class DecodeScriptTest(BitcoinTestFramework): @@ -111,7 +111,7 @@ class DecodeScriptTest(BitcoinTestFramework):
assert_equal('OP_IF ' + public_key + ' OP_CHECKSIGVERIFY OP_ELSE 500000 OP_CHECKLOCKTIMEVERIFY OP_DROP OP_ENDIF ' + public_key + ' OP_CHECKSIG', rpc_result['asm'])
def decoderawtransaction_asm_sighashtype(self):
"""Tests decoding scripts via RPC command "decoderawtransaction".
"""Test decoding scripts via RPC command "decoderawtransaction".
This test is in with the "decodescript" tests because they are testing the same "asm" script decodes.
"""

8
qa/rpc-tests/disablewallet.py

@ -2,10 +2,11 @@ @@ -2,10 +2,11 @@
# Copyright (c) 2015-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test a node with the -disablewallet option.
#
# Exercise API with -disablewallet.
#
- Test that validateaddress RPC works when running with -disablewallet
- Test that it is not possible to mine to an invalid address.
"""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
@ -24,7 +25,6 @@ class DisableWalletTest (BitcoinTestFramework): @@ -24,7 +25,6 @@ class DisableWalletTest (BitcoinTestFramework):
self.sync_all()
def run_test (self):
# Check regression: https://github.com/bitcoin/bitcoin/issues/6963#issuecomment-154548880
x = self.nodes[0].validateaddress('3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy')
assert(x['isvalid'] == False)
x = self.nodes[0].validateaddress('mneYUmWYsuk7kySiURxCi3AGxrAqZxLgPZ')

5
qa/rpc-tests/forknotify.py

@ -2,10 +2,7 @@ @@ -2,10 +2,7 @@
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#
# Test -alertnotify
#
"""Test the -alertnotify option."""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *

1
qa/rpc-tests/fundrawtransaction.py

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test the fundrawtransaction RPC."""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *

5
qa/rpc-tests/getblocktemplate_longpoll.py

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test longpolling with getblocktemplate."""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
@ -22,10 +23,6 @@ class LongpollThread(threading.Thread): @@ -22,10 +23,6 @@ class LongpollThread(threading.Thread):
self.node.getblocktemplate({'longpollid':self.longpollid})
class GetBlockTemplateLPTest(BitcoinTestFramework):
'''
Test longpolling with getblocktemplate.
'''
def __init__(self):
super().__init__()
self.num_nodes = 4

4
qa/rpc-tests/getblocktemplate_proposals.py

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test block proposals with getblocktemplate."""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
@ -66,9 +67,6 @@ def assert_template(node, tmpl, txlist, expect): @@ -66,9 +67,6 @@ def assert_template(node, tmpl, txlist, expect):
raise AssertionError('unexpected: %s' % (rsp,))
class GetBlockTemplateProposalTest(BitcoinTestFramework):
'''
Test block proposals with getblocktemplate.
'''
def __init__(self):
super().__init__()

9
qa/rpc-tests/getchaintips.py

@ -2,10 +2,13 @@ @@ -2,10 +2,13 @@
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test the getchaintips RPC.
# Exercise the getchaintips API. We introduce a network split, work
# on chains of different lengths, and join the network together again.
# This gives us two tips, verify that it works.
- introduce a network split
- work on chains of different lengths
- join the network together again
- verify that getchaintips now returns two chain tips.
"""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal

5
qa/rpc-tests/httpbasics.py

@ -2,10 +2,7 @@ @@ -2,10 +2,7 @@
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#
# Test rpc http basics
#
"""Test the RPC HTTP basics."""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *

4
qa/rpc-tests/import-rescan.py

@ -2,7 +2,9 @@ @@ -2,7 +2,9 @@
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test rescan behavior of importaddress, importpubkey, importprivkey, and
"""Test wallet import RPCs.
Test rescan behavior of importaddress, importpubkey, importprivkey, and
importmulti RPCs with different types of keys and rescan options.
In the first part of the test, node 0 creates an address for each type of

2
qa/rpc-tests/importmulti.py

@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test the importmulti RPC."""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *

2
qa/rpc-tests/importprunedfunds.py

@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test the importprunedfunds and removeprunedfunds RPCs."""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *

5
qa/rpc-tests/invalidateblock.py

@ -2,10 +2,7 @@ @@ -2,10 +2,7 @@
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#
# Test InvalidateBlock code
#
"""Test the invalidateblock RPC."""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *

17
qa/rpc-tests/invalidblockrequest.py

@ -2,6 +2,14 @@ @@ -2,6 +2,14 @@
# Copyright (c) 2015-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test node responses to invalid blocks.
In this test we connect to one node over p2p, and test block requests:
1) Valid blocks should be requested and become chain tip.
2) Invalid block with duplicated transaction should be re-requested.
3) Invalid block with bad coinbase value should be rejected and not
re-requested.
"""
from test_framework.test_framework import ComparisonTestFramework
from test_framework.util import *
@ -10,15 +18,6 @@ from test_framework.blocktools import * @@ -10,15 +18,6 @@ from test_framework.blocktools import *
import copy
import time
'''
In this test we connect to one node over p2p, and test block requests:
1) Valid blocks should be requested and become chain tip.
2) Invalid block with duplicated transaction should be re-requested.
3) Invalid block with bad coinbase value should be rejected and not
re-requested.
'''
# Use the ComparisonTestFramework with 1 node: only use --testbinary.
class InvalidBlockRequestTest(ComparisonTestFramework):

7
qa/rpc-tests/invalidtxrequest.py

@ -2,6 +2,10 @@ @@ -2,6 +2,10 @@
# Copyright (c) 2015-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test node responses to invalid transactions.
In this test we connect to one node over p2p, and test tx requests.
"""
from test_framework.test_framework import ComparisonTestFramework
from test_framework.comptool import TestManager, TestInstance, RejectResult
@ -9,9 +13,6 @@ from test_framework.blocktools import * @@ -9,9 +13,6 @@ from test_framework.blocktools import *
import time
'''
In this test we connect to one node over p2p, and test tx requests.
'''
# Use the ComparisonTestFramework with 1 node: only use --testbinary.
class InvalidTxRequestTest(ComparisonTestFramework):

3
qa/rpc-tests/keypool.py

@ -2,8 +2,7 @@ @@ -2,8 +2,7 @@
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
# Exercise the wallet keypool, and interaction with wallet encryption/locking
"""Test the wallet keypool and interaction with wallet encryption/locking."""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *

1
qa/rpc-tests/listsinceblock.py

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
# Copyright (c) 2017 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test the listsincelast RPC."""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal

3
qa/rpc-tests/listtransactions.py

@ -2,8 +2,7 @@ @@ -2,8 +2,7 @@
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
# Exercise the listtransactions API
"""Test the listtransactions API."""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *

13
qa/rpc-tests/maxblocksinflight.py

@ -2,18 +2,19 @@ @@ -2,18 +2,19 @@
# Copyright (c) 2015-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test nodes responses to having many blocks in flight.
In this test we connect to one node over p2p, send it numerous inv's, and
compare the resulting number of getdata requests to a max allowed value. We
test for exceeding 128 blocks in flight, which was the limit an 0.9 client will
reach. [0.10 clients shouldn't request more than 16 from a single peer.]
"""
from test_framework.mininode import *
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
import logging
'''
In this test we connect to one node over p2p, send it numerous inv's, and
compare the resulting number of getdata requests to a max allowed value. We
test for exceeding 128 blocks in flight, which was the limit an 0.9 client will
reach. [0.10 clients shouldn't request more than 16 from a single peer.]
'''
MAX_REQUESTS = 128
class TestManager(NodeConnCB):

16
qa/rpc-tests/maxuploadtarget.py

@ -2,21 +2,19 @@ @@ -2,21 +2,19 @@
# Copyright (c) 2015-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
from test_framework.mininode import *
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
import time
'''
Test behavior of -maxuploadtarget.
"""Test behavior of -maxuploadtarget.
* Verify that getdata requests for old blocks (>1week) are dropped
if uploadtarget has been reached.
* Verify that getdata requests for recent blocks are respecteved even
if uploadtarget has been reached.
* Verify that the upload counters are reset after 24 hours.
'''
"""
from test_framework.mininode import *
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
import time
# TestNode: bare-bones "peer". Used mostly as a conduit for a test to sending
# p2p messages to a node, generating the messages in the main testing logic.

3
qa/rpc-tests/mempool_limit.py

@ -2,8 +2,7 @@ @@ -2,8 +2,7 @@
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
# Test mempool limiting together/eviction with the wallet
"""Test mempool limiting together/eviction with the wallet."""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *

3
qa/rpc-tests/mempool_packages.py

@ -2,8 +2,7 @@ @@ -2,8 +2,7 @@
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
# Test descendant package tracking code
"""Test descendant package tracking code."""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *

8
qa/rpc-tests/mempool_reorg.py

@ -2,11 +2,11 @@ @@ -2,11 +2,11 @@
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test mempool re-org scenarios.
#
# Test re-org scenarios with a mempool that contains transactions
# that spend (directly or indirectly) coinbase transactions.
#
Test re-org scenarios with a mempool that contains transactions
that spend (directly or indirectly) coinbase transactions.
"""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *

6
qa/rpc-tests/mempool_resurrect_test.py

@ -2,11 +2,7 @@ @@ -2,11 +2,7 @@
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#
# Test resurrection of mined transactions when
# the blockchain is re-organized.
#
"""Test resurrection of mined transactions when the blockchain is re-organized."""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *

19
qa/rpc-tests/mempool_spendcoinbase.py

@ -2,16 +2,15 @@ @@ -2,16 +2,15 @@
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#
# Test spending coinbase transactions.
# The coinbase transaction in block N can appear in block
# N+100... so is valid in the mempool when the best block
# height is N+99.
# This test makes sure coinbase spends that will be mature
# in the next block are accepted into the memory pool,
# but less mature coinbase spends are NOT.
#
"""Test spending coinbase transactions.
The coinbase transaction in block N can appear in block
N+100... so is valid in the mempool when the best block
height is N+99.
This test makes sure coinbase spends that will be mature
in the next block are accepted into the memory pool,
but less mature coinbase spends are NOT.
"""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *

5
qa/rpc-tests/merkle_blocks.py

@ -2,10 +2,7 @@ @@ -2,10 +2,7 @@
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#
# Test merkleblock fetch/validation
#
"""Test gettxoutproof and verifytxoutproof RPCs."""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *

5
qa/rpc-tests/multi_rpc.py

@ -2,10 +2,7 @@ @@ -2,10 +2,7 @@
# Copyright (c) 2015-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#
# Test multiple rpc user config option rpcauth
#
"""Test multiple RPC users."""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import str_to_b64str, assert_equal

5
qa/rpc-tests/nodehandling.py

@ -2,10 +2,7 @@ @@ -2,10 +2,7 @@
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#
# Test node handling
#
"""Test node handling."""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *

21
qa/rpc-tests/nulldummy.py

@ -2,6 +2,16 @@ @@ -2,6 +2,16 @@
# Copyright (c) 2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test NULLDUMMY softfork.
Connect to a single node.
Generate 2 blocks (save the coinbases for later).
Generate 427 more blocks.
[Policy/Consensus] Check that NULLDUMMY compliant transactions are accepted in the 430th block.
[Policy] Check that non-NULLDUMMY transactions are rejected before activation.
[Consensus] Check that the new NULLDUMMY rules are not enforced on the 431st block.
[Policy/Consensus] Check that the new NULLDUMMY rules are enforced on the 432nd block.
"""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
@ -25,17 +35,6 @@ def trueDummy(tx): @@ -25,17 +35,6 @@ def trueDummy(tx):
tx.vin[0].scriptSig = CScript(newscript)
tx.rehash()
'''
This test is meant to exercise NULLDUMMY softfork.
Connect to a single node.
Generate 2 blocks (save the coinbases for later).
Generate 427 more blocks.
[Policy/Consensus] Check that NULLDUMMY compliant transactions are accepted in the 430th block.
[Policy] Check that non-NULLDUMMY transactions are rejected before activation.
[Consensus] Check that the new NULLDUMMY rules are not enforced on the 431st block.
[Policy/Consensus] Check that the new NULLDUMMY rules are enforced on the 432nd block.
'''
class NULLDUMMYTest(BitcoinTestFramework):
def __init__(self):

18
qa/rpc-tests/p2p-acceptblock.py

@ -2,15 +2,7 @@ @@ -2,15 +2,7 @@
# Copyright (c) 2015-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
from test_framework.mininode import *
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
import time
from test_framework.blocktools import create_block, create_coinbase
'''
AcceptBlockTest -- test processing of unrequested blocks.
"""Test processing of unrequested blocks.
Since behavior differs when receiving unrequested blocks from whitelisted peers
versus non-whitelisted peers, this tests the behavior of both (effectively two
@ -54,7 +46,13 @@ The test: @@ -54,7 +46,13 @@ The test:
7. Send Node0 the missing block again.
Node0 should process and the tip should advance.
'''
"""
from test_framework.mininode import *
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
import time
from test_framework.blocktools import create_block, create_coinbase
# TestNode: bare-bones "peer". Used mostly as a conduit for a test to sending
# p2p messages to a node, generating the messages in the main testing logic.

12
qa/rpc-tests/p2p-compactblocks.py

@ -2,6 +2,11 @@ @@ -2,6 +2,11 @@
# Copyright (c) 2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test compact blocks (BIP 152).
Version 1 compact blocks are pre-segwit (txids)
Version 2 compact blocks are post-segwit (wtxids)
"""
from test_framework.mininode import *
from test_framework.test_framework import BitcoinTestFramework
@ -9,13 +14,6 @@ from test_framework.util import * @@ -9,13 +14,6 @@ from test_framework.util import *
from test_framework.blocktools import create_block, create_coinbase, add_witness_commitment
from test_framework.script import CScript, OP_TRUE
'''
CompactBlocksTest -- test compact blocks (BIP 152)
Version 1 compact blocks are pre-segwit (txids)
Version 2 compact blocks are post-segwit (wtxids)
'''
# TestNode: A peer we use to send messages to bitcoind, and store responses.
class TestNode(SingleNodeConnCB):
def __init__(self):

5
qa/rpc-tests/p2p-feefilter.py

@ -2,16 +2,13 @@ @@ -2,16 +2,13 @@
# Copyright (c) 2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#
"""Test processing of feefilter messages."""
from test_framework.mininode import *
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
import time
'''
FeeFilterTest -- test processing of feefilter messages
'''
def hashToHex(hash):
return format(hash, '064x')

16
qa/rpc-tests/p2p-fullblocktest.py

@ -2,6 +2,14 @@ @@ -2,6 +2,14 @@
# Copyright (c) 2015-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test block processing.
This reimplements tests from the bitcoinj/FullBlockTestGenerator used
by the pull-tester.
We use the testing framework in which we expect a particular answer from
each test.
"""
from test_framework.test_framework import ComparisonTestFramework
from test_framework.util import *
@ -17,14 +25,6 @@ class PreviousSpendableOutput(object): @@ -17,14 +25,6 @@ class PreviousSpendableOutput(object):
self.tx = tx
self.n = n # the output we're spending
'''
This reimplements tests from the bitcoinj/FullBlockTestGenerator used
by the pull-tester.
We use the testing framework in which we expect a particular answer from
each test.
'''
# Use this class for tests that require behavior other than normal "mininode" behavior.
# For now, it is used to serialize a bloated varint (b64).
class CBrokenBlock(CBlock):

14
qa/rpc-tests/p2p-leaktests.py

@ -2,20 +2,18 @@ @@ -2,20 +2,18 @@
# Copyright (c) 2017 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
from test_framework.mininode import *
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
'''
Test for message sending before handshake completion
"""Test message sending before handshake completion.
A node should never send anything other than VERSION/VERACK/REJECT until it's
received a VERACK.
This test connects to a node and sends it a few messages, trying to intice it
into sending us something it shouldn't.
'''
"""
from test_framework.mininode import *
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
banscore = 10

5
qa/rpc-tests/p2p-mempool.py

@ -2,6 +2,11 @@ @@ -2,6 +2,11 @@
# Copyright (c) 2015-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test p2p mempool message.
Test that nodes are disconnected if they send mempool messages when bloom
filters are not enabled.
"""
from test_framework.mininode import *
from test_framework.test_framework import BitcoinTestFramework

4
qa/rpc-tests/p2p-segwit.py

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
# Copyright (c) 2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test segwit transactions and blocks on P2P network."""
from test_framework.mininode import *
from test_framework.test_framework import BitcoinTestFramework
@ -21,9 +22,6 @@ VB_TOP_BITS = 0x20000000 @@ -21,9 +22,6 @@ VB_TOP_BITS = 0x20000000
MAX_SIGOP_COST = 80000
'''
SegWit p2p test.
'''
# Calculate the virtual size of a witness block:
# (base + witness/4)

2
qa/rpc-tests/p2p-timeouts.py

@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
# Copyright (c) 2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
""" TimeoutsTest -- test various net timeouts (only in extended tests)
"""Test various net timeouts.
- Create three bitcoind nodes:

12
qa/rpc-tests/p2p-versionbits-warning.py

@ -2,6 +2,11 @@ @@ -2,6 +2,11 @@
# Copyright (c) 2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test version bits warning system.
Generate chains with block versions that appear to be signalling unknown
soft-forks, and test that warning alerts are generated.
"""
from test_framework.mininode import *
from test_framework.test_framework import BitcoinTestFramework
@ -10,13 +15,6 @@ import re @@ -10,13 +15,6 @@ import re
import time
from test_framework.blocktools import create_block, create_coinbase
'''
Test version bits' warning system.
Generate chains with block versions that appear to be signalling unknown
soft-forks, and test that warning alerts are generated.
'''
VB_PERIOD = 144 # versionbits period length for regtest
VB_THRESHOLD = 108 # versionbits activation threshold for regtest
VB_TOP_BITS = 0x20000000

5
qa/rpc-tests/preciousblock.py

@ -2,10 +2,7 @@ @@ -2,10 +2,7 @@
# Copyright (c) 2015-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#
# Test PreciousBlock code
#
"""Test the preciousblock RPC."""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (

5
qa/rpc-tests/prioritise_transaction.py

@ -2,10 +2,7 @@ @@ -2,10 +2,7 @@
# Copyright (c) 2015-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#
# Test PrioritiseTransaction code
#
"""Test the prioritisetransaction mining RPC."""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *

29
qa/rpc-tests/proxy_test.py

@ -2,20 +2,8 @@ @@ -2,20 +2,8 @@
# Copyright (c) 2015-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test bitcoind with different proxy configuration.
import socket
import os
from test_framework.socks5 import Socks5Configuration, Socks5Command, Socks5Server, AddressType
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
PORT_MIN,
PORT_RANGE,
start_nodes,
assert_equal,
)
from test_framework.netutil import test_ipv6_local
'''
Test plan:
- Start bitcoind's with different proxy configurations
- Use addnode to initiate connections
@ -37,7 +25,20 @@ addnode connect to IPv4 @@ -37,7 +25,20 @@ addnode connect to IPv4
addnode connect to IPv6
addnode connect to onion
addnode connect to generic DNS name
'''
"""
import socket
import os
from test_framework.socks5 import Socks5Configuration, Socks5Command, Socks5Server, AddressType
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
PORT_MIN,
PORT_RANGE,
start_nodes,
assert_equal,
)
from test_framework.netutil import test_ipv6_local
RANGE_BEGIN = PORT_MIN + 2 * PORT_RANGE # Start after p2p and rpc ports

12
qa/rpc-tests/pruning.py

@ -2,14 +2,12 @@ @@ -2,14 +2,12 @@
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test the pruning code.
#
# Test pruning code
# ********
# WARNING:
# This test uses 4GB of disk space.
# This test takes 30 mins or more (up to 2 hours)
# ********
WARNING:
This test uses 4GB of disk space.
This test takes 30 mins or more (up to 2 hours)
"""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *

16
qa/rpc-tests/rawtransactions.py

@ -2,14 +2,14 @@ @@ -2,14 +2,14 @@
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""rawtranscation RPCs QA test.
# Tests the following RPCs:
# - createrawtransaction
# - signrawtransaction
# - sendrawtransaction
# - decoderawtransaction
# - getrawtransaction
"""Test the rawtranscation RPCs.
Test the following RPCs:
- createrawtransaction
- signrawtransaction
- sendrawtransaction
- decoderawtransaction
- getrawtransaction
"""
from test_framework.test_framework import BitcoinTestFramework

4
qa/rpc-tests/receivedby.py

@ -2,13 +2,11 @@ @@ -2,13 +2,11 @@
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
# Exercise the listreceivedbyaddress API
"""Test the listreceivedbyaddress RPC."""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
def get_sub_array_from_array(object_array, to_match):
'''
Finds and returns a sub array from an array of arrays.

9
qa/rpc-tests/reindex.py

@ -2,10 +2,13 @@ @@ -2,10 +2,13 @@
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test running bitcoind with -reindex and -reindex-chainstate options.
- Start a single node and generate 3 blocks.
- Stop the node and restart it with -reindex. Verify that the node has reindexed up to block 3.
- Stop the node and restart it with -reindex-chainstate. Verify that the node has reindexed up to block 3.
"""
#
# Test -reindex and -reindex-chainstate with CheckBlockIndex
#
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
start_nodes,

7
qa/rpc-tests/replace-by-fee.py

@ -2,10 +2,7 @@ @@ -2,10 +2,7 @@
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#
# Test replace by fee code
#
"""Test the RBF code."""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
@ -442,7 +439,7 @@ class ReplaceByFeeTest(BitcoinTestFramework): @@ -442,7 +439,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
self.nodes[0].sendrawtransaction(double_tx_hex, True)
def test_opt_in(self):
""" Replacing should only work if orig tx opted in """
"""Replacing should only work if orig tx opted in"""
tx0_outpoint = make_utxo(self.nodes[0], int(1.1*COIN))
# Create a non-opting in transaction

6
qa/rpc-tests/rest.py

@ -2,11 +2,7 @@ @@ -2,11 +2,7 @@
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#
# Test REST interface
#
"""Test the REST API."""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *

3
qa/rpc-tests/rpcbind_test.py

@ -2,8 +2,7 @@ @@ -2,8 +2,7 @@
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
# Test for -rpcbind, as well as -rpcallowip and -rpcconnect
"""Test running bitcoind with the -rpcbind and -rpcallowip options."""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *

1
qa/rpc-tests/rpcnamedargs.py

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
# Copyright (c) 2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test using named arguments for RPCs."""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (

5
qa/rpc-tests/segwit.py

@ -2,10 +2,7 @@ @@ -2,10 +2,7 @@
# Copyright (c) 2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#
# Test the SegWit changeover logic
#
"""Test the SegWit changeover logic."""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *

17
qa/rpc-tests/sendheaders.py

@ -2,14 +2,7 @@ @@ -2,14 +2,7 @@
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
from test_framework.mininode import *
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
from test_framework.blocktools import create_block, create_coinbase
'''
SendHeadersTest -- test behavior of headers messages to announce blocks.
"""Test behavior of headers messages to announce blocks.
Setup:
@ -78,7 +71,13 @@ d. Announce 49 headers that don't connect. @@ -78,7 +71,13 @@ d. Announce 49 headers that don't connect.
Expect: getheaders message each time.
e. Announce one more that doesn't connect.
Expect: disconnect.
'''
"""
from test_framework.mininode import *
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
from test_framework.blocktools import create_block, create_coinbase
direct_fetch_response_time = 0.05

3
qa/rpc-tests/signmessages.py

@ -2,13 +2,12 @@ @@ -2,13 +2,12 @@
# Copyright (c) 2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test RPC commands for signing and verifying messages."""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
class SignMessagesTest(BitcoinTestFramework):
"""Tests RPC commands for signing and verifying messages."""
def __init__(self):
super().__init__()

7
qa/rpc-tests/signrawtransactions.py

@ -2,14 +2,13 @@ @@ -2,14 +2,13 @@
# Copyright (c) 2015-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test transaction signing using the signrawtransaction RPC."""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
class SignRawTransactionsTest(BitcoinTestFramework):
"""Tests transaction signing via RPC command "signrawtransaction"."""
def __init__(self):
super().__init__()
self.setup_clean_chain = True
@ -20,7 +19,7 @@ class SignRawTransactionsTest(BitcoinTestFramework): @@ -20,7 +19,7 @@ class SignRawTransactionsTest(BitcoinTestFramework):
self.is_network_split = False
def successful_signing_test(self):
"""Creates and signs a valid raw transaction with one input.
"""Create and sign a valid raw transaction with one input.
Expected results:
@ -65,7 +64,7 @@ class SignRawTransactionsTest(BitcoinTestFramework): @@ -65,7 +64,7 @@ class SignRawTransactionsTest(BitcoinTestFramework):
def script_verification_error_test(self):
"""Creates and signs a raw transaction with valid (vin 0), invalid (vin 1) and one missing (vin 2) input script.
"""Create and sign a raw transaction with valid (vin 0), invalid (vin 1) and one missing (vin 2) input script.
Expected results:

21
qa/rpc-tests/smartfees.py

@ -2,10 +2,7 @@ @@ -2,10 +2,7 @@
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#
# Test fee estimation code
#
"""Test fee estimation code."""
from collections import OrderedDict
from test_framework.test_framework import BitcoinTestFramework
@ -21,7 +18,7 @@ P2SH_2 = "2NBdpwq8Aoo1EEKEXPNrKvr5xQr3M9UfcZA" # P2SH of "OP_2 OP_DROP" @@ -21,7 +18,7 @@ P2SH_2 = "2NBdpwq8Aoo1EEKEXPNrKvr5xQr3M9UfcZA" # P2SH of "OP_2 OP_DROP"
SCRIPT_SIG = ["0451025175", "0451025275"]
def small_txpuzzle_randfee(from_node, conflist, unconflist, amount, min_fee, fee_increment):
'''
"""
Create and send a transaction with a random fee.
The transaction pays to a trivial P2SH script, and assumes that its inputs
are of the same form.
@ -29,7 +26,7 @@ def small_txpuzzle_randfee(from_node, conflist, unconflist, amount, min_fee, fee @@ -29,7 +26,7 @@ def small_txpuzzle_randfee(from_node, conflist, unconflist, amount, min_fee, fee
and attempts to use the confirmed list first for its inputs.
It adds the newly created outputs to the unconfirmed list.
Returns (raw transaction, fee)
'''
"""
# It's best to exponentially distribute our random fees
# because the buckets are exponentially spaced.
# Exponentially distributed from 1-128 * fee_increment
@ -71,12 +68,12 @@ def small_txpuzzle_randfee(from_node, conflist, unconflist, amount, min_fee, fee @@ -71,12 +68,12 @@ def small_txpuzzle_randfee(from_node, conflist, unconflist, amount, min_fee, fee
return (completetx, fee)
def split_inputs(from_node, txins, txouts, initial_split = False):
'''
"""
We need to generate a lot of very small inputs so we can generate a ton of transactions
and they will have low priority.
This function takes an input from txins, and creates and sends a transaction
which splits the value into 2 outputs which are appended to txouts.
'''
"""
prevtxout = txins.pop()
inputs = []
inputs.append({ "txid" : prevtxout["txid"], "vout" : prevtxout["vout"] })
@ -95,10 +92,10 @@ def split_inputs(from_node, txins, txouts, initial_split = False): @@ -95,10 +92,10 @@ def split_inputs(from_node, txins, txouts, initial_split = False):
txouts.append({ "txid" : txid, "vout" : 1 , "amount" : rem_change})
def check_estimates(node, fees_seen, max_invalid, print_estimates = True):
'''
"""
This function calls estimatefee and verifies that the estimates
meet certain invariants.
'''
"""
all_estimates = [ node.estimatefee(i) for i in range(1,26) ]
if print_estimates:
print([str(all_estimates[e-1]) for e in [1,2,3,6,15,25]])
@ -151,11 +148,11 @@ class EstimateFeeTest(BitcoinTestFramework): @@ -151,11 +148,11 @@ class EstimateFeeTest(BitcoinTestFramework):
self.setup_clean_chain = False
def setup_network(self):
'''
"""
We'll setup the network to have 3 nodes that all mine with different parameters.
But first we need to use one node to create a lot of small low priority outputs
which we will use to generate our transactions.
'''
"""
self.nodes = []
# Use node0 to mine blocks for input splitting
self.nodes.append(start_node(0, self.options.tmpdir, ["-maxorphantx=1000",

7
qa/rpc-tests/test_framework/address.py

@ -2,12 +2,7 @@ @@ -2,12 +2,7 @@
# Copyright (c) 2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#
# address.py
#
# This file encodes and decodes BASE58 P2PKH and P2SH addresses
#
"""Encode and decode BASE58, P2PKH and P2SH addresses."""
from .script import hash256, hash160, sha256, CScript, OP_0
from .util import bytes_to_hex_str, hex_str_to_bytes

67
qa/rpc-tests/test_framework/authproxy.py

@ -1,37 +1,36 @@ @@ -1,37 +1,36 @@
"""
Copyright (c) 2011 Jeff Garzik
AuthServiceProxy has the following improvements over python-jsonrpc's
ServiceProxy class:
- HTTP connections persist for the life of the AuthServiceProxy object
(if server supports HTTP/1.1)
- sends protocol 'version', per JSON-RPC 1.1
- sends proper, incrementing 'id'
- sends Basic HTTP authentication headers
- parses all JSON numbers that look like floats as Decimal
- uses standard Python json lib
Previous copyright, from python-jsonrpc/jsonrpc/proxy.py:
Copyright (c) 2007 Jan-Klaas Kollhof
This file is part of jsonrpc.
jsonrpc is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This software is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this software; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# Copyright (c) 2011 Jeff Garzik
#
# Previous copyright, from python-jsonrpc/jsonrpc/proxy.py:
#
# Copyright (c) 2007 Jan-Klaas Kollhof
#
# This file is part of jsonrpc.
#
# jsonrpc is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# This software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this software; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""HTTP proxy for opening RPC connection to bitcoind.
AuthServiceProxy has the following improvements over python-jsonrpc's
ServiceProxy class:
- HTTP connections persist for the life of the AuthServiceProxy object
(if server supports HTTP/1.1)
- sends protocol 'version', per JSON-RPC 1.1
- sends proper, incrementing 'id'
- sends Basic HTTP authentication headers
- parses all JSON numbers that look like floats as Decimal
- uses standard Python json lib
"""
try:

10
qa/rpc-tests/test_framework/bignum.py

@ -1,15 +1,11 @@ @@ -1,15 +1,11 @@
#!/usr/bin/env python3
#
# bignum.py
#
# This file is copied from python-bitcoinlib.
#
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#
"""Bignum routines"""
"""Big number routines.
This file is copied from python-bitcoinlib.
"""
import struct

12
qa/rpc-tests/test_framework/blockstore.py

@ -2,16 +2,20 @@ @@ -2,16 +2,20 @@
# Copyright (c) 2015-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
# BlockStore: a helper class that keeps a map of blocks and implements
# helper functions for responding to getheaders and getdata,
# and for constructing a getheaders message
#
"""BlockStore and TxStore helper classes."""
from .mininode import *
from io import BytesIO
import dbm.dumb as dbmd
class BlockStore(object):
"""BlockStore helper class.
BlockStore keeps a map of blocks and implements helper functions for
responding to getheaders and getdata, and for constructing a getheaders
message.
"""
def __init__(self, datadir):
self.blockDB = dbmd.open(datadir + "/blocks", 'c')
self.currentBlock = 0

2
qa/rpc-tests/test_framework/blocktools.py

@ -1,8 +1,8 @@ @@ -1,8 +1,8 @@
#!/usr/bin/env python3
# blocktools.py - utilities for manipulating blocks and transactions
# Copyright (c) 2015-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Utilities for manipulating blocks and transactions."""
from .mininode import *
from .script import CScript, OP_TRUE, OP_CHECKSIG, OP_RETURN

33
qa/rpc-tests/test_framework/comptool.py

@ -2,34 +2,29 @@ @@ -2,34 +2,29 @@
# Copyright (c) 2015-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
from .mininode import *
from .blockstore import BlockStore, TxStore
from .util import p2p_port
'''
This is a tool for comparing two or more bitcoinds to each other
using a script provided.
"""Compare two or more bitcoinds to each other.
To use, create a class that implements get_tests(), and pass it in
as the test generator to TestManager. get_tests() should be a python
generator that returns TestInstance objects. See below for definition.
'''
# TestNode behaves as follows:
# Configure with a BlockStore and TxStore
# on_inv: log the message but don't request
# on_headers: log the chain tip
# on_pong: update ping response map (for synchronization)
# on_getheaders: provide headers via BlockStore
# on_getdata: provide blocks via BlockStore
TestNode behaves as follows:
Configure with a BlockStore and TxStore
on_inv: log the message but don't request
on_headers: log the chain tip
on_pong: update ping response map (for synchronization)
on_getheaders: provide headers via BlockStore
on_getdata: provide blocks via BlockStore
"""
from .mininode import *
from .blockstore import BlockStore, TxStore
from .util import p2p_port
global mininode_lock
class RejectResult(object):
'''
Outcome that expects rejection of a transaction or block.
'''
"""Outcome that expects rejection of a transaction or block."""
def __init__(self, code, reason=b''):
self.code = code
self.reason = reason

9
qa/rpc-tests/test_framework/coverage.py

@ -2,15 +2,12 @@ @@ -2,15 +2,12 @@
# Copyright (c) 2015-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Utilities for doing coverage analysis on the RPC interface.
"""
This module contains utilities for doing coverage analysis on the RPC
interface.
It provides a way to track which RPC commands are exercised during
Provides a way to track which RPC commands are exercised during
testing.
"""
import os

10
qa/rpc-tests/test_framework/key.py

@ -1,14 +1,10 @@ @@ -1,14 +1,10 @@
# Copyright (c) 2011 Sam Rushing
#
# key.py - OpenSSL wrapper
#
# This file is modified from python-bitcoinlib.
#
"""ECC secp256k1 crypto routines
"""ECC secp256k1 OpenSSL wrapper.
WARNING: This module does not mlock() secrets; your private keys may end up on
disk in swap! Use with caution!
This file is modified from python-bitcoinlib.
"""
import ctypes

32
qa/rpc-tests/test_framework/mininode.py

@ -4,23 +4,21 @@ @@ -4,23 +4,21 @@
# Copyright (c) 2010-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#
# mininode.py - Bitcoin P2P network half-a-node
#
# This python code was modified from ArtForz' public domain half-a-node, as
# found in the mini-node branch of http://github.com/jgarzik/pynode.
#
# NodeConn: an object which manages p2p connectivity to a bitcoin node
# NodeConnCB: a base class that describes the interface for receiving
# callbacks with network messages from a NodeConn
# CBlock, CTransaction, CBlockHeader, CTxIn, CTxOut, etc....:
# data structures that should map to corresponding structures in
# bitcoin/primitives
# msg_block, msg_tx, msg_headers, etc.:
# data structures that represent network messages
# ser_*, deser_*: functions that handle serialization/deserialization
"""Bitcoin P2P network half-a-node.
This python code was modified from ArtForz' public domain half-a-node, as
found in the mini-node branch of http://github.com/jgarzik/pynode.
NodeConn: an object which manages p2p connectivity to a bitcoin node
NodeConnCB: a base class that describes the interface for receiving
callbacks with network messages from a NodeConn
CBlock, CTransaction, CBlockHeader, CTxIn, CTxOut, etc....:
data structures that should map to corresponding structures in
bitcoin/primitives
msg_block, msg_tx, msg_headers, etc.:
data structures that represent network messages
ser_*, deser_*: functions that handle serialization/deserialization
"""
import struct
import socket

5
qa/rpc-tests/test_framework/netutil.py

@ -2,8 +2,10 @@ @@ -2,8 +2,10 @@
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Linux network utilities.
# Linux network utilities
Roughly based on http://voorloopnul.com/blog/a-python-netstat-in-less-than-100-lines-of-code/ by Ricardo Pascal
"""
import sys
import socket
@ -13,7 +15,6 @@ import array @@ -13,7 +15,6 @@ import array
import os
from binascii import unhexlify, hexlify
# Roughly based on http://voorloopnul.com/blog/a-python-netstat-in-less-than-100-lines-of-code/ by Ricardo Pascal
STATE_ESTABLISHED = '01'
STATE_SYN_SENT = '02'
STATE_SYN_RECV = '03'

12
qa/rpc-tests/test_framework/script.py

@ -2,19 +2,11 @@ @@ -2,19 +2,11 @@
# Copyright (c) 2015-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Functionality to build scripts, as well as SignatureHash().
#
# script.py
#
# This file is modified from python-bitcoinlib.
#
"""Scripts
Functionality to build scripts, as well as SignatureHash().
This file is modified from python-bitcoinlib.
"""
from .mininode import CTransaction, CTxOut, sha256, hash256, uint256_from_str, ser_uint256, ser_string
from binascii import hexlify
import hashlib

7
qa/rpc-tests/test_framework/siphash.py

@ -2,11 +2,10 @@ @@ -2,11 +2,10 @@
# Copyright (c) 2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Specialized SipHash-2-4 implementations.
#
# siphash.py - Specialized SipHash-2-4 implementations
#
# This implements SipHash-2-4 for 256-bit integers.
This implements SipHash-2-4 for 256-bit integers.
"""
def rotl64(n, b):
return n >> (64 - b) | (n & ((1 << (64 - b)) - 1)) << b

14
qa/rpc-tests/test_framework/socks5.py

@ -2,9 +2,7 @@ @@ -2,9 +2,7 @@
# Copyright (c) 2015-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
'''
Dummy Socks5 server for testing.
'''
"""Dummy Socks5 server for testing."""
import socket, threading, queue
import traceback, sys
@ -20,7 +18,7 @@ class AddressType: @@ -20,7 +18,7 @@ class AddressType:
### Utility functions
def recvall(s, n):
'''Receive n bytes from a socket, or fail'''
"""Receive n bytes from a socket, or fail."""
rv = bytearray()
while n > 0:
d = s.recv(n)
@ -32,7 +30,7 @@ def recvall(s, n): @@ -32,7 +30,7 @@ def recvall(s, n):
### Implementation classes
class Socks5Configuration(object):
'''Proxy configuration'''
"""Proxy configuration."""
def __init__(self):
self.addr = None # Bind address (must be set)
self.af = socket.AF_INET # Bind address family
@ -40,7 +38,7 @@ class Socks5Configuration(object): @@ -40,7 +38,7 @@ class Socks5Configuration(object):
self.auth = False # Support authentication
class Socks5Command(object):
'''Information about an incoming socks5 command'''
"""Information about an incoming socks5 command."""
def __init__(self, cmd, atyp, addr, port, username, password):
self.cmd = cmd # Command (one of Command.*)
self.atyp = atyp # Address type (one of AddressType.*)
@ -58,9 +56,7 @@ class Socks5Connection(object): @@ -58,9 +56,7 @@ class Socks5Connection(object):
self.peer = peer
def handle(self):
'''
Handle socks5 request according to RFC1928
'''
"""Handle socks5 request according to RFC192."""
try:
# Verify socks version
ver = recvall(self.conn, 1)[0]

3
qa/rpc-tests/test_framework/test_framework.py

@ -2,8 +2,7 @@ @@ -2,8 +2,7 @@
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
# Base class for RPC testing
"""Base class for RPC testing."""
import logging
import optparse

6
qa/rpc-tests/test_framework/util.py

@ -2,11 +2,7 @@ @@ -2,11 +2,7 @@
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#
# Helpful routines for regression testing
#
"""Helpful routines for regression testing."""
import os
import sys

5
qa/rpc-tests/txn_clone.py

@ -2,10 +2,7 @@ @@ -2,10 +2,7 @@
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#
# Test proper accounting with an equivalent malleability clone
#
"""Test the wallet accounts properly when there are cloned transactions with malleated scriptsigs."""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *

5
qa/rpc-tests/txn_doublespend.py

@ -2,10 +2,7 @@ @@ -2,10 +2,7 @@
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#
# Test proper accounting with a double-spend conflict
#
"""Test the wallet accounts properly when there is a double-spend conflict."""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *

10
qa/rpc-tests/wallet-accounts.py

@ -2,6 +2,15 @@ @@ -2,6 +2,15 @@
# Copyright (c) 2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test account RPCs.
RPCs tested are:
- getaccountaddress
- getaddressesbyaccount
- setaccount
- sendfrom (with account arguments)
- move (with account arguments)
"""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
@ -9,7 +18,6 @@ from test_framework.util import ( @@ -9,7 +18,6 @@ from test_framework.util import (
assert_equal,
)
class WalletAccountsTest(BitcoinTestFramework):
def __init__(self):

1
qa/rpc-tests/wallet-dump.py

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
# Copyright (c) 2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test the dumpwallet RPC."""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (start_nodes, start_node, assert_equal, bitcoind_processes)

1
qa/rpc-tests/wallet-hd.py

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
# Copyright (c) 2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test Hierarchical Deterministic wallet function."""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (

2
qa/rpc-tests/wallet.py

@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test the wallet."""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *

4
qa/rpc-tests/walletbackup.py

@ -2,9 +2,7 @@ @@ -2,9 +2,7 @@
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""
Exercise the wallet backup code. Ported from walletbackup.sh.
"""Test the wallet backup features.
Test case is:
4 nodes. 1 2 and 3 send transactions between each other,

9
qa/rpc-tests/zapwallettxes.py

@ -2,7 +2,16 @@ @@ -2,7 +2,16 @@
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test the zapwallettxes functionality.
- start three bitcoind nodes
- create four transactions on node 0 - two are confirmed and two are
unconfirmed.
- restart node 1 and verify that both the confirmed and the unconfirmed
transactions are still available.
- restart node 0 and verify that the confirmed transactions are still
available, but that the unconfirmed transaction has been zapped.
"""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *

5
qa/rpc-tests/zmq_test.py

@ -2,10 +2,7 @@ @@ -2,10 +2,7 @@
# Copyright (c) 2015-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#
# Test ZMQ interface
#
"""Test the ZMQ API."""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *

Loading…
Cancel
Save