Merge pull request #1028 from lightning-signer/2021-08-no-std
authorMatt Corallo <649246+TheBlueMatt@users.noreply.github.com>
Tue, 3 Aug 2021 17:06:59 +0000 (17:06 +0000)
committerGitHub <noreply@github.com>
Tue, 3 Aug 2021 17:06:59 +0000 (17:06 +0000)
Actual no_std support

.github/workflows/build.yml
lightning-block-sync/src/http.rs
lightning-persister/src/util.rs
lightning/src/util/ser_macros.rs

index f18f3f64d78eda3c96ec61b56f42ea506dc463d2..34337769a26677969bc8a3246c4cbb36f35648f7 100644 (file)
@@ -26,10 +26,18 @@ jobs:
             platform: macos-latest
             build-net-tokio: true
             build-no-std: true
+          - toolchain: beta
+            platform: macos-latest
+            build-net-tokio: true
+            build-no-std: true
           - toolchain: stable
             platform: windows-latest
             build-net-tokio: true
             build-no-std: true
+          - toolchain: beta
+            platform: windows-latest
+            build-net-tokio: true
+            build-no-std: true
           - toolchain: beta
             build-net-tokio: true
             build-no-std: true
@@ -262,4 +270,4 @@ jobs:
           rustup component add clippy
       - name: Run default clippy linting
         run: |
-          cargo clippy -- -Aclippy::erasing_op -Aclippy::never_loop -Aclippy::if_same_then_else
+          cargo clippy -- -Aclippy::erasing_op -Aclippy::never_loop -Aclippy::if_same_then_else -Dclippy::try_err
index 89054a23ffb5a936ad7814bcdcde8a248f20f18a..0721babfde3d1b626051ba1ccccb7240d1f5a5a7 100644 (file)
@@ -636,7 +636,10 @@ pub(crate) mod client_tests {
        #[test]
        fn connect_to_unresolvable_host() {
                match HttpClient::connect(("example.invalid", 80)) {
-                       Err(e) => assert_eq!(e.kind(), std::io::ErrorKind::Other),
+                       Err(e) => {
+                               assert!(e.to_string().contains("failed to lookup address information") ||
+                                       e.to_string().contains("No such host"), "{:?}", e);
+                       },
                        Ok(_) => panic!("Expected error"),
                }
        }
index 1825980ad891fcb257cdaf956150a526ac5e326d..73b28985bfff6ae8b484e5f0d76c62e4091b3541 100644 (file)
@@ -135,7 +135,7 @@ mod tests {
                // Create the channel data file and make it a directory.
                fs::create_dir_all(get_full_filepath(path.clone(), filename.to_string())).unwrap();
                match write_to_file(path.clone(), filename.to_string(), &test_writeable) {
-                       Err(e) => assert_eq!(e.kind(), io::ErrorKind::Other),
+                       Err(e) => assert_eq!(e.raw_os_error(), Some(libc::EISDIR)),
                        _ => panic!("Unexpected Ok(())")
                }
                fs::remove_dir_all(path).unwrap();
@@ -178,7 +178,7 @@ mod tests {
                match write_to_file(path, filename, &test_writeable) {
                        Err(e) => {
                                #[cfg(not(target_os = "windows"))]
-                               assert_eq!(e.kind(), io::ErrorKind::Other);
+                               assert_eq!(e.raw_os_error(), Some(libc::EISDIR));
                                #[cfg(target_os = "windows")]
                                assert_eq!(e.kind(), io::ErrorKind::PermissionDenied);
                        }
index cffa0838ddceee3c1cc08be7c4d147e889760b5a..5d5171adbb4401c1dd1fb5faf3b1f8afab919db2 100644 (file)
@@ -93,7 +93,7 @@ macro_rules! check_tlv_order {
                #[allow(unused_comparisons)] // Note that $type may be 0 making the second comparison always true
                let invalid_order = ($last_seen_type.is_none() || $last_seen_type.unwrap() < $type) && $typ.0 > $type;
                if invalid_order {
-                       Err(DecodeError::InvalidValue)?
+                       return Err(DecodeError::InvalidValue);
                }
        }};
        ($last_seen_type: expr, $typ: expr, $type: expr, option) => {{
@@ -109,7 +109,7 @@ macro_rules! check_missing_tlv {
                #[allow(unused_comparisons)] // Note that $type may be 0 making the second comparison always true
                let missing_req_type = $last_seen_type.is_none() || $last_seen_type.unwrap() < $type;
                if missing_req_type {
-                       Err(DecodeError::InvalidValue)?
+                       return Err(DecodeError::InvalidValue);
                }
        }};
        ($last_seen_type: expr, $type: expr, vec_type) => {{
@@ -149,12 +149,12 @@ macro_rules! decode_tlv_stream {
                                match ser::Readable::read(&mut tracking_reader) {
                                        Err(DecodeError::ShortRead) => {
                                                if !tracking_reader.have_read {
-                                                       break 'tlv_read
+                                                       break 'tlv_read;
                                                } else {
-                                                       Err(DecodeError::ShortRead)?
+                                                       return Err(DecodeError::ShortRead);
                                                }
                                        },
-                                       Err(e) => Err(e)?,
+                                       Err(e) => return Err(e),
                                        Ok(t) => t,
                                }
                        };
@@ -162,7 +162,7 @@ macro_rules! decode_tlv_stream {
                        // Types must be unique and monotonically increasing:
                        match last_seen_type {
                                Some(t) if typ.0 <= t => {
-                                       Err(DecodeError::InvalidValue)?
+                                       return Err(DecodeError::InvalidValue);
                                },
                                _ => {},
                        }
@@ -180,11 +180,11 @@ macro_rules! decode_tlv_stream {
                                        decode_tlv!(s, $field, $fieldty);
                                        if s.bytes_remain() {
                                                s.eat_remaining()?; // Return ShortRead if there's actually not enough bytes
-                                               Err(DecodeError::InvalidValue)?
+                                               return Err(DecodeError::InvalidValue);
                                        }
                                },)*
                                x if x % 2 == 0 => {
-                                       Err(DecodeError::UnknownRequiredFeature)?
+                                       return Err(DecodeError::UnknownRequiredFeature);
                                },
                                _ => {},
                        }
@@ -490,7 +490,7 @@ macro_rules! impl_writeable_tlv_based_enum {
                                                Ok($st::$tuple_variant_name(Readable::read(reader)?))
                                        }),*
                                        _ => {
-                                               Err(DecodeError::UnknownRequiredFeature)?
+                                               Err(DecodeError::UnknownRequiredFeature)
                                        },
                                }
                        }