Exclude from formatting stuff in the network module

In preparation for formatting the `network` module; improve the
formatting, and direct `rustfmt` to skip formatting, on a bunch of
byte arrays.
This commit is contained in:
Tobin C. Harding 2022-10-27 13:31:55 +11:00
parent 408d7737fb
commit 81f69e846b
1 changed files with 47 additions and 36 deletions

View File

@ -574,6 +574,7 @@ mod test {
}
#[test]
#[rustfmt::skip]
fn serialize_verack_test() {
assert_eq!(serialize(&RawNetworkMessage { magic: Magic::from(Network::Bitcoin), payload: NetworkMessage::Verack }),
vec![0xf9, 0xbe, 0xb4, 0xd9, 0x76, 0x65, 0x72, 0x61,
@ -582,6 +583,7 @@ mod test {
}
#[test]
#[rustfmt::skip]
fn serialize_ping_test() {
assert_eq!(serialize(&RawNetworkMessage { magic: Magic::from(Network::Bitcoin), payload: NetworkMessage::Ping(100) }),
vec![0xf9, 0xbe, 0xb4, 0xd9, 0x70, 0x69, 0x6e, 0x67,
@ -592,6 +594,7 @@ mod test {
#[test]
#[rustfmt::skip]
fn serialize_mempool_test() {
assert_eq!(serialize(&RawNetworkMessage { magic: Magic::from(Network::Bitcoin), payload: NetworkMessage::MemPool }),
vec![0xf9, 0xbe, 0xb4, 0xd9, 0x6d, 0x65, 0x6d, 0x70,
@ -600,6 +603,7 @@ mod test {
}
#[test]
#[rustfmt::skip]
fn serialize_getaddr_test() {
assert_eq!(serialize(&RawNetworkMessage { magic: Magic::from(Network::Bitcoin), payload: NetworkMessage::GetAddr }),
vec![0xf9, 0xbe, 0xb4, 0xd9, 0x67, 0x65, 0x74, 0x61,
@ -609,10 +613,12 @@ mod test {
#[test]
fn deserialize_getaddr_test() {
let msg = deserialize(
&[0xf9, 0xbe, 0xb4, 0xd9, 0x67, 0x65, 0x74, 0x61,
#[rustfmt::skip]
let msg = deserialize(&[
0xf9, 0xbe, 0xb4, 0xd9, 0x67, 0x65, 0x74, 0x61,
0x64, 0x64, 0x72, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x5d, 0xf6, 0xe0, 0xe2]);
0x00, 0x00, 0x00, 0x00, 0x5d, 0xf6, 0xe0, 0xe2
]);
let preimage = RawNetworkMessage { magic: Magic::from(Network::Bitcoin), payload: NetworkMessage::GetAddr };
assert!(msg.is_ok());
let msg : RawNetworkMessage = msg.unwrap();
@ -622,8 +628,9 @@ mod test {
#[test]
fn deserialize_version_test() {
let msg = deserialize::<RawNetworkMessage>(
&[ 0xf9, 0xbe, 0xb4, 0xd9, 0x76, 0x65, 0x72, 0x73,
#[rustfmt::skip]
let msg = deserialize::<RawNetworkMessage>(&[
0xf9, 0xbe, 0xb4, 0xd9, 0x76, 0x65, 0x72, 0x73,
0x69, 0x6f, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00,
0x66, 0x00, 0x00, 0x00, 0xbe, 0x61, 0xb8, 0x27,
0x7f, 0x11, 0x01, 0x00, 0x0d, 0x04, 0x00, 0x00,
@ -638,7 +645,8 @@ mod test {
0xfa, 0xa9, 0x95, 0x59, 0xcc, 0x68, 0xa1, 0xc1,
0x10, 0x2f, 0x53, 0x61, 0x74, 0x6f, 0x73, 0x68,
0x69, 0x3a, 0x30, 0x2e, 0x31, 0x37, 0x2e, 0x31,
0x2f, 0x93, 0x8c, 0x08, 0x00, 0x01 ]);
0x2f, 0x93, 0x8c, 0x08, 0x00, 0x01
]);
assert!(msg.is_ok());
let msg = msg.unwrap();
@ -658,7 +666,9 @@ mod test {
#[test]
fn deserialize_partial_message_test() {
let data = [ 0xf9, 0xbe, 0xb4, 0xd9, 0x76, 0x65, 0x72, 0x73,
#[rustfmt::skip]
let data = [
0xf9, 0xbe, 0xb4, 0xd9, 0x76, 0x65, 0x72, 0x73,
0x69, 0x6f, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00,
0x66, 0x00, 0x00, 0x00, 0xbe, 0x61, 0xb8, 0x27,
0x7f, 0x11, 0x01, 0x00, 0x0d, 0x04, 0x00, 0x00,
@ -673,7 +683,8 @@ mod test {
0xfa, 0xa9, 0x95, 0x59, 0xcc, 0x68, 0xa1, 0xc1,
0x10, 0x2f, 0x53, 0x61, 0x74, 0x6f, 0x73, 0x68,
0x69, 0x3a, 0x30, 0x2e, 0x31, 0x37, 0x2e, 0x31,
0x2f, 0x93, 0x8c, 0x08, 0x00, 0x01, 0, 0 ];
0x2f, 0x93, 0x8c, 0x08, 0x00, 0x01, 0x00, 0x00
];
let msg = deserialize_partial::<RawNetworkMessage>(&data);
assert!(msg.is_ok());