cargo test -p lightning --verbose --color always --features no-std
echo -e "\n\nTesting c_bindings builds"
-RUSTFLAGS="$RUSTFLAGS --cfg=c_bindings" cargo test --verbose --color always
+# Note that because `$RUSTFLAGS` is not passed through to doctest builds we cannot selectively
+# disable doctests in `c_bindings` so we skip doctests entirely here.
+RUSTFLAGS="$RUSTFLAGS --cfg=c_bindings" cargo test --verbose --color always --lib --bins --tests
for DIR in lightning-invoice lightning-rapid-gossip-sync; do
# check if there is a conflict between no-std and the c_bindings cfg
done
# Note that because `$RUSTFLAGS` is not passed through to doctest builds we cannot selectively
-# disable tests in `c_bindings` so we skip doctests entirely here.
+# disable doctests in `c_bindings` so we skip doctests entirely here.
RUSTFLAGS="$RUSTFLAGS --cfg=c_bindings" cargo test -p lightning-background-processor --verbose --color always --features futures --no-default-features --lib --bins --tests
-RUSTFLAGS="$RUSTFLAGS --cfg=c_bindings" cargo test -p lightning --verbose --color always --no-default-features --features=no-std
+RUSTFLAGS="$RUSTFLAGS --cfg=c_bindings" cargo test -p lightning --verbose --color always --no-default-features --features=no-std --lib --bins --tests
echo -e "\n\nTesting other crate-specific builds"
# Note that outbound_commitment_test only runs in this mode because of hardcoded signature values
impl OnionMessageContents for Infallible {
fn tlv_type(&self) -> u64 { unreachable!(); }
+ #[cfg(c_bindings)]
+ fn msg_type(&self) -> String { unreachable!(); }
+ #[cfg(not(c_bindings))]
fn msg_type(&self) -> &'static str { unreachable!(); }
}
fn tlv_type(&self) -> u64 {
RELEASE_HELD_HTLC_TLV_TYPE
}
+ #[cfg(c_bindings)]
+ fn msg_type(&self) -> String {
+ "Release Held HTLC".to_string()
+ }
+ #[cfg(not(c_bindings))]
fn msg_type(&self) -> &'static str {
"Release Held HTLC"
}
Self::ReleaseHeldHtlc(msg) => msg.tlv_type(),
}
}
+ #[cfg(c_bindings)]
+ fn msg_type(&self) -> String {
+ match &self {
+ Self::HeldHtlcAvailable(_) => "Held HTLC Available".to_string(),
+ Self::ReleaseHeldHtlc(msg) => msg.msg_type(),
+ }
+ }
+ #[cfg(not(c_bindings))]
fn msg_type(&self) -> &'static str {
match &self {
Self::HeldHtlcAvailable(_) => "Held HTLC Available",
TestCustomMessage::Pong => CUSTOM_PONG_MESSAGE_TYPE,
}
}
+ #[cfg(c_bindings)]
+ fn msg_type(&self) -> String {
+ "Custom Message".to_string()
+ }
+ #[cfg(not(c_bindings))]
fn msg_type(&self) -> &'static str {
"Custom Message"
}
// Onion message contents must have a TLV >= 64.
63
}
+ #[cfg(c_bindings)]
+ fn msg_type(&self) -> String {
+ "Invalid Message".to_string()
+ }
+ #[cfg(not(c_bindings))]
fn msg_type(&self) -> &'static str {
"Invalid Message"
}
_ => Err(Bolt12ParseError::Decode(DecodeError::InvalidValue)),
}
}
+
+ fn get_msg_type(&self) -> &'static str {
+ match &self {
+ OffersMessage::InvoiceRequest(_) => "Invoice Request",
+ OffersMessage::Invoice(_) => "Invoice",
+ #[cfg(async_payments)]
+ OffersMessage::StaticInvoice(_) => "Static Invoice",
+ OffersMessage::InvoiceError(_) => "Invoice Error",
+ }
+ }
}
impl fmt::Debug for OffersMessage {
OffersMessage::InvoiceError(_) => INVOICE_ERROR_TLV_TYPE,
}
}
+ #[cfg(c_bindings)]
+ fn msg_type(&self) -> String {
+ self.get_msg_type().to_string()
+ }
+ #[cfg(not(c_bindings))]
fn msg_type(&self) -> &'static str {
- match &self {
- OffersMessage::InvoiceRequest(_) => "Invoice Request",
- OffersMessage::Invoice(_) => "Invoice",
- #[cfg(async_payments)]
- OffersMessage::StaticInvoice(_) => "Static Invoice",
- OffersMessage::InvoiceError(_) => "Invoice Error",
- }
+ self.get_msg_type()
}
}
&ParsedOnionMessageContents::Custom(ref msg) => msg.tlv_type(),
}
}
+ #[cfg(c_bindings)]
+ fn msg_type(&self) -> String {
+ match self {
+ ParsedOnionMessageContents::Offers(ref msg) => msg.msg_type(),
+ #[cfg(async_payments)]
+ ParsedOnionMessageContents::AsyncPayments(ref msg) => msg.msg_type(),
+ ParsedOnionMessageContents::Custom(ref msg) => msg.msg_type(),
+ }
+ }
+ #[cfg(not(c_bindings))]
fn msg_type(&self) -> &'static str {
match self {
ParsedOnionMessageContents::Offers(ref msg) => msg.msg_type(),
/// Returns the TLV type identifying the message contents. MUST be >= 64.
fn tlv_type(&self) -> u64;
+ #[cfg(c_bindings)]
+ /// Returns the message type
+ fn msg_type(&self) -> String;
+
+ #[cfg(not(c_bindings))]
/// Returns the message type
fn msg_type(&self) -> &'static str;
}