From 778c752a0b0e25ac15a78bcf3b6b2651224b7f96 Mon Sep 17 00:00:00 2001 From: benthecarman Date: Sat, 15 Apr 2023 15:38:53 -0500 Subject: [PATCH 1/2] Fix compiling lightning-invoice for no-std + serde --- lightning-invoice/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lightning-invoice/src/lib.rs b/lightning-invoice/src/lib.rs index e9565f4ce30..8426db37c64 100644 --- a/lightning-invoice/src/lib.rs +++ b/lightning-invoice/src/lib.rs @@ -1648,7 +1648,7 @@ impl<'de> Deserialize<'de> for Invoice { fn deserialize(deserializer: D) -> Result where D: Deserializer<'de> { let bolt11 = String::deserialize(deserializer)? .parse::() - .map_err(|e| D::Error::custom(format!("{:?}", e)))?; + .map_err(|e| D::Error::custom(alloc::format!("{:?}", e)))?; Ok(bolt11) } From 36f610c4cfd7186799a9b522d93e8cb0dc105511 Mon Sep 17 00:00:00 2001 From: benthecarman Date: Sun, 16 Apr 2023 13:17:22 -0500 Subject: [PATCH 2/2] Add CI test for compile no-std serde lightning-invoice --- ci/ci-tests.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ci/ci-tests.sh b/ci/ci-tests.sh index 01ef631f783..7dad1436e98 100755 --- a/ci/ci-tests.sh +++ b/ci/ci-tests.sh @@ -42,6 +42,11 @@ for DIR in lightning lightning-invoice lightning-rapid-gossip-sync; do RUSTFLAGS="--cfg=c_bindings" cargo test --verbose --color always --no-default-features --features=no-std popd done +# This one only works for lightning-invoice +pushd lightning-invoice +# check that compile with no-std and serde works in lightning-invoice +cargo test --verbose --color always --no-default-features --features no-std --features serde +popd echo -e "\n\nTesting no-std build on a downstream no-std crate" # check no-std compatibility across dependencies