Malformed gRPC request values must be rejected, not panic the server.
(node_factory)
| 179 | |
| 180 | |
| 181 | def test_grpc_request_validation(node_factory): |
| 182 | """Malformed gRPC request values must be rejected, not panic the server.""" |
| 183 | l1 = node_factory.get_node() |
| 184 | wait_for_grpc_start(l1) |
| 185 | stub = l1.grpc |
| 186 | |
| 187 | valid_pubkey = bytes.fromhex(l1.info["id"]) |
| 188 | valid_hash = b"\x00" * 32 |
| 189 | |
| 190 | cases = [ |
| 191 | ( |
| 192 | "pubkey", |
| 193 | lambda: stub.ListPeers(clnpb.ListpeersRequest(id=b"\x00" * 33)), |
| 194 | "id", |
| 195 | ), |
| 196 | ( |
| 197 | "u16_overflow", |
| 198 | lambda: stub.ConnectPeer(clnpb.ConnectRequest(id="x", port=65536)), |
| 199 | "port", |
| 200 | ), |
| 201 | ("enum", lambda: stub.ListPeers(clnpb.ListpeersRequest(level=9999)), "level"), |
| 202 | ( |
| 203 | "hash", |
| 204 | lambda: stub.ListPays(clnpb.ListpaysRequest(payment_hash=b"\x00" * 31)), |
| 205 | "payment_hash", |
| 206 | ), |
| 207 | ( |
| 208 | "secret", |
| 209 | lambda: stub.SendPay( |
| 210 | clnpb.SendpayRequest( |
| 211 | payment_hash=valid_hash, payment_secret=b"\x00" * 31 |
| 212 | ) |
| 213 | ), |
| 214 | "payment_secret", |
| 215 | ), |
| 216 | ( |
| 217 | "short_channel_id", |
| 218 | lambda: stub.ListChannels( |
| 219 | clnpb.ListchannelsRequest(short_channel_id="not-a-scid") |
| 220 | ), |
| 221 | "short_channel_id", |
| 222 | ), |
| 223 | ( |
| 224 | "short_channel_id_dir", |
| 225 | lambda: stub.AskReneBiasChannel( |
| 226 | clnpb.AskrenebiaschannelRequest( |
| 227 | layer="x", bias=1, short_channel_id_dir="not-a-scid" |
| 228 | ) |
| 229 | ), |
| 230 | "short_channel_id_dir", |
| 231 | ), |
| 232 | ( |
| 233 | "missing_required", |
| 234 | lambda: stub.Withdraw(clnpb.WithdrawRequest(destination="bcrt1qtest")), |
| 235 | "satoshi", |
| 236 | ), |
| 237 | ( |
| 238 | "array_pubkey", |
nothing calls this directly
no test coverage detected