aboutsummaryrefslogtreecommitdiff
path: root/test/functional
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional')
-rwxr-xr-xtest/functional/blockchain.py9
-rwxr-xr-xtest/functional/disablewallet.py2
-rwxr-xr-xtest/functional/disconnect_ban.py8
-rwxr-xr-xtest/functional/net.py1
-rwxr-xr-xtest/functional/rpcnamedargs.py1
-rwxr-xr-xtest/functional/signmessages.py1
-rwxr-xr-xtest/functional/wallet-accounts.py1
-rwxr-xr-xtest/functional/wallet-hd.py1
8 files changed, 16 insertions, 8 deletions
diff --git a/test/functional/blockchain.py b/test/functional/blockchain.py
index 00ae3d7572..8596f1edaf 100755
--- a/test/functional/blockchain.py
+++ b/test/functional/blockchain.py
@@ -10,6 +10,7 @@ Test the following RPCs:
- getbestblockhash
- getblockhash
- getblockheader
+ - getnetworkhashps
- verifychain
Tests correspond to code in rpc/blockchain.cpp.
@@ -23,8 +24,6 @@ from test_framework.util import (
assert_raises_jsonrpc,
assert_is_hex_string,
assert_is_hash_string,
- start_nodes,
- connect_nodes_bi,
)
@@ -39,6 +38,7 @@ class BlockchainTest(BitcoinTestFramework):
self._test_gettxoutsetinfo()
self._test_getblockheader()
self._test_getdifficulty()
+ self._test_getnetworkhashps()
self.nodes[0].verifychain(4, 0)
def _test_gettxoutsetinfo(self):
@@ -85,5 +85,10 @@ class BlockchainTest(BitcoinTestFramework):
# binary => decimal => binary math is why we do this check
assert abs(difficulty * 2**31 - 1) < 0.0001
+ def _test_getnetworkhashps(self):
+ hashes_per_second = self.nodes[0].getnetworkhashps()
+ # This should be 2 hashes every 10 minutes or 1/300
+ assert abs(hashes_per_second * 300 - 1) < 0.0001
+
if __name__ == '__main__':
BlockchainTest().main()
diff --git a/test/functional/disablewallet.py b/test/functional/disablewallet.py
index 3f77a1828d..d344513414 100755
--- a/test/functional/disablewallet.py
+++ b/test/functional/disablewallet.py
@@ -21,6 +21,8 @@ class DisableWalletTest (BitcoinTestFramework):
self.extra_args = [["-disablewallet"]]
def run_test (self):
+ # Make sure wallet is really disabled
+ assert_raises_jsonrpc(-32601, 'Method not found', self.nodes[0].getwalletinfo)
x = self.nodes[0].validateaddress('3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy')
assert(x['isvalid'] == False)
x = self.nodes[0].validateaddress('mneYUmWYsuk7kySiURxCi3AGxrAqZxLgPZ')
diff --git a/test/functional/disconnect_ban.py b/test/functional/disconnect_ban.py
index 50d79db903..f453fc0261 100755
--- a/test/functional/disconnect_ban.py
+++ b/test/functional/disconnect_ban.py
@@ -3,6 +3,7 @@
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test node disconnect and ban behavior"""
+import time
from test_framework.mininode import wait_until
from test_framework.test_framework import BitcoinTestFramework
@@ -56,11 +57,16 @@ class DisconnectBanTest(BitcoinTestFramework):
self.log.info("setban: test persistence across node restart")
self.nodes[1].setban("127.0.0.0/32", "add")
self.nodes[1].setban("127.0.0.0/24", "add")
+ # Set the mocktime so we can control when bans expire
+ old_time = int(time.time())
+ self.nodes[1].setmocktime(old_time)
self.nodes[1].setban("192.168.0.1", "add", 1) # ban for 1 seconds
self.nodes[1].setban("2001:4d48:ac57:400:cacf:e9ff:fe1d:9c63/19", "add", 1000) # ban for 1000 seconds
listBeforeShutdown = self.nodes[1].listbanned()
assert_equal("192.168.0.1/32", listBeforeShutdown[2]['address'])
- assert wait_until(lambda: len(self.nodes[1].listbanned()) == 3, timeout=10)
+ # Move time forward by 3 seconds so the third ban has expired
+ self.nodes[1].setmocktime(old_time + 3)
+ assert_equal(len(self.nodes[1].listbanned()), 3)
stop_node(self.nodes[1], 1)
diff --git a/test/functional/net.py b/test/functional/net.py
index 16476f7d34..fb46064441 100755
--- a/test/functional/net.py
+++ b/test/functional/net.py
@@ -15,7 +15,6 @@ from test_framework.util import (
assert_raises_jsonrpc,
connect_nodes_bi,
p2p_port,
- start_nodes,
)
diff --git a/test/functional/rpcnamedargs.py b/test/functional/rpcnamedargs.py
index fd81b02ead..3b286000a1 100755
--- a/test/functional/rpcnamedargs.py
+++ b/test/functional/rpcnamedargs.py
@@ -8,7 +8,6 @@ from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_equal,
assert_raises_jsonrpc,
- start_nodes,
)
diff --git a/test/functional/signmessages.py b/test/functional/signmessages.py
index bfde8e40ec..42f6a9daaf 100755
--- a/test/functional/signmessages.py
+++ b/test/functional/signmessages.py
@@ -5,7 +5,6 @@
"""Test RPC commands for signing and verifying messages."""
from test_framework.test_framework import BitcoinTestFramework
-from test_framework.util import *
class SignMessagesTest(BitcoinTestFramework):
diff --git a/test/functional/wallet-accounts.py b/test/functional/wallet-accounts.py
index 8dc1589117..e6635bea1c 100755
--- a/test/functional/wallet-accounts.py
+++ b/test/functional/wallet-accounts.py
@@ -15,7 +15,6 @@ RPCs tested are:
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
- start_nodes,
assert_equal,
)
diff --git a/test/functional/wallet-hd.py b/test/functional/wallet-hd.py
index bbf53e7dba..aab3b4bc2d 100755
--- a/test/functional/wallet-hd.py
+++ b/test/functional/wallet-hd.py
@@ -6,7 +6,6 @@
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
- start_nodes,
start_node,
assert_equal,
connect_nodes_bi,