(self)
| 95 | self.stop_nodes() |
| 96 | |
| 97 | def run_test(self): |
| 98 | if sum([self.options.run_ipv4, self.options.run_ipv6, self.options.run_nonloopback]) > 1: |
| 99 | raise AssertionError("Only one of --ipv4, --ipv6 and --nonloopback can be set") |
| 100 | |
| 101 | self.log.info("Check for ipv6") |
| 102 | have_ipv6 = test_ipv6_local() |
| 103 | if not have_ipv6 and not (self.options.run_ipv4 or self.options.run_nonloopback): |
| 104 | raise SkipTest("This test requires ipv6 support.") |
| 105 | |
| 106 | self.log.info("Check for non-loopback interface") |
| 107 | interfaces = all_interfaces() |
| 108 | if not interfaces: |
| 109 | raise AssertionError("all_interfaces() returned no IPv4 interfaces") |
| 110 | self.non_loopback_ip = None |
| 111 | for name,ip in interfaces: |
| 112 | if not ip.startswith('127.'): |
| 113 | self.non_loopback_ip = ip |
| 114 | break |
| 115 | if self.non_loopback_ip is None and self.options.run_nonloopback: |
| 116 | raise SkipTest("This test requires a non-loopback ip address.") |
| 117 | |
| 118 | self.defaultport = rpc_port(0) |
| 119 | |
| 120 | if not self.options.run_nonloopback: |
| 121 | self._run_loopback_tests() |
| 122 | if self.options.run_ipv4: |
| 123 | self.run_invalid_bind_test(['127.0.0.1'], ['127.0.0.1:notaport', '127.0.0.1:-18443', '127.0.0.1:0', '127.0.0.1:65536']) |
| 124 | if self.options.run_ipv6: |
| 125 | self.run_invalid_bind_test(['[::1]'], ['[::1]:notaport', '[::1]:-18443', '[::1]:0', '[::1]:65536']) |
| 126 | self.run_invalid_allowip_test() |
| 127 | if not self.options.run_ipv4 and not self.options.run_ipv6: |
| 128 | if self.non_loopback_ip: |
| 129 | self._run_nonloopback_tests() |
| 130 | else: |
| 131 | self.log.info('Non-loopback IP address not found, skipping non-loopback tests') |
| 132 | |
| 133 | def _run_loopback_tests(self): |
| 134 | if self.options.run_ipv4: |
nothing calls this directly
no test coverage detected