From 580584061360fff89cf307b90b995d78ca2ab248 Mon Sep 17 00:00:00 2001 From: Dmitri Bogomolov <4glitch@gmail.com> Date: Wed, 10 Jun 2020 00:49:14 +0300 Subject: [PATCH] A test case for protocol with the test for TCPConnection.local --- src/tests/test_protocol.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/tests/test_protocol.py diff --git a/src/tests/test_protocol.py b/src/tests/test_protocol.py new file mode 100644 index 00000000..84d87a0f --- /dev/null +++ b/src/tests/test_protocol.py @@ -0,0 +1,22 @@ +""" +Tests for common protocol functions +""" + +import unittest + + +class TestProtocol(unittest.TestCase): + """Main protocol test case""" + + def test_check_local(self): + """Check the logic of TCPConnection.local""" + from pybitmessage import protocol, state + + self.assertTrue( + protocol.checkIPAddress(protocol.encodeHost('127.0.0.1'), True)) + self.assertTrue( + protocol.checkIPAddress(protocol.encodeHost('192.168.0.1'), True)) + + self.assertTrue( + not protocol.checkSocksIP('127.0.0.1') + or state.socksIP)