| 36 | assert_equal(result.returncode, 0 if error is None else 1) |
| 37 | |
| 38 | def run_test(self): |
| 39 | node = self.nodes[0] |
| 40 | if node.ipc_tmp_dir: |
| 41 | self.log.info("Skipping a few checks because temporary directory path is too long") |
| 42 | |
| 43 | http_auth_error = "error: Authorization failed: Incorrect rpcuser or rpcpassword were specified." |
| 44 | http_connect_error = f"error: Error while attempting to communicate with server 127.0.0.1:{rpc_port(node.index)} (Could not connect to the server)\n\nMake sure the bitcoind server is running and that you are connecting to the correct RPC port.\nUse \"bitcoin-cli -help\" for more info.\n" |
| 45 | ipc_connect_error = "error: Connection refused\n\nProbably bitcoin-node is not running or not listening on a unix socket. Can be started with:\n\n bitcoin-node -chain=regtest -ipcbind=unix\n" |
| 46 | ipc_http_conflict = "error: -rpcconnect and -ipcconnect options cannot both be enabled\n" |
| 47 | |
| 48 | for started in (True, False): |
| 49 | auto_error = None if started else http_connect_error |
| 50 | http_error = http_auth_error if started else http_connect_error |
| 51 | ipc_error = None if started else ipc_connect_error |
| 52 | |
| 53 | if not node.ipc_tmp_dir: |
| 54 | self.test_cli([], auto_error) |
| 55 | self.test_cli(["-rpcconnect=127.0.0.1"], http_error) |
| 56 | self.test_cli(["-ipcconnect=auto"], auto_error) |
| 57 | self.test_cli(["-ipcconnect=auto", "-rpcconnect=127.0.0.1"], http_error) |
| 58 | self.test_cli(["-ipcconnect=unix"], ipc_error) |
| 59 | |
| 60 | self.test_cli([f"-ipcconnect=unix:{node.ipc_socket_path}"], ipc_error) |
| 61 | self.test_cli(["-noipcconnect"], http_error) |
| 62 | self.test_cli(["-ipcconnect=unix", "-rpcconnect=127.0.0.1"], ipc_http_conflict) |
| 63 | |
| 64 | self.stop_node(0) |
| 65 | |
| 66 | |
| 67 | if __name__ == '__main__': |