aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest/functional/p2p_segwit.py12
-rwxr-xr-xtest/functional/rpc_psbt.py6
-rwxr-xr-xtest/functional/test_framework/mininode.py10
-rwxr-xr-xtest/functional/wallet_multiwallet.py6
-rwxr-xr-xtest/lint/lint-git-commit-check.sh46
-rwxr-xr-xtest/lint/lint-include-guards.sh2
6 files changed, 67 insertions, 15 deletions
diff --git a/test/functional/p2p_segwit.py b/test/functional/p2p_segwit.py
index 9915b844d1..728212ca23 100755
--- a/test/functional/p2p_segwit.py
+++ b/test/functional/p2p_segwit.py
@@ -2133,17 +2133,17 @@ class SegWitTest(BitcoinTestFramework):
# Send tx2 through; it's an orphan so won't be accepted
with mininode_lock:
- self.tx_node.last_message.pop("getdata", None)
- test_transaction_acceptance(self.nodes[0], self.tx_node, tx2, with_witness=True, accepted=False)
+ self.wtx_node.last_message.pop("getdata", None)
+ test_transaction_acceptance(self.nodes[0], self.wtx_node, tx2, with_witness=True, accepted=False)
- # Expect a request for parent (tx) due to use of non-WTX peer
- self.tx_node.wait_for_getdata([tx.sha256], 60)
+ # Expect a request for parent (tx) by txid despite use of WTX peer
+ self.wtx_node.wait_for_getdata([tx.sha256], 60)
with mininode_lock:
- lgd = self.tx_node.lastgetdata[:]
+ lgd = self.wtx_node.lastgetdata[:]
assert_equal(lgd, [CInv(MSG_TX|MSG_WITNESS_FLAG, tx.sha256)])
# Send tx through
- test_transaction_acceptance(self.nodes[0], self.tx_node, tx, with_witness=False, accepted=True)
+ test_transaction_acceptance(self.nodes[0], self.wtx_node, tx, with_witness=False, accepted=True)
# Check tx2 is there now
assert_equal(tx2.hash in self.nodes[0].getrawmempool(), True)
diff --git a/test/functional/rpc_psbt.py b/test/functional/rpc_psbt.py
index e5e62fd646..4d985dd1b1 100755
--- a/test/functional/rpc_psbt.py
+++ b/test/functional/rpc_psbt.py
@@ -155,12 +155,14 @@ class PSBTTest(BitcoinTestFramework):
p2pkh_pos = out['n']
# spend single key from node 1
- rawtx = self.nodes[1].walletcreatefundedpsbt([{"txid":txid,"vout":p2wpkh_pos},{"txid":txid,"vout":p2sh_p2wpkh_pos},{"txid":txid,"vout":p2pkh_pos}], {self.nodes[1].getnewaddress():29.99})['psbt']
- walletprocesspsbt_out = self.nodes[1].walletprocesspsbt(rawtx)
+ created_psbt = self.nodes[1].walletcreatefundedpsbt([{"txid":txid,"vout":p2wpkh_pos},{"txid":txid,"vout":p2sh_p2wpkh_pos},{"txid":txid,"vout":p2pkh_pos}], {self.nodes[1].getnewaddress():29.99})
+ walletprocesspsbt_out = self.nodes[1].walletprocesspsbt(created_psbt['psbt'])
# Make sure it has both types of UTXOs
decoded = self.nodes[1].decodepsbt(walletprocesspsbt_out['psbt'])
assert 'non_witness_utxo' in decoded['inputs'][0]
assert 'witness_utxo' in decoded['inputs'][0]
+ # Check decodepsbt fee calculation (input values shall only be counted once per UTXO)
+ assert_equal(decoded['fee'], created_psbt['fee'])
assert_equal(walletprocesspsbt_out['complete'], True)
self.nodes[1].sendrawtransaction(self.nodes[1].finalizepsbt(walletprocesspsbt_out['psbt'])['hex'])
diff --git a/test/functional/test_framework/mininode.py b/test/functional/test_framework/mininode.py
index f68c1a9ddd..07811667a8 100755
--- a/test/functional/test_framework/mininode.py
+++ b/test/functional/test_framework/mininode.py
@@ -283,9 +283,13 @@ class P2PInterface(P2PConnection):
def __init__(self):
super().__init__()
- # Track number of messages of each type received and the most recent
- # message of each type
+ # Track number of messages of each type received.
+ # Should be read-only in a test.
self.message_count = defaultdict(int)
+
+ # Track the most recent message of each type.
+ # To wait for a message to be received, pop that message from
+ # this and use wait_until.
self.last_message = {}
# A count of the number of ping messages we've sent to the node
@@ -472,7 +476,7 @@ class P2PInterface(P2PConnection):
def wait_for_verack(self, timeout=60):
def test_function():
- return self.message_count["verack"]
+ return "verack" in self.last_message
self.wait_until(test_function, timeout=timeout)
diff --git a/test/functional/wallet_multiwallet.py b/test/functional/wallet_multiwallet.py
index 88beef1034..a54396cad3 100755
--- a/test/functional/wallet_multiwallet.py
+++ b/test/functional/wallet_multiwallet.py
@@ -120,7 +120,7 @@ class MultiWalletTest(BitcoinTestFramework):
# should not initialize if one wallet is a copy of another
shutil.copyfile(wallet_dir('w8'), wallet_dir('w8_copy'))
- exp_stderr = r"BerkeleyBatch: Can't open database w8_copy \(duplicates fileid \w+ from w8\)"
+ exp_stderr = r"BerkeleyDatabase: Can't open database w8_copy \(duplicates fileid \w+ from w8\)"
self.nodes[0].assert_start_raises_init_error(['-wallet=w8', '-wallet=w8_copy'], exp_stderr, match=ErrorMatch.PARTIAL_REGEX)
# should not initialize if wallet file is a symlink
@@ -258,10 +258,10 @@ class MultiWalletTest(BitcoinTestFramework):
assert_raises_rpc_error(-4, "Wallet file verification failed. Error loading wallet wallet.dat. Duplicate -wallet filename specified.", self.nodes[0].loadwallet, 'wallet.dat')
# Fail to load if one wallet is a copy of another
- assert_raises_rpc_error(-4, "BerkeleyBatch: Can't open database w8_copy (duplicates fileid", self.nodes[0].loadwallet, 'w8_copy')
+ assert_raises_rpc_error(-4, "BerkeleyDatabase: Can't open database w8_copy (duplicates fileid", self.nodes[0].loadwallet, 'w8_copy')
# Fail to load if one wallet is a copy of another, test this twice to make sure that we don't re-introduce #14304
- assert_raises_rpc_error(-4, "BerkeleyBatch: Can't open database w8_copy (duplicates fileid", self.nodes[0].loadwallet, 'w8_copy')
+ assert_raises_rpc_error(-4, "BerkeleyDatabase: Can't open database w8_copy (duplicates fileid", self.nodes[0].loadwallet, 'w8_copy')
# Fail to load if wallet file is a symlink
diff --git a/test/lint/lint-git-commit-check.sh b/test/lint/lint-git-commit-check.sh
new file mode 100755
index 0000000000..7cffd267dd
--- /dev/null
+++ b/test/lint/lint-git-commit-check.sh
@@ -0,0 +1,46 @@
+#!/usr/bin/env bash
+# Copyright (c) 2020 The Bitcoin Core developers
+# Distributed under the MIT software license, see the accompanying
+# file COPYING or http://www.opensource.org/licenses/mit-license.php.
+#
+# Linter to check that commit messages have a new line before the body
+# or no body at all
+
+export LC_ALL=C
+
+EXIT_CODE=0
+
+while getopts "?" opt; do
+ case $opt in
+ ?)
+ echo "Usage: $0 [N]"
+ echo " TRAVIS_COMMIT_RANGE='<commit range>' $0"
+ echo " $0 -?"
+ echo "Checks unmerged commits, the previous N commits, or a commit range."
+ echo "TRAVIS_COMMIT_RANGE='47ba2c3...ee50c9e' $0"
+ exit ${EXIT_CODE}
+ ;;
+ esac
+done
+
+if [ -z "${TRAVIS_COMMIT_RANGE}" ]; then
+ if [ -n "$1" ]; then
+ TRAVIS_COMMIT_RANGE="HEAD~$1...HEAD"
+ else
+ TRAVIS_COMMIT_RANGE="origin/master..HEAD"
+ fi
+fi
+
+while IFS= read -r commit_hash || [[ -n "$commit_hash" ]]; do
+ n_line=0
+ while IFS= read -r line || [[ -n "$line" ]]; do
+ n_line=$((n_line+1))
+ length=${#line}
+ if [ $n_line -eq 2 ] && [ $length -ne 0 ]; then
+ echo "The subject line of commit hash ${commit_hash} is followed by a non-empty line. Subject lines should always be followed by a blank line."
+ EXIT_CODE=1
+ fi
+ done < <(git log --format=%B -n 1 "$commit_hash")
+done < <(git log "${TRAVIS_COMMIT_RANGE}" --format=%H)
+
+exit ${EXIT_CODE}
diff --git a/test/lint/lint-include-guards.sh b/test/lint/lint-include-guards.sh
index 3a0494c190..5d5a150db8 100755
--- a/test/lint/lint-include-guards.sh
+++ b/test/lint/lint-include-guards.sh
@@ -10,7 +10,7 @@ export LC_ALL=C
HEADER_ID_PREFIX="BITCOIN_"
HEADER_ID_SUFFIX="_H"
-REGEXP_EXCLUDE_FILES_WITH_PREFIX="src/(crypto/ctaes/|leveldb/|crc32c/|secp256k1/|test/fuzz/FuzzedDataProvider.h|tinyformat.h|univalue/)"
+REGEXP_EXCLUDE_FILES_WITH_PREFIX="src/(crypto/ctaes/|leveldb/|crc32c/|secp256k1/|test/fuzz/FuzzedDataProvider.h|tinyformat.h|bench/nanobench.h|univalue/)"
EXIT_CODE=0
for HEADER_FILE in $(git ls-files -- "*.h" | grep -vE "^${REGEXP_EXCLUDE_FILES_WITH_PREFIX}")