diff --git a/crates/net/eth-wire/src/types/blocks.rs b/crates/net/eth-wire/src/types/blocks.rs index 1180cdecf7..f0eee6b9cf 100644 --- a/crates/net/eth-wire/src/types/blocks.rs +++ b/crates/net/eth-wire/src/types/blocks.rs @@ -153,8 +153,8 @@ mod tests { } } - #[test] // Test vector from: https://eips.ethereum.org/EIPS/eip-2481 + #[test] fn encode_get_block_header() { let expected = hex!( "e8820457e4a000000000000000000000000000000000000000000000000000000000deadc0de050580" @@ -175,8 +175,8 @@ mod tests { assert_eq!(data, expected); } - #[test] // Test vector from: https://eips.ethereum.org/EIPS/eip-2481 + #[test] fn decode_get_block_header() { let data = hex!( "e8820457e4a000000000000000000000000000000000000000000000000000000000deadc0de050580" @@ -196,8 +196,8 @@ mod tests { assert_eq!(result.unwrap(), expected); } - #[test] // Test vector from: https://eips.ethereum.org/EIPS/eip-2481 + #[test] fn encode_get_block_header_number() { let expected = hex!("ca820457c682270f050580"); let mut data = vec![]; @@ -214,8 +214,8 @@ mod tests { assert_eq!(data, expected); } - #[test] // Test vector from: https://eips.ethereum.org/EIPS/eip-2481 + #[test] fn decode_get_block_header_number() { let data = hex!("ca820457c682270f050580"); let expected = RequestPair:: { @@ -231,8 +231,8 @@ mod tests { assert_eq!(result.unwrap(), expected); } - #[test] // Test vector from: https://eips.ethereum.org/EIPS/eip-2481 + #[test] fn encode_block_header() { // [ (f90202) 0x0457 = 1111, [ (f901fc) [ (f901f9) header ] ] ] let expected = hex!("f90202820457f901fcf901f9a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000940000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008208ae820d0582115c8215b3821a0a827788a00000000000000000000000000000000000000000000000000000000000000000880000000000000000"); @@ -267,8 +267,8 @@ mod tests { assert_eq!(data, expected); } - #[test] // Test vector from: https://eips.ethereum.org/EIPS/eip-2481 + #[test] fn decode_block_header() { let data = hex!("f90202820457f901fcf901f9a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000940000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008208ae820d0582115c8215b3821a0a827788a00000000000000000000000000000000000000000000000000000000000000000880000000000000000"); let expected = RequestPair:: { @@ -302,8 +302,8 @@ mod tests { assert_eq!(result.unwrap(), expected); } - #[test] // Test vector from: https://eips.ethereum.org/EIPS/eip-2481 + #[test] fn encode_get_block_bodies() { let expected = hex!("f847820457f842a000000000000000000000000000000000000000000000000000000000deadc0dea000000000000000000000000000000000000000000000000000000000feedbeef"); let mut data = vec![]; @@ -318,8 +318,8 @@ mod tests { assert_eq!(data, expected); } - #[test] // Test vector from: https://eips.ethereum.org/EIPS/eip-2481 + #[test] fn decode_get_block_bodies() { let data = hex!("f847820457f842a000000000000000000000000000000000000000000000000000000000deadc0dea000000000000000000000000000000000000000000000000000000000feedbeef"); let expected = RequestPair:: { @@ -333,12 +333,10 @@ mod tests { assert_eq!(result.unwrap(), expected); } - #[test] // Test vector from: https://eips.ethereum.org/EIPS/eip-2481 + #[test] fn encode_block_bodies() { - let expected = - hex!("f902dc820457f902d6f902d3f8d2f867088504a817c8088302e2489435353535353535353535353535353535353535358202008025a064b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c12a064b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c10f867098504a817c809830334509435353535353535353535353535353535353535358202d98025a052f8f61201b2b11a78d6e866abc9c3db2ae8631fa656bfe5cb53668255367afba052f8f61201b2b11a78d6e866abc9c3db2ae8631fa656bfe5cb53668255367afbf901fcf901f9a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000940000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008208ae820d0582115c8215b3821a0a827788a00000000000000000000000000000000000000000000000000000000000000000880000000000000000" - ); + let expected = hex!("f902dc820457f902d6f902d3f8d2f867088504a817c8088302e2489435353535353535353535353535353535353535358202008025a064b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c12a064b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c10f867098504a817c809830334509435353535353535353535353535353535353535358202d98025a052f8f61201b2b11a78d6e866abc9c3db2ae8631fa656bfe5cb53668255367afba052f8f61201b2b11a78d6e866abc9c3db2ae8631fa656bfe5cb53668255367afbf901fcf901f9a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000940000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008208ae820d0582115c8215b3821a0a827788a00000000000000000000000000000000000000000000000000000000000000000880000000000000000"); let mut data = vec![]; let request = RequestPair:: { request_id: 1111, @@ -350,17 +348,14 @@ mod tests { nonce: 0x8u64, gas_price: 0x4a817c808, gas_limit: 0x2e248u64, - to: - TransactionKind::Call(hex!("3535353535353535353535353535353535353535").into()), + to: TransactionKind::Call(hex!("3535353535353535353535353535353535353535").into()), value: 0x200u64.into(), input: Default::default(), }), Signature { odd_y_parity: false, - r: - U256::from_str("0x64b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c12").unwrap(), - s: - U256::from_str("0x64b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c10").unwrap(), + r: U256::from_str("0x64b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c12").unwrap(), + s: U256::from_str("0x64b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c10").unwrap(), } ), TransactionSigned::from_transaction_and_signature(Transaction::Legacy(TxLegacy { @@ -368,42 +363,32 @@ mod tests { nonce: 0x9u64, gas_price: 0x4a817c809, gas_limit: 0x33450u64, - to: - TransactionKind::Call(hex!("3535353535353535353535353535353535353535").into()), + to: TransactionKind::Call(hex!("3535353535353535353535353535353535353535").into()), value: 0x2d9u64.into(), input: Default::default(), }), Signature { odd_y_parity: false, - r: - U256::from_str("0x52f8f61201b2b11a78d6e866abc9c3db2ae8631fa656bfe5cb53668255367afb").unwrap(), - s: - U256::from_str("0x52f8f61201b2b11a78d6e866abc9c3db2ae8631fa656bfe5cb53668255367afb").unwrap(), + r: U256::from_str("0x52f8f61201b2b11a78d6e866abc9c3db2ae8631fa656bfe5cb53668255367afb").unwrap(), + s: U256::from_str("0x52f8f61201b2b11a78d6e866abc9c3db2ae8631fa656bfe5cb53668255367afb").unwrap(), }, ), ], ommers: vec![ Header { - parent_hash: - hex!("0000000000000000000000000000000000000000000000000000000000000000").into(), - ommers_hash: - hex!("0000000000000000000000000000000000000000000000000000000000000000").into(), + parent_hash: hex!("0000000000000000000000000000000000000000000000000000000000000000").into(), + ommers_hash: hex!("0000000000000000000000000000000000000000000000000000000000000000").into(), beneficiary: hex!("0000000000000000000000000000000000000000").into(), - state_root: - hex!("0000000000000000000000000000000000000000000000000000000000000000").into(), - transactions_root: - hex!("0000000000000000000000000000000000000000000000000000000000000000").into(), - receipts_root: - hex!("0000000000000000000000000000000000000000000000000000000000000000").into(), - logs_bloom: - hex!("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" - ).into(), difficulty: U256::from(0x8aeu64), + state_root: hex!("0000000000000000000000000000000000000000000000000000000000000000").into(), + transactions_root: hex!("0000000000000000000000000000000000000000000000000000000000000000").into(), + receipts_root: hex!("0000000000000000000000000000000000000000000000000000000000000000").into(), + logs_bloom: hex!("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").into(), + difficulty: U256::from(0x8aeu64), number: 0xd05u64, gas_limit: 0x115cu64, gas_used: 0x15b3u64, timestamp: 0x1a0au64, extra_data: hex!("7788")[..].into(), - mix_hash: - hex!("0000000000000000000000000000000000000000000000000000000000000000").into(), + mix_hash: hex!("0000000000000000000000000000000000000000000000000000000000000000").into(), nonce: 0x0000000000000000u64, base_fee_per_gas: None, withdrawals_root: None, @@ -420,77 +405,64 @@ mod tests { assert_eq!(data, expected); } - #[test] // Test vector from: https://eips.ethereum.org/EIPS/eip-2481 + #[test] fn decode_block_bodies() { - let data = - hex!("f902dc820457f902d6f902d3f8d2f867088504a817c8088302e2489435353535353535353535353535353535353535358202008025a064b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c12a064b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c10f867098504a817c809830334509435353535353535353535353535353535353535358202d98025a052f8f61201b2b11a78d6e866abc9c3db2ae8631fa656bfe5cb53668255367afba052f8f61201b2b11a78d6e866abc9c3db2ae8631fa656bfe5cb53668255367afbf901fcf901f9a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000940000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008208ae820d0582115c8215b3821a0a827788a00000000000000000000000000000000000000000000000000000000000000000880000000000000000" - ); + let data = hex!("f902dc820457f902d6f902d3f8d2f867088504a817c8088302e2489435353535353535353535353535353535353535358202008025a064b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c12a064b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c10f867098504a817c809830334509435353535353535353535353535353535353535358202d98025a052f8f61201b2b11a78d6e866abc9c3db2ae8631fa656bfe5cb53668255367afba052f8f61201b2b11a78d6e866abc9c3db2ae8631fa656bfe5cb53668255367afbf901fcf901f9a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000940000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008208ae820d0582115c8215b3821a0a827788a00000000000000000000000000000000000000000000000000000000000000000880000000000000000"); let expected = RequestPair:: { request_id: 1111, message: BlockBodies(vec![ BlockBody { transactions: vec![ - TransactionSigned::from_transaction_and_signature(Transaction::Legacy(TxLegacy { - chain_id: Some(1), - nonce: 0x8u64, - gas_price: 0x4a817c808, - gas_limit: 0x2e248u64, - to: - TransactionKind::Call(hex!("3535353535353535353535353535353535353535").into()), - value: 0x200u64.into(), - input: Default::default(), - }), - Signature { + TransactionSigned::from_transaction_and_signature(Transaction::Legacy( + TxLegacy { + chain_id: Some(1), + nonce: 0x8u64, + gas_price: 0x4a817c808, + gas_limit: 0x2e248u64, + to: TransactionKind::Call(hex!("3535353535353535353535353535353535353535").into()), + value: 0x200u64.into(), + input: Default::default(), + }), + Signature { odd_y_parity: false, - r: - U256::from_str("0x64b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c12").unwrap(), - s: - U256::from_str("0x64b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c10").unwrap(), + r: U256::from_str("0x64b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c12").unwrap(), + s: U256::from_str("0x64b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c10").unwrap(), } ), - TransactionSigned::from_transaction_and_signature(Transaction::Legacy(TxLegacy { - chain_id: Some(1), - nonce: 0x9u64, - gas_price: 0x4a817c809, - gas_limit: 0x33450u64, - to: - TransactionKind::Call(hex!("3535353535353535353535353535353535353535").into()), - value: 0x2d9u64.into(), - input: Default::default(), - }), - Signature { + TransactionSigned::from_transaction_and_signature( + Transaction::Legacy(TxLegacy { + chain_id: Some(1), + nonce: 0x9u64, + gas_price: 0x4a817c809, + gas_limit: 0x33450u64, + to: TransactionKind::Call(hex!("3535353535353535353535353535353535353535").into()), + value: 0x2d9u64.into(), + input: Default::default(), + }), + Signature { odd_y_parity: false, - r: - U256::from_str("0x52f8f61201b2b11a78d6e866abc9c3db2ae8631fa656bfe5cb53668255367afb").unwrap(), - s: - U256::from_str("0x52f8f61201b2b11a78d6e866abc9c3db2ae8631fa656bfe5cb53668255367afb").unwrap(), - }, + r: U256::from_str("0x52f8f61201b2b11a78d6e866abc9c3db2ae8631fa656bfe5cb53668255367afb").unwrap(), + s: U256::from_str("0x52f8f61201b2b11a78d6e866abc9c3db2ae8631fa656bfe5cb53668255367afb").unwrap(), + } ), ], ommers: vec![ Header { - parent_hash: - hex!("0000000000000000000000000000000000000000000000000000000000000000").into(), - ommers_hash: - hex!("0000000000000000000000000000000000000000000000000000000000000000").into(), + parent_hash: hex!("0000000000000000000000000000000000000000000000000000000000000000").into(), + ommers_hash: hex!("0000000000000000000000000000000000000000000000000000000000000000").into(), beneficiary: hex!("0000000000000000000000000000000000000000").into(), - state_root: - hex!("0000000000000000000000000000000000000000000000000000000000000000").into(), - transactions_root: - hex!("0000000000000000000000000000000000000000000000000000000000000000").into(), - receipts_root: - hex!("0000000000000000000000000000000000000000000000000000000000000000").into(), - logs_bloom: - hex!("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" - ).into(), difficulty: U256::from(0x8aeu64), + state_root: hex!("0000000000000000000000000000000000000000000000000000000000000000").into(), + transactions_root: hex!("0000000000000000000000000000000000000000000000000000000000000000").into(), + receipts_root: hex!("0000000000000000000000000000000000000000000000000000000000000000").into(), + logs_bloom: hex!("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").into(), + difficulty: U256::from(0x8aeu64), number: 0xd05u64, gas_limit: 0x115cu64, gas_used: 0x15b3u64, timestamp: 0x1a0au64, extra_data: hex!("7788")[..].into(), - mix_hash: - hex!("0000000000000000000000000000000000000000000000000000000000000000").into(), + mix_hash: hex!("0000000000000000000000000000000000000000000000000000000000000000").into(), nonce: 0x0000000000000000u64, base_fee_per_gas: None, withdrawals_root: None,