aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2017-04-23 17:04:38 +0200
committerMarcoFalke <falke.marco@gmail.com>2017-04-23 17:04:46 +0200
commit2723bcdce3248417e98e6c43207bef74d34076c1 (patch)
treea13f1e525d263cd21f4b84d09cd284f861c46f97
parented22eb4a62bd8d5369aaec87d4cbdc03c9f16368 (diff)
parentbc537526164324d4be9c37aa72bb75db8073d283 (diff)
Merge #10224: [test] Add test for getaddednodeinfo
bc53752 Tests: Add simple test for getaddednodeinfo (Jimmy Song) Tree-SHA512: d2f8a384fb994b83f881b585db70e7cf57980821074126d254960cb67988a40672ffde065d0ccd9a90f9e3b395d8cd33695c796ecb4b54f69fe74ee2bf7497a6
-rwxr-xr-xtest/functional/net.py21
1 files changed, 17 insertions, 4 deletions
diff --git a/test/functional/net.py b/test/functional/net.py
index e9463c7dc7..a82cdabf52 100755
--- a/test/functional/net.py
+++ b/test/functional/net.py
@@ -7,15 +7,15 @@
Tests correspond to code in rpc/net.cpp.
"""
-from decimal import Decimal
import time
from test_framework.test_framework import BitcoinTestFramework
-from test_framework.authproxy import JSONRPCException
from test_framework.util import (
assert_equal,
- start_nodes,
+ assert_raises_jsonrpc,
connect_nodes_bi,
+ p2p_port,
+ start_nodes,
)
@@ -33,7 +33,7 @@ class NetTest(BitcoinTestFramework):
def run_test(self):
assert_equal(self.nodes[0].getnetworkinfo()['networkactive'], True)
- assert_equal(self.nodes[0].getnetworkinfo()['connections'], 2) # bilateral connection
+ assert_equal(self.nodes[0].getnetworkinfo()['connections'], 2)
self.nodes[0].setnetworkactive(False)
assert_equal(self.nodes[0].getnetworkinfo()['networkactive'], False)
@@ -49,6 +49,19 @@ class NetTest(BitcoinTestFramework):
assert_equal(self.nodes[0].getnetworkinfo()['networkactive'], True)
assert_equal(self.nodes[0].getnetworkinfo()['connections'], 2)
+ # test getaddednodeinfo
+ assert_equal(self.nodes[0].getaddednodeinfo(), [])
+ # add a node (node2) to node0
+ ip_port = "127.0.0.1:{}".format(p2p_port(2))
+ self.nodes[0].addnode(ip_port, 'add')
+ # check that the node has indeed been added
+ added_nodes = self.nodes[0].getaddednodeinfo(ip_port)
+ assert_equal(len(added_nodes), 1)
+ assert_equal(added_nodes[0]['addednode'], ip_port)
+ # check that a non-existant node returns an error
+ assert_raises_jsonrpc(-24, "Node has not been added",
+ self.nodes[0].getaddednodeinfo, '1.1.1.1')
+
if __name__ == '__main__':
NetTest().main()