diff options
Diffstat (limited to 'test')
-rwxr-xr-x | test/functional/mempool_compatibility.py | 17 | ||||
-rwxr-xr-x | test/functional/rpc_setban.py | 16 | ||||
-rw-r--r-- | test/functional/test_framework/util.py | 1 | ||||
-rw-r--r-- | test/functional/test_framework/wallet.py | 10 | ||||
-rwxr-xr-x | test/lint/lint-includes.sh | 3 |
5 files changed, 34 insertions, 13 deletions
diff --git a/test/functional/mempool_compatibility.py b/test/functional/mempool_compatibility.py index 8ac91bd008..eb08765ebf 100755 --- a/test/functional/mempool_compatibility.py +++ b/test/functional/mempool_compatibility.py @@ -16,15 +16,15 @@ Only v0.15.2 is required by this test. The rest is used in other backwards compa import os from test_framework.test_framework import BitcoinTestFramework +from test_framework.wallet import MiniWallet class MempoolCompatibilityTest(BitcoinTestFramework): def set_test_params(self): self.num_nodes = 2 - self.wallet_names = [None, self.default_wallet_name] + self.wallet_names = [None] def skip_test_if_missing_module(self): - self.skip_if_no_wallet() self.skip_if_no_previous_releases() def setup_network(self): @@ -38,8 +38,15 @@ class MempoolCompatibilityTest(BitcoinTestFramework): def run_test(self): self.log.info("Test that mempool.dat is compatible between versions") - old_node = self.nodes[0] - new_node = self.nodes[1] + old_node, new_node = self.nodes + new_wallet = MiniWallet(new_node) + new_wallet.generate(1) + new_node.generate(100) + # Sync the nodes to ensure old_node has the block that contains the coinbase that new_wallet will spend. + # Otherwise, because coinbases are only valid in a block and not as loose txns, if the nodes aren't synced + # unbroadcasted_tx won't pass old_node's `MemPoolAccept::PreChecks`. + self.connect_nodes(0, 1) + self.sync_blocks() recipient = old_node.getnewaddress() self.stop_node(1) @@ -58,7 +65,7 @@ class MempoolCompatibilityTest(BitcoinTestFramework): assert old_tx_hash in new_node.getrawmempool() self.log.info("Add unbroadcasted tx to mempool on new node and shutdown") - unbroadcasted_tx_hash = new_node.sendtoaddress(recipient, 0.0001) + unbroadcasted_tx_hash = new_wallet.send_self_transfer(from_node=new_node)['txid'] assert unbroadcasted_tx_hash in new_node.getrawmempool() mempool = new_node.getrawmempool(True) assert mempool[unbroadcasted_tx_hash]['unbroadcast'] diff --git a/test/functional/rpc_setban.py b/test/functional/rpc_setban.py index 523fdc9f63..fd5f8aa098 100755 --- a/test/functional/rpc_setban.py +++ b/test/functional/rpc_setban.py @@ -15,6 +15,9 @@ class SetBanTests(BitcoinTestFramework): self.setup_clean_chain = True self.extra_args = [[],[]] + def is_banned(self, node, addr): + return any(e['address'] == addr for e in node.listbanned()) + def run_test(self): # Node 0 connects to Node 1, check that the noban permission is not granted self.connect_nodes(0, 1) @@ -42,5 +45,18 @@ class SetBanTests(BitcoinTestFramework): peerinfo = self.nodes[1].getpeerinfo()[0] assert(not 'noban' in peerinfo['permissions']) + self.log.info("Test that a non-IP address can be banned/unbanned") + node = self.nodes[1] + tor_addr = "pg6mmjiyjmcrsslvykfwnntlaru7p5svn6y2ymmju6nubxndf4pscryd.onion" + ip_addr = "1.2.3.4" + assert(not self.is_banned(node, tor_addr)) + assert(not self.is_banned(node, ip_addr)) + node.setban(tor_addr, "add") + assert(self.is_banned(node, tor_addr)) + assert(not self.is_banned(node, ip_addr)) + node.setban(tor_addr, "remove") + assert(not self.is_banned(self.nodes[1], tor_addr)) + assert(not self.is_banned(node, ip_addr)) + if __name__ == '__main__': SetBanTests().main() diff --git a/test/functional/test_framework/util.py b/test/functional/test_framework/util.py index 62ff5c6e33..b3eb2d61a7 100644 --- a/test/functional/test_framework/util.py +++ b/test/functional/test_framework/util.py @@ -362,6 +362,7 @@ def initialize_datadir(dirname, n, chain): f.write("listenonion=0\n") f.write("printtoconsole=0\n") f.write("upnp=0\n") + f.write("natpmp=0\n") f.write("shrinkdebugfile=0\n") os.makedirs(os.path.join(datadir, 'stderr'), exist_ok=True) os.makedirs(os.path.join(datadir, 'stdout'), exist_ok=True) diff --git a/test/functional/test_framework/wallet.py b/test/functional/test_framework/wallet.py index a71f2c69cb..7cb74bdcb3 100644 --- a/test/functional/test_framework/wallet.py +++ b/test/functional/test_framework/wallet.py @@ -71,9 +71,9 @@ class MiniWallet: tx.wit.vtxinwit[0].scriptWitness.stack = [CScript([OP_TRUE])] tx_hex = tx.serialize().hex() - txid = from_node.sendrawtransaction(tx_hex) - self._utxos.append({'txid': txid, 'vout': 0, 'value': send_value}) - tx_info = from_node.getmempoolentry(txid) + tx_info = from_node.testmempoolaccept([tx_hex])[0] + self._utxos.append({'txid': tx_info['txid'], 'vout': 0, 'value': send_value}) + from_node.sendrawtransaction(tx_hex) assert_equal(tx_info['vsize'], vsize) - assert_equal(tx_info['fee'], fee) - return {'txid': txid, 'wtxid': tx_info['wtxid'], 'hex': tx_hex} + assert_equal(tx_info['fees']['base'], fee) + return {'txid': tx_info['txid'], 'wtxid': from_node.decoderawtransaction(tx_hex)['hash'], 'hex': tx_hex} diff --git a/test/lint/lint-includes.sh b/test/lint/lint-includes.sh index 393f734abe..dc032665e4 100755 --- a/test/lint/lint-includes.sh +++ b/test/lint/lint-includes.sh @@ -71,9 +71,6 @@ EXPECTED_BOOST_INCLUDES=( boost/thread/mutex.hpp boost/thread/shared_mutex.hpp boost/thread/thread.hpp - boost/variant.hpp - boost/variant/apply_visitor.hpp - boost/variant/static_visitor.hpp ) for BOOST_INCLUDE in $(git grep '^#include <boost/' -- "*.cpp" "*.h" | cut -f2 -d: | cut -f2 -d'<' | cut -f1 -d'>' | sort -u); do |