Skip to content

Commit 75a361c

Browse files
committed
f - parsing test for going over MAX_VALUE_MSAT
1 parent 877a2f4 commit 75a361c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lightning/src/offers/offer.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -876,6 +876,18 @@ mod tests {
876876
Ok(_) => panic!("expected error"),
877877
Err(e) => assert_eq!(e, ParseError::InvalidSemantics(SemanticError::MissingAmount)),
878878
}
879+
880+
let mut tlv_stream = offer.as_tlv_stream();
881+
tlv_stream.amount = Some(MAX_VALUE_MSAT + 1);
882+
tlv_stream.currency = None;
883+
884+
let mut encoded_offer = Vec::new();
885+
tlv_stream.write(&mut encoded_offer).unwrap();
886+
887+
match Offer::try_from(encoded_offer) {
888+
Ok(_) => panic!("expected error"),
889+
Err(e) => assert_eq!(e, ParseError::InvalidSemantics(SemanticError::InvalidAmount)),
890+
}
879891
}
880892

881893
#[test]

0 commit comments

Comments
 (0)