| 220 | |
| 221 | #[test] |
| 222 | fn test_init_message_parsing() { |
| 223 | let value = json!({ |
| 224 | "jsonrpc": "2.0", |
| 225 | "method": "init", |
| 226 | "params": { |
| 227 | "options": { |
| 228 | "greeting": "World", |
| 229 | "number": [0] |
| 230 | }, |
| 231 | "configuration": { |
| 232 | "lightning-dir": "/home/user/.lightning/testnet", |
| 233 | "rpc-file": "lightning-rpc", |
| 234 | "startup": true, |
| 235 | "network": "testnet", |
| 236 | "feature_set": { |
| 237 | "init": "02aaa2", |
| 238 | "node": "8000000002aaa2", |
| 239 | "channel": "", |
| 240 | "invoice": "028200" |
| 241 | }, |
| 242 | "proxy": { |
| 243 | "type": "ipv4", |
| 244 | "address": "127.0.0.1", |
| 245 | "port": 9050 |
| 246 | }, |
| 247 | "torv3-enabled": true, |
| 248 | "always_use_proxy": false |
| 249 | } |
| 250 | }, |
| 251 | "id": "10", |
| 252 | }); |
| 253 | let req: JsonRpc<Notification, Request> = serde_json::from_value(value).unwrap(); |
| 254 | match req { |
| 255 | messages::JsonRpc::Request(_, messages::Request::Init(init)) => { |
| 256 | assert_eq!(init.options["greeting"], "World"); |
| 257 | assert_eq!( |
| 258 | init.configuration.lightning_dir, |
| 259 | String::from("/home/user/.lightning/testnet") |
| 260 | ); |
| 261 | } |
| 262 | _ => panic!("Couldn't parse init message"), |
| 263 | } |
| 264 | } |
| 265 | } |