Main test logic
(self)
| 116 | assert_equal(result, expected) |
| 117 | |
| 118 | def run_test(self): |
| 119 | """Main test logic""" |
| 120 | self.test_echojson_positional_equals() |
| 121 | |
| 122 | self.generate(self.nodes[0], BLOCKS) |
| 123 | |
| 124 | self.log.info("Compare responses from getblockchaininfo RPC and `bitcoin-cli getblockchaininfo`") |
| 125 | cli_response = self.nodes[0].cli.getblockchaininfo() |
| 126 | rpc_response = self.nodes[0].getblockchaininfo() |
| 127 | assert_equal(cli_response, rpc_response) |
| 128 | |
| 129 | self.log.info("Test named arguments") |
| 130 | assert_equal(self.nodes[0].cli.echo(0, 1, arg3=3, arg5=5), ['0', '1', None, '3', None, '5']) |
| 131 | assert_raises_rpc_error(-8, "Parameter arg1 specified twice both as positional and named argument", self.nodes[0].cli.echo, 0, 1, arg1=1) |
| 132 | assert_raises_rpc_error(-8, "Parameter arg1 specified twice both as positional and named argument", self.nodes[0].cli.echo, 0, None, 2, arg1=1) |
| 133 | |
| 134 | self.log.info("Test that later cli named arguments values silently overwrite earlier ones") |
| 135 | assert_equal(self.nodes[0].cli("-named", "echo", "arg0=0", "arg1=1", "arg2=2", "arg1=3").send_cli(), ['0', '3', '2']) |
| 136 | assert_raises_rpc_error(-8, "Parameter args specified multiple times", self.nodes[0].cli("-named", "echo", "args=[0,1,2,3]", "4", "5", "6", ).send_cli) |
| 137 | |
| 138 | user, password = get_auth_cookie(self.nodes[0].datadir_path, self.chain) |
| 139 | |
| 140 | self.log.info("Test -stdinrpcpass option") |
| 141 | assert_equal(BLOCKS, self.nodes[0].cli(f'-rpcuser={user}', '-stdinrpcpass', input=password).getblockcount()) |
| 142 | assert_raises_process_error(1, 'Incorrect rpcuser or rpcpassword were specified', self.nodes[0].cli(f'-rpcuser={user}', '-stdinrpcpass', input='foo').echo) |
| 143 | |
| 144 | self.log.info("Test -stdin and -stdinrpcpass") |
| 145 | assert_equal(['foo', 'bar'], self.nodes[0].cli(f'-rpcuser={user}', '-stdin', '-stdinrpcpass', input=f'{password}\nfoo\nbar').echo()) |
| 146 | assert_raises_process_error(1, 'Incorrect rpcuser or rpcpassword were specified', self.nodes[0].cli(f'-rpcuser={user}', '-stdin', '-stdinrpcpass', input='foo').echo) |
| 147 | |
| 148 | self.log.info("Test connecting to a non-existing server") |
| 149 | assert_raises_process_error(1, "Could not connect to the server", self.nodes[0].cli('-rpcport=1').echo) |
| 150 | |
| 151 | self.log.info("Test handling of invalid ports in rpcconnect") |
| 152 | assert_raises_process_error(1, "Invalid port provided in -rpcconnect: 127.0.0.1:notaport", self.nodes[0].cli("-rpcconnect=127.0.0.1:notaport").echo) |
| 153 | assert_raises_process_error(1, "Invalid port provided in -rpcconnect: 127.0.0.1:-1", self.nodes[0].cli("-rpcconnect=127.0.0.1:-1").echo) |
| 154 | assert_raises_process_error(1, "Invalid port provided in -rpcconnect: 127.0.0.1:0", self.nodes[0].cli("-rpcconnect=127.0.0.1:0").echo) |
| 155 | assert_raises_process_error(1, "Invalid port provided in -rpcconnect: 127.0.0.1:65536", self.nodes[0].cli("-rpcconnect=127.0.0.1:65536").echo) |
| 156 | |
| 157 | self.log.info("Checking for IPv6") |
| 158 | have_ipv6 = test_ipv6_local() |
| 159 | if not have_ipv6: |
| 160 | self.log.info("Skipping IPv6 tests") |
| 161 | |
| 162 | if have_ipv6: |
| 163 | assert_raises_process_error(1, "Invalid port provided in -rpcconnect: [::1]:notaport", self.nodes[0].cli("-rpcconnect=[::1]:notaport").echo) |
| 164 | assert_raises_process_error(1, "Invalid port provided in -rpcconnect: [::1]:-1", self.nodes[0].cli("-rpcconnect=[::1]:-1").echo) |
| 165 | assert_raises_process_error(1, "Invalid port provided in -rpcconnect: [::1]:0", self.nodes[0].cli("-rpcconnect=[::1]:0").echo) |
| 166 | assert_raises_process_error(1, "Invalid port provided in -rpcconnect: [::1]:65536", self.nodes[0].cli("-rpcconnect=[::1]:65536").echo) |
| 167 | |
| 168 | self.log.info("Test handling of invalid ports in rpcport") |
| 169 | assert_raises_process_error(1, "Invalid port provided in -rpcport: notaport", self.nodes[0].cli("-rpcport=notaport").echo) |
| 170 | assert_raises_process_error(1, "Invalid port provided in -rpcport: -1", self.nodes[0].cli("-rpcport=-1").echo) |
| 171 | assert_raises_process_error(1, "Invalid port provided in -rpcport: 0", self.nodes[0].cli("-rpcport=0").echo) |
| 172 | assert_raises_process_error(1, "Invalid port provided in -rpcport: 65536", self.nodes[0].cli("-rpcport=65536").echo) |
| 173 | |
| 174 | self.log.info("Test port usage preferences") |
| 175 | node_rpc_port = rpc_port(self.nodes[0].index) |
nothing calls this directly
no test coverage detected