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.
This commit is contained in:
John Newbery 2017-01-17 18:34:40 -05:00
parent 61a640ea97
commit 3f95a806b1
89 changed files with 384 additions and 479 deletions

View file

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

View file

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

View file

@ -2,6 +2,19 @@
# Copyright (c) 2015-2016 The Bitcoin Core developers # Copyright (c) 2015-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php. # 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.test_framework import ComparisonTestFramework
from test_framework.util import * from test_framework.util import *
@ -20,19 +33,6 @@ def cltv_invalidate(tx):
tx.vin[0].scriptSig = CScript([OP_1NEGATE, OP_CHECKLOCKTIMEVERIFY, OP_DROP] + tx.vin[0].scriptSig = CScript([OP_1NEGATE, OP_CHECKLOCKTIMEVERIFY, OP_DROP] +
list(CScript(tx.vin[0].scriptSig))) 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): class BIP65Test(ComparisonTestFramework):

View file

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

View file

@ -2,18 +2,8 @@
# Copyright (c) 2015-2016 The Bitcoin Core developers # Copyright (c) 2015-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php. # 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: This soft fork will activate the following BIPS:
BIP 68 - nSequence relative lock times BIP 68 - nSequence relative lock times
BIP 112 - CHECKSEQUENCEVERIFY BIP 112 - CHECKSEQUENCEVERIFY
@ -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 - 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 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 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 base_relative_locktime = 10
seq_disable_flag = 1<<31 seq_disable_flag = 1<<31

View file

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

View file

@ -2,6 +2,19 @@
# Copyright (c) 2015-2016 The Bitcoin Core developers # Copyright (c) 2015-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php. # file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test BIP 9 soft forks.
Connect to a single node.
regtest lock-in with 108/144 block signalling
activation after a further 144 blocks
mine 2 block and save coinbases for later use
mine 141 blocks to transition from DEFINED to STARTED
mine 100 blocks signalling readiness and 44 not in order to fail to change state this period
mine 108 blocks signalling readiness and 36 blocks not signalling readiness (STARTED->LOCKED_IN)
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.blockstore import BlockStore
from test_framework.test_framework import ComparisonTestFramework from test_framework.test_framework import ComparisonTestFramework
@ -14,21 +27,6 @@ from io import BytesIO
import time import time
import itertools 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
mine 2 block and save coinbases for later use
mine 141 blocks to transition from DEFINED to STARTED
mine 100 blocks signalling readiness and 44 not in order to fail to change state this period
mine 108 blocks signalling readiness and 36 blocks not signalling readiness (STARTED->LOCKED_IN)
mine a further 143 blocks (LOCKED_IN)
test that enforcement has not triggered (which triggers ACTIVE)
test that enforcement has triggered
'''
class BIP9SoftForksTest(ComparisonTestFramework): class BIP9SoftForksTest(ComparisonTestFramework):
def __init__(self): def __init__(self):
@ -225,21 +223,21 @@ class BIP9SoftForksTest(ComparisonTestFramework):
return return
def csv_invalidate(self, tx): 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. Prepends -1 CSV DROP in the scriptSig itself.
''' """
tx.vin[0].scriptSig = CScript([OP_1NEGATE, OP_CHECKSEQUENCEVERIFY, OP_DROP] + tx.vin[0].scriptSig = CScript([OP_1NEGATE, OP_CHECKSEQUENCEVERIFY, OP_DROP] +
list(CScript(tx.vin[0].scriptSig))) list(CScript(tx.vin[0].scriptSig)))
def sequence_lock_invalidate(self, tx): 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.vin[0].nSequence = 0x00FFFFFF
tx.nLockTime = 0 tx.nLockTime = 0
def mtp_invalidate(self, tx): 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 # Disable Sequence lock, Activate nLockTime
tx.vin[0].nSequence = 0x90FFFFFF tx.vin[0].nSequence = 0x90FFFFFF
tx.nLockTime = self.last_block_time tx.nLockTime = self.last_block_time

View file

@ -2,6 +2,19 @@
# Copyright (c) 2015-2016 The Bitcoin Core developers # Copyright (c) 2015-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php. # 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.test_framework import ComparisonTestFramework
from test_framework.util import * from test_framework.util import *
@ -15,10 +28,10 @@ import time
# A canonical signature consists of: # A canonical signature consists of:
# <30> <total len> <02> <len R> <R> <02> <len S> <S> <hashtype> # <30> <total len> <02> <len R> <R> <02> <len S> <S> <hashtype>
def unDERify(tx): def unDERify(tx):
''' """
Make the signature in vin 0 of a tx non-DER-compliant, Make the signature in vin 0 of a tx non-DER-compliant,
by adding padding after the S-value. by adding padding after the S-value.
''' """
scriptSig = CScript(tx.vin[0].scriptSig) scriptSig = CScript(tx.vin[0].scriptSig)
newscript = [] newscript = []
for i in scriptSig: for i in scriptSig:
@ -28,20 +41,6 @@ def unDERify(tx):
newscript.append(i) newscript.append(i)
tx.vin[0].scriptSig = CScript(newscript) 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): class BIP66Test(ComparisonTestFramework):
def __init__(self): def __init__(self):

View file

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

View file

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

View file

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

View file

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

View file

@ -2,6 +2,7 @@
# Copyright (c) 2015-2016 The Bitcoin Core developers # Copyright (c) 2015-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php. # 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.test_framework import BitcoinTestFramework
from test_framework.util import * from test_framework.util import *
@ -9,7 +10,6 @@ from test_framework.mininode import *
from io import BytesIO from io import BytesIO
class DecodeScriptTest(BitcoinTestFramework): class DecodeScriptTest(BitcoinTestFramework):
"""Tests decoding scripts via RPC command "decodescript"."""
def __init__(self): def __init__(self):
super().__init__() super().__init__()
@ -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']) 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): 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. This test is in with the "decodescript" tests because they are testing the same "asm" script decodes.
""" """

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -2,7 +2,9 @@
# Copyright (c) 2014-2016 The Bitcoin Core developers # Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php. # 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. 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 In the first part of the test, node 0 creates an address for each type of

View file

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

View file

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

View file

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

View file

@ -2,6 +2,14 @@
# Copyright (c) 2015-2016 The Bitcoin Core developers # Copyright (c) 2015-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php. # 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.test_framework import ComparisonTestFramework
from test_framework.util import * from test_framework.util import *
@ -10,15 +18,6 @@ from test_framework.blocktools import *
import copy import copy
import time 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. # Use the ComparisonTestFramework with 1 node: only use --testbinary.
class InvalidBlockRequestTest(ComparisonTestFramework): class InvalidBlockRequestTest(ComparisonTestFramework):

View file

@ -2,6 +2,10 @@
# Copyright (c) 2015-2016 The Bitcoin Core developers # Copyright (c) 2015-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php. # 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.test_framework import ComparisonTestFramework
from test_framework.comptool import TestManager, TestInstance, RejectResult from test_framework.comptool import TestManager, TestInstance, RejectResult
@ -9,9 +13,6 @@ from test_framework.blocktools import *
import time 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. # Use the ComparisonTestFramework with 1 node: only use --testbinary.
class InvalidTxRequestTest(ComparisonTestFramework): class InvalidTxRequestTest(ComparisonTestFramework):

View file

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

View file

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

View file

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

View file

@ -2,18 +2,19 @@
# Copyright (c) 2015-2016 The Bitcoin Core developers # Copyright (c) 2015-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php. # 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.mininode import *
from test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import * from test_framework.util import *
import logging 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 MAX_REQUESTS = 128
class TestManager(NodeConnCB): class TestManager(NodeConnCB):

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -2,6 +2,16 @@
# Copyright (c) 2016 The Bitcoin Core developers # Copyright (c) 2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php. # 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.test_framework import BitcoinTestFramework
from test_framework.util import * from test_framework.util import *
@ -25,17 +35,6 @@ def trueDummy(tx):
tx.vin[0].scriptSig = CScript(newscript) tx.vin[0].scriptSig = CScript(newscript)
tx.rehash() 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): class NULLDUMMYTest(BitcoinTestFramework):
def __init__(self): def __init__(self):

View file

@ -2,15 +2,7 @@
# Copyright (c) 2015-2016 The Bitcoin Core developers # Copyright (c) 2015-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php. # file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test processing of unrequested blocks.
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.
Since behavior differs when receiving unrequested blocks from whitelisted peers Since behavior differs when receiving unrequested blocks from whitelisted peers
versus non-whitelisted peers, this tests the behavior of both (effectively two versus non-whitelisted peers, this tests the behavior of both (effectively two
@ -54,7 +46,13 @@ The test:
7. Send Node0 the missing block again. 7. Send Node0 the missing block again.
Node0 should process and the tip should advance. 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 # 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. # p2p messages to a node, generating the messages in the main testing logic.

View file

@ -2,6 +2,11 @@
# Copyright (c) 2016 The Bitcoin Core developers # Copyright (c) 2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php. # 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.mininode import *
from test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
@ -9,13 +14,6 @@ from test_framework.util import *
from test_framework.blocktools import create_block, create_coinbase, add_witness_commitment from test_framework.blocktools import create_block, create_coinbase, add_witness_commitment
from test_framework.script import CScript, OP_TRUE 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. # TestNode: A peer we use to send messages to bitcoind, and store responses.
class TestNode(SingleNodeConnCB): class TestNode(SingleNodeConnCB):
def __init__(self): def __init__(self):

View file

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

View file

@ -2,6 +2,14 @@
# Copyright (c) 2015-2016 The Bitcoin Core developers # Copyright (c) 2015-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php. # 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.test_framework import ComparisonTestFramework
from test_framework.util import * from test_framework.util import *
@ -17,14 +25,6 @@ class PreviousSpendableOutput(object):
self.tx = tx self.tx = tx
self.n = n # the output we're spending 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. # Use this class for tests that require behavior other than normal "mininode" behavior.
# For now, it is used to serialize a bloated varint (b64). # For now, it is used to serialize a bloated varint (b64).
class CBrokenBlock(CBlock): class CBrokenBlock(CBlock):

View file

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

View file

@ -2,6 +2,11 @@
# Copyright (c) 2015-2016 The Bitcoin Core developers # Copyright (c) 2015-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php. # 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.mininode import *
from test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework

View file

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

View file

@ -2,7 +2,7 @@
# Copyright (c) 2016 The Bitcoin Core developers # Copyright (c) 2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php. # 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: - Create three bitcoind nodes:

View file

@ -2,6 +2,11 @@
# Copyright (c) 2016 The Bitcoin Core developers # Copyright (c) 2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php. # 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.mininode import *
from test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
@ -10,13 +15,6 @@ import re
import time import time
from test_framework.blocktools import create_block, create_coinbase 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_PERIOD = 144 # versionbits period length for regtest
VB_THRESHOLD = 108 # versionbits activation threshold for regtest VB_THRESHOLD = 108 # versionbits activation threshold for regtest
VB_TOP_BITS = 0x20000000 VB_TOP_BITS = 0x20000000

View file

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

View file

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

View file

@ -2,20 +2,8 @@
# Copyright (c) 2015-2016 The Bitcoin Core developers # Copyright (c) 2015-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php. # 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: Test plan:
- Start bitcoind's with different proxy configurations - Start bitcoind's with different proxy configurations
- Use addnode to initiate connections - Use addnode to initiate connections
@ -37,7 +25,20 @@ addnode connect to IPv4
addnode connect to IPv6 addnode connect to IPv6
addnode connect to onion addnode connect to onion
addnode connect to generic DNS name 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 RANGE_BEGIN = PORT_MIN + 2 * PORT_RANGE # Start after p2p and rpc ports

View file

@ -2,14 +2,12 @@
# Copyright (c) 2014-2016 The Bitcoin Core developers # Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php. # file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test the pruning code.
# WARNING:
# Test pruning code 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.test_framework import BitcoinTestFramework
from test_framework.util import * from test_framework.util import *

View file

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

View file

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

View file

@ -2,10 +2,13 @@
# Copyright (c) 2014-2016 The Bitcoin Core developers # Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php. # 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.test_framework import BitcoinTestFramework
from test_framework.util import ( from test_framework.util import (
start_nodes, start_nodes,

View file

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

View file

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

View file

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

View file

@ -2,6 +2,7 @@
# Copyright (c) 2016 The Bitcoin Core developers # Copyright (c) 2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php. # 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.test_framework import BitcoinTestFramework
from test_framework.util import ( from test_framework.util import (

View file

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

View file

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

View file

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

View file

@ -2,14 +2,13 @@
# Copyright (c) 2015-2016 The Bitcoin Core developers # Copyright (c) 2015-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php. # 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.test_framework import BitcoinTestFramework
from test_framework.util import * from test_framework.util import *
class SignRawTransactionsTest(BitcoinTestFramework): class SignRawTransactionsTest(BitcoinTestFramework):
"""Tests transaction signing via RPC command "signrawtransaction"."""
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.setup_clean_chain = True self.setup_clean_chain = True
@ -20,7 +19,7 @@ class SignRawTransactionsTest(BitcoinTestFramework):
self.is_network_split = False self.is_network_split = False
def successful_signing_test(self): 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: Expected results:
@ -65,7 +64,7 @@ class SignRawTransactionsTest(BitcoinTestFramework):
def script_verification_error_test(self): 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: Expected results:

View file

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

View file

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

View file

@ -1,37 +1,36 @@
# 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
Copyright (c) 2011 Jeff Garzik ServiceProxy class:
AuthServiceProxy has the following improvements over python-jsonrpc's - HTTP connections persist for the life of the AuthServiceProxy object
ServiceProxy class:
- HTTP connections persist for the life of the AuthServiceProxy object
(if server supports HTTP/1.1) (if server supports HTTP/1.1)
- sends protocol 'version', per JSON-RPC 1.1 - sends protocol 'version', per JSON-RPC 1.1
- sends proper, incrementing 'id' - sends proper, incrementing 'id'
- sends Basic HTTP authentication headers - sends Basic HTTP authentication headers
- parses all JSON numbers that look like floats as Decimal - parses all JSON numbers that look like floats as Decimal
- uses standard Python json lib - 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
""" """
try: try:

View file

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

View file

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

View file

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

View file

@ -2,34 +2,29 @@
# Copyright (c) 2015-2016 The Bitcoin Core developers # Copyright (c) 2015-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php. # file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""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
"""
from .mininode import * from .mininode import *
from .blockstore import BlockStore, TxStore from .blockstore import BlockStore, TxStore
from .util import p2p_port from .util import p2p_port
'''
This is a tool for comparing two or more bitcoinds to each other
using a script provided.
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
global mininode_lock global mininode_lock
class RejectResult(object): 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''): def __init__(self, code, reason=b''):
self.code = code self.code = code
self.reason = reason self.reason = reason

View file

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

View file

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

View file

@ -4,23 +4,21 @@
# Copyright (c) 2010-2016 The Bitcoin Core developers # Copyright (c) 2010-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php. # file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Bitcoin P2P network half-a-node.
# This python code was modified from ArtForz' public domain half-a-node, as
# mininode.py - Bitcoin P2P network half-a-node found in the mini-node branch of http://github.com/jgarzik/pynode.
#
# 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
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 struct
import socket import socket

View file

@ -2,8 +2,10 @@
# Copyright (c) 2014-2016 The Bitcoin Core developers # Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php. # 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 sys
import socket import socket
@ -13,7 +15,6 @@ import array
import os import os
from binascii import unhexlify, hexlify 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_ESTABLISHED = '01'
STATE_SYN_SENT = '02' STATE_SYN_SENT = '02'
STATE_SYN_RECV = '03' STATE_SYN_RECV = '03'

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -2,6 +2,15 @@
# Copyright (c) 2016 The Bitcoin Core developers # Copyright (c) 2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php. # 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.test_framework import BitcoinTestFramework
from test_framework.util import ( from test_framework.util import (
@ -9,7 +18,6 @@ from test_framework.util import (
assert_equal, assert_equal,
) )
class WalletAccountsTest(BitcoinTestFramework): class WalletAccountsTest(BitcoinTestFramework):
def __init__(self): def __init__(self):

View file

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

View file

@ -2,6 +2,7 @@
# Copyright (c) 2016 The Bitcoin Core developers # Copyright (c) 2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php. # 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.test_framework import BitcoinTestFramework
from test_framework.util import ( from test_framework.util import (

View file

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

View file

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

View file

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

View file

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