Relicense as dual Apache-2.0 + MIT
[rust-lightning] / fuzz / src / msg_targets / utils.rs
index 2a7731ccd136d2185414b4b73f7510a7bebe8397..82fa739fbcfbd4febfb33af89b6bbcb31717d559 100644 (file)
@@ -1,3 +1,12 @@
+// This file is Copyright its original authors, visible in version control
+// history.
+//
+// This file is licensed under the Apache License, Version 2.0 <LICENSE-APACHE
+// or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
+// You may not use this file except in accordance with one or both of these
+// licenses.
+
 #![macro_use]
 
 use lightning::util::ser::Writer;
@@ -28,7 +37,7 @@ macro_rules! test_msg {
                {
                        use lightning::util::ser::{Writeable, Readable};
                        let mut r = ::std::io::Cursor::new($data);
-                       if let Ok(msg) = <$MsgType as Readable<::std::io::Cursor<&[u8]>>>::read(&mut r) {
+                       if let Ok(msg) = <$MsgType as Readable>::read(&mut r) {
                                let p = r.position() as usize;
                                let mut w = VecWriter(Vec::new());
                                msg.write(&mut w).unwrap();
@@ -48,11 +57,11 @@ macro_rules! test_msg_simple {
                {
                        use lightning::util::ser::{Writeable, Readable};
                        let mut r = ::std::io::Cursor::new($data);
-                       if let Ok(msg) = <$MsgType as Readable<::std::io::Cursor<&[u8]>>>::read(&mut r) {
+                       if let Ok(msg) = <$MsgType as Readable>::read(&mut r) {
                                let mut w = VecWriter(Vec::new());
                                msg.write(&mut w).unwrap();
 
-                               let msg = <$MsgType as Readable<::std::io::Cursor<&[u8]>>>::read(&mut ::std::io::Cursor::new(&w.0)).unwrap();
+                               let msg = <$MsgType as Readable>::read(&mut ::std::io::Cursor::new(&w.0)).unwrap();
                                let mut w_two = VecWriter(Vec::new());
                                msg.write(&mut w_two).unwrap();
                                assert_eq!(&w.0[..], &w_two.0[..]);
@@ -69,7 +78,7 @@ macro_rules! test_msg_exact {
                {
                        use lightning::util::ser::{Writeable, Readable};
                        let mut r = ::std::io::Cursor::new($data);
-                       if let Ok(msg) = <$MsgType as Readable<::std::io::Cursor<&[u8]>>>::read(&mut r) {
+                       if let Ok(msg) = <$MsgType as Readable>::read(&mut r) {
                                let mut w = VecWriter(Vec::new());
                                msg.write(&mut w).unwrap();
                                assert_eq!(&r.into_inner()[..], &w.0[..]);
@@ -78,15 +87,15 @@ macro_rules! test_msg_exact {
        }
 }
 
-// Tests a message that must survive roundtrip exactly, modulo one "hole" which may be set to 0s on
-// re-serialization.
+// Tests a message that must survive roundtrip exactly, modulo one "hole" which may be set to
+// any value on re-serialization.
 #[macro_export]
 macro_rules! test_msg_hole {
        ($MsgType: path, $data: ident, $hole: expr, $hole_len: expr) => {
                {
                        use lightning::util::ser::{Writeable, Readable};
                        let mut r = ::std::io::Cursor::new($data);
-                       if let Ok(msg) = <$MsgType as Readable<::std::io::Cursor<&[u8]>>>::read(&mut r) {
+                       if let Ok(msg) = <$MsgType as Readable>::read(&mut r) {
                                let mut w = VecWriter(Vec::new());
                                msg.write(&mut w).unwrap();
                                let p = w.0.len() as usize;