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

Function test_reply_channel_range

gossipd/test/run-extended-info.c:232–304  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

230}
231
232static u8 *test_reply_channel_range(const char *test_vector, const jsmntok_t *obj)
233{
234 struct bitcoin_blkid chain_hash;
235 u32 firstBlockNum, numberOfBlocks, complete;
236 const jsmntok_t *opt, *t;
237 size_t i;
238 u8 *msg;
239 u8 *encoded_scids;
240
241 u8 *ctx = tal(NULL, u8);
242 struct tlv_reply_channel_range_tlvs *tlvs
243 = tlv_reply_channel_range_tlvs_new(ctx);
244
245 get_chainhash(test_vector, obj, &chain_hash);
246 assert(json_to_number(test_vector, json_get_member(test_vector, obj, "firstBlockNum"), &firstBlockNum));
247 assert(json_to_number(test_vector, json_get_member(test_vector, obj, "numberOfBlocks"), &numberOfBlocks));
248 assert(json_to_number(test_vector, json_get_member(test_vector, obj, "complete"), &complete));
249
250 encoded_scids = get_scid_array(ctx, test_vector, obj);
251
252 opt = json_get_member(test_vector, obj, "timestamps");
253 if (opt) {
254 const jsmntok_t *encodingtok, *tstok;
255 tlvs->timestamps_tlv
256 = tal(tlvs, struct tlv_reply_channel_range_tlvs_timestamps_tlv);
257
258 tlvs->timestamps_tlv->encoded_timestamps
259 = encoding_start(tlvs->timestamps_tlv, false);
260 encodingtok = json_get_member(test_vector, opt, "encoding");
261 tstok = json_get_member(test_vector, opt, "timestamps");
262 json_for_each_arr(i, t, tstok) {
263 struct channel_update_timestamps ts;
264 assert(json_to_number(test_vector,
265 json_get_member(test_vector, t,
266 "timestamp1"),
267 &ts.timestamp_node_id_1));
268 assert(json_to_number(test_vector,
269 json_get_member(test_vector, t,
270 "timestamp2"),
271 &ts.timestamp_node_id_2));
272 encoding_add_timestamps(&tlvs->timestamps_tlv->encoded_timestamps, &ts);
273 }
274 assert(json_tok_streq(test_vector, encodingtok, "UNCOMPRESSED"));
275 tlvs->timestamps_tlv->encoding_type = ARR_UNCOMPRESSED;
276 }
277
278 opt = json_get_member(test_vector, obj, "checksums");
279 if (opt) {
280 const jsmntok_t *cstok;
281 tlvs->checksums_tlv
282 = tal_arr(tlvs, struct channel_update_checksums, 0);
283
284 cstok = json_get_member(test_vector, opt, "checksums");
285 json_for_each_arr(i, t, cstok) {
286 struct channel_update_checksums cs;
287 assert(json_to_number(test_vector,
288 json_get_member(test_vector, t,
289 "checksum1"),

Callers 1

mainFunction · 0.85

Calls 8

get_chainhashFunction · 0.85
get_scid_arrayFunction · 0.85
encoding_startFunction · 0.85
encoding_add_timestampsFunction · 0.85
tal_freeFunction · 0.85
json_to_numberFunction · 0.50
json_get_memberFunction · 0.50
json_tok_streqFunction · 0.50

Tested by

no test coverage detected