Browse Source

[QA] add setban/listbanned/clearbanned tests

0.13
Jonas Schnelli 10 years ago
parent
commit
1086ffba26
  1. 11
      qa/rpc-tests/httpbasics.py
  2. 9
      src/test/rpc_tests.cpp

11
qa/rpc-tests/httpbasics.py

@ -98,5 +98,16 @@ class HTTPBasicsTest (BitcoinTestFramework):
assert_equal('"error":null' in out1, True) assert_equal('"error":null' in out1, True)
assert_equal(conn.sock!=None, True) #connection must be closed because bitcoind should use keep-alive by default assert_equal(conn.sock!=None, True) #connection must be closed because bitcoind should use keep-alive by default
###########################
# setban/listbanned tests #
###########################
assert_equal(len(self.nodes[2].getpeerinfo()), 4); #we should have 4 nodes at this point
self.nodes[2].setban("127.0.0.1", "add")
time.sleep(3) #wait till the nodes are disconected
assert_equal(len(self.nodes[2].getpeerinfo()), 0); #all nodes must be disconnected at this point
assert_equal(len(self.nodes[2].listbanned()), 1);
self.nodes[2].clearbanned()
assert_equal(len(self.nodes[2].listbanned()), 0);
if __name__ == '__main__': if __name__ == '__main__':
HTTPBasicsTest ().main () HTTPBasicsTest ().main ()

9
src/test/rpc_tests.cpp

@ -177,4 +177,13 @@ BOOST_AUTO_TEST_CASE(rpc_boostasiotocnetaddr)
BOOST_CHECK_EQUAL(BoostAsioToCNetAddr(boost::asio::ip::address::from_string("::ffff:127.0.0.1")).ToString(), "127.0.0.1"); BOOST_CHECK_EQUAL(BoostAsioToCNetAddr(boost::asio::ip::address::from_string("::ffff:127.0.0.1")).ToString(), "127.0.0.1");
} }
BOOST_AUTO_TEST_CASE(rpc_ban)
{
BOOST_CHECK_NO_THROW(CallRPC(string("setban 127.0.0.1 add")));
BOOST_CHECK_THROW(CallRPC(string("setban 127.0.0.1:8334")), runtime_error); //portnumber for setban not allowed
BOOST_CHECK_NO_THROW(CallRPC(string("listbanned")));
BOOST_CHECK_NO_THROW(CallRPC(string("setban 127.0.0.1 remove")));
BOOST_CHECK_NO_THROW(CallRPC(string("clearbanned")));
}
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()

Loading…
Cancel
Save