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

Function test_forward_event

cln-grpc/src/test.rs:469–520  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

467
468#[test]
469fn test_forward_event() {
470 // Settled forward with all fields
471 let j: serde_json::Value = json!({
472 "created_index": 1,
473 "updated_index": 2,
474 "status": "settled",
475 "in_channel": "103x1x0",
476 "in_htlc_id": 0,
477 "in_msat": "100001001msat",
478 "out_channel": "103x2x1",
479 "out_htlc_id": 0,
480 "out_msat": "100000000msat",
481 "fee_msat": "1001msat",
482 "payment_hash": "d17a42c4f7f49648064a0ce7ce848bd92c4c50f24d35fe5c3d1f3a7a9bf474b2",
483 "received_time": 1648222556.498,
484 "resolved_time": 1648222557.123,
485 "style": "tlv"
486 });
487 let u: cln_rpc::notifications::ForwardEventNotification = serde_json::from_value(j).unwrap();
488 assert_eq!(
489 u.status,
490 cln_rpc::notifications::ForwardEventStatus::SETTLED
491 );
492 assert_eq!(
493 u.style,
494 Some(cln_rpc::notifications::ForwardEventStyle::TLV)
495 );
496 assert!(u.out_channel.is_some());
497 let _pb: crate::pb::ForwardEventNotification = u.into();
498
499 // Failed forward with failure info
500 let j_failed: serde_json::Value = json!({
501 "created_index": 2,
502 "status": "local_failed",
503 "in_channel": "103x1x0",
504 "in_htlc_id": 1,
505 "in_msat": "50000000msat",
506 "payment_hash": "d17a42c4f7f49648064a0ce7ce848bd92c4c50f24d35fe5c3d1f3a7a9bf474b2",
507 "received_time": 1648222600.0,
508 "failcode": 16399,
509 "failreason": "WIRE_TEMPORARY_CHANNEL_FAILURE"
510 });
511 let u_failed: cln_rpc::notifications::ForwardEventNotification =
512 serde_json::from_value(j_failed).unwrap();
513 assert_eq!(
514 u_failed.status,
515 cln_rpc::notifications::ForwardEventStatus::LOCAL_FAILED
516 );
517 assert_eq!(u_failed.failcode, Some(16399));
518 assert!(u_failed.out_channel.is_none());
519 let _pb_failed: crate::pb::ForwardEventNotification = u_failed.into();
520}
521
522#[test]
523fn test_sendpay_failure() {

Callers

nothing calls this directly

Calls 1

unwrapMethod · 0.45

Tested by

no test coverage detected