@@ -163,7 +163,10 @@ impl OfferBuilder {
163
163
///
164
164
/// Successive calls to this method will override the previous setting.
165
165
pub fn supported_quantity ( mut self , quantity : Quantity ) -> Self {
166
- self . offer . supported_quantity = quantity;
166
+ self . offer . supported_quantity = match quantity {
167
+ Quantity :: Max ( n) if n. get ( ) == 1 => Quantity :: One ,
168
+ _ => quantity,
169
+ } ;
167
170
self
168
171
}
169
172
@@ -658,6 +661,7 @@ mod tests {
658
661
659
662
#[ test]
660
663
fn builds_offer_with_supported_quantity ( ) {
664
+ let one = NonZeroU64 :: new ( 1 ) . unwrap ( ) ;
661
665
let ten = NonZeroU64 :: new ( 10 ) . unwrap ( ) ;
662
666
663
667
let offer = OfferBuilder :: new ( "foo" . into ( ) , pubkey ( 42 ) )
@@ -692,5 +696,14 @@ mod tests {
692
696
let tlv_stream = offer. as_tlv_stream ( ) ;
693
697
assert_eq ! ( offer. supported_quantity( ) , Quantity :: One ) ;
694
698
assert_eq ! ( tlv_stream. quantity_max, None ) ;
699
+
700
+ let offer = OfferBuilder :: new ( "foo" . into ( ) , pubkey ( 42 ) )
701
+ . supported_quantity ( Quantity :: Max ( one) )
702
+ . build ( )
703
+ . unwrap ( ) ;
704
+ let tlv_stream = offer. as_tlv_stream ( ) ;
705
+ assert_eq ! ( offer. supported_quantity( ) , Quantity :: One ) ;
706
+ assert_eq ! ( tlv_stream. quantity_max, None ) ;
707
+
695
708
}
696
709
}
0 commit comments