MCPcopy Create free account
hub / github.com/ElementsProject/lightning / test_ml_decoder

Function test_ml_decoder

cln-rpc/src/codec.rs:139–166  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

137
138 #[test]
139 fn test_ml_decoder() {
140 struct Test(String, Option<String>, String);
141 let tests = vec![
142 Test("".to_string(), None, "".to_string()),
143 Test(
144 "{\"hello\":\"world\"}\n\nremainder".to_string(),
145 Some("{\"hello\":\"world\"}".to_string()),
146 "remainder".to_string(),
147 ),
148 Test(
149 "{\"hello\":\"world\"}\n\n{}\n\nremainder".to_string(),
150 Some("{\"hello\":\"world\"}".to_string()),
151 "{}\n\nremainder".to_string(),
152 ),
153 ];
154
155 for t in tests.iter() {
156 let mut buf = BytesMut::new();
157 buf.put_slice(t.0.as_bytes());
158
159 let mut codec = MultiLineCodec::default();
160 let mut remainder = BytesMut::new();
161 remainder.put_slice(t.2.as_bytes());
162
163 assert_eq!(codec.decode(&mut buf).unwrap(), t.1);
164 assert_eq!(buf, remainder);
165 }
166 }
167
168 #[test]
169 fn test_ml_encoder() {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected