File tree Expand file tree Collapse file tree 6 files changed +62
-10
lines changed Expand file tree Collapse file tree 6 files changed +62
-10
lines changed Original file line number Diff line number Diff line change @@ -87,17 +87,19 @@ cargo test -p lightning --verbose --color always --no-default-features --feature
87
87
cargo test -p lightning --verbose --color always --features no-std
88
88
89
89
echo -e " \n\nTesting c_bindings builds"
90
- RUSTFLAGS=" $RUSTFLAGS --cfg=c_bindings" cargo test --verbose --color always
90
+ # Note that because `$RUSTFLAGS` is not passed through to doctest builds we cannot selectively
91
+ # disable doctests in `c_bindings` so we skip doctests entirely here.
92
+ RUSTFLAGS=" $RUSTFLAGS --cfg=c_bindings" cargo test --verbose --color always --lib --bins --tests
91
93
92
94
for DIR in lightning-invoice lightning-rapid-gossip-sync; do
93
95
# check if there is a conflict between no-std and the c_bindings cfg
94
96
RUSTFLAGS=" $RUSTFLAGS --cfg=c_bindings" cargo test -p $DIR --verbose --color always --no-default-features
95
97
done
96
98
97
99
# Note that because `$RUSTFLAGS` is not passed through to doctest builds we cannot selectively
98
- # disable tests in `c_bindings` so we skip doctests entirely here.
100
+ # disable doctests in `c_bindings` so we skip doctests entirely here.
99
101
RUSTFLAGS=" $RUSTFLAGS --cfg=c_bindings" cargo test -p lightning-background-processor --verbose --color always --features futures --no-default-features --lib --bins --tests
100
- RUSTFLAGS=" $RUSTFLAGS --cfg=c_bindings" cargo test -p lightning --verbose --color always --no-default-features --features=no-std
102
+ RUSTFLAGS=" $RUSTFLAGS --cfg=c_bindings" cargo test -p lightning --verbose --color always --no-default-features --features=no-std --lib --bins --tests
101
103
102
104
echo -e " \n\nTesting other crate-specific builds"
103
105
# Note that outbound_commitment_test only runs in this mode because of hardcoded signature values
Original file line number Diff line number Diff line change @@ -170,6 +170,9 @@ impl CustomOnionMessageHandler for IgnoringMessageHandler {
170
170
171
171
impl OnionMessageContents for Infallible {
172
172
fn tlv_type ( & self ) -> u64 { unreachable ! ( ) ; }
173
+ #[ cfg( c_bindings) ]
174
+ fn msg_type ( & self ) -> String { unreachable ! ( ) ; }
175
+ #[ cfg( not( c_bindings) ) ]
173
176
fn msg_type ( & self ) -> & ' static str { unreachable ! ( ) ; }
174
177
}
175
178
Original file line number Diff line number Diff line change @@ -77,6 +77,11 @@ impl OnionMessageContents for ReleaseHeldHtlc {
77
77
fn tlv_type ( & self ) -> u64 {
78
78
RELEASE_HELD_HTLC_TLV_TYPE
79
79
}
80
+ #[ cfg( c_bindings) ]
81
+ fn msg_type ( & self ) -> String {
82
+ "Release Held HTLC" . to_string ( )
83
+ }
84
+ #[ cfg( not( c_bindings) ) ]
80
85
fn msg_type ( & self ) -> & ' static str {
81
86
"Release Held HTLC"
82
87
}
@@ -107,6 +112,14 @@ impl OnionMessageContents for AsyncPaymentsMessage {
107
112
Self :: ReleaseHeldHtlc ( msg) => msg. tlv_type ( ) ,
108
113
}
109
114
}
115
+ #[ cfg( c_bindings) ]
116
+ fn msg_type ( & self ) -> String {
117
+ match & self {
118
+ Self :: HeldHtlcAvailable ( _) => "Held HTLC Available" . to_string ( ) ,
119
+ Self :: ReleaseHeldHtlc ( msg) => msg. msg_type ( ) ,
120
+ }
121
+ }
122
+ #[ cfg( not( c_bindings) ) ]
110
123
fn msg_type ( & self ) -> & ' static str {
111
124
match & self {
112
125
Self :: HeldHtlcAvailable ( _) => "Held HTLC Available" ,
Original file line number Diff line number Diff line change @@ -108,6 +108,11 @@ impl OnionMessageContents for TestCustomMessage {
108
108
TestCustomMessage :: Pong => CUSTOM_PONG_MESSAGE_TYPE ,
109
109
}
110
110
}
111
+ #[ cfg( c_bindings) ]
112
+ fn msg_type ( & self ) -> String {
113
+ "Custom Message" . to_string ( )
114
+ }
115
+ #[ cfg( not( c_bindings) ) ]
111
116
fn msg_type ( & self ) -> & ' static str {
112
117
"Custom Message"
113
118
}
@@ -656,6 +661,11 @@ fn invalid_custom_message_type() {
656
661
// Onion message contents must have a TLV >= 64.
657
662
63
658
663
}
664
+ #[ cfg( c_bindings) ]
665
+ fn msg_type ( & self ) -> String {
666
+ "Invalid Message" . to_string ( )
667
+ }
668
+ #[ cfg( not( c_bindings) ) ]
659
669
fn msg_type ( & self ) -> & ' static str {
660
670
"Invalid Message"
661
671
}
Original file line number Diff line number Diff line change @@ -99,6 +99,16 @@ impl OffersMessage {
99
99
_ => Err ( Bolt12ParseError :: Decode ( DecodeError :: InvalidValue ) ) ,
100
100
}
101
101
}
102
+
103
+ fn get_msg_type ( & self ) -> & ' static str {
104
+ match & self {
105
+ OffersMessage :: InvoiceRequest ( _) => "Invoice Request" ,
106
+ OffersMessage :: Invoice ( _) => "Invoice" ,
107
+ #[ cfg( async_payments) ]
108
+ OffersMessage :: StaticInvoice ( _) => "Static Invoice" ,
109
+ OffersMessage :: InvoiceError ( _) => "Invoice Error" ,
110
+ }
111
+ }
102
112
}
103
113
104
114
impl fmt:: Debug for OffersMessage {
@@ -131,14 +141,13 @@ impl OnionMessageContents for OffersMessage {
131
141
OffersMessage :: InvoiceError ( _) => INVOICE_ERROR_TLV_TYPE ,
132
142
}
133
143
}
144
+ #[ cfg( c_bindings) ]
145
+ fn msg_type ( & self ) -> String {
146
+ self . get_msg_type ( ) . to_string ( )
147
+ }
148
+ #[ cfg( not( c_bindings) ) ]
134
149
fn msg_type ( & self ) -> & ' static str {
135
- match & self {
136
- OffersMessage :: InvoiceRequest ( _) => "Invoice Request" ,
137
- OffersMessage :: Invoice ( _) => "Invoice" ,
138
- #[ cfg( async_payments) ]
139
- OffersMessage :: StaticInvoice ( _) => "Static Invoice" ,
140
- OffersMessage :: InvoiceError ( _) => "Invoice Error" ,
141
- }
150
+ self . get_msg_type ( )
142
151
}
143
152
}
144
153
Original file line number Diff line number Diff line change @@ -148,6 +148,16 @@ impl<T: OnionMessageContents> OnionMessageContents for ParsedOnionMessageContent
148
148
& ParsedOnionMessageContents :: Custom ( ref msg) => msg. tlv_type ( ) ,
149
149
}
150
150
}
151
+ #[ cfg( c_bindings) ]
152
+ fn msg_type ( & self ) -> String {
153
+ match self {
154
+ ParsedOnionMessageContents :: Offers ( ref msg) => msg. msg_type ( ) ,
155
+ #[ cfg( async_payments) ]
156
+ ParsedOnionMessageContents :: AsyncPayments ( ref msg) => msg. msg_type ( ) ,
157
+ ParsedOnionMessageContents :: Custom ( ref msg) => msg. msg_type ( ) ,
158
+ }
159
+ }
160
+ #[ cfg( not( c_bindings) ) ]
151
161
fn msg_type ( & self ) -> & ' static str {
152
162
match self {
153
163
ParsedOnionMessageContents :: Offers ( ref msg) => msg. msg_type ( ) ,
@@ -174,6 +184,11 @@ pub trait OnionMessageContents: Writeable + core::fmt::Debug {
174
184
/// Returns the TLV type identifying the message contents. MUST be >= 64.
175
185
fn tlv_type ( & self ) -> u64 ;
176
186
187
+ #[ cfg( c_bindings) ]
188
+ /// Returns the message type
189
+ fn msg_type ( & self ) -> String ;
190
+
191
+ #[ cfg( not( c_bindings) ) ]
177
192
/// Returns the message type
178
193
fn msg_type ( & self ) -> & ' static str ;
179
194
}
You can’t perform that action at this time.
0 commit comments