From 8ace3471176fc232ada1be3b75576232384d18a9 Mon Sep 17 00:00:00 2001 From: ljedrz Date: Wed, 25 Oct 2023 12:50:18 +0200 Subject: [PATCH 1/2] tests: remove flakiness caused by subslice assertions Signed-off-by: ljedrz --- console/program/src/data/ciphertext/bytes.rs | 1 - console/program/src/data/future/bytes.rs | 1 - console/program/src/data/identifier/bytes.rs | 1 - console/program/src/data/literal/bytes.rs | 2 -- console/program/src/data/plaintext/bytes.rs | 5 ----- console/program/src/data/record/bytes.rs | 1 - console/program/src/data/value/bytes.rs | 2 -- console/program/src/request/bytes.rs | 4 ---- console/program/src/state_path/header_leaf/bytes.rs | 4 ---- console/program/src/state_path/transaction_leaf/bytes.rs | 4 ---- console/program/src/state_path/transition_leaf/bytes.rs | 4 ---- console/types/string/src/bytes.rs | 1 - ledger/authority/src/bytes.rs | 5 +---- ledger/block/src/bytes.rs | 2 -- ledger/block/src/ratifications/bytes.rs | 4 ---- ledger/block/src/ratify/bytes.rs | 4 ---- ledger/block/src/transaction/bytes.rs | 4 ---- ledger/block/src/transaction/deployment/bytes.rs | 4 ---- ledger/block/src/transaction/execution/bytes.rs | 4 ---- ledger/block/src/transaction/fee/bytes.rs | 5 ----- ledger/block/src/transactions/bytes.rs | 4 ---- ledger/block/src/transactions/confirmed/bytes.rs | 4 ---- ledger/block/src/transactions/rejected/bytes.rs | 4 ---- ledger/block/src/transition/bytes.rs | 4 ---- ledger/block/src/transition/input/bytes.rs | 4 ---- ledger/block/src/transition/output/bytes.rs | 4 ---- ledger/committee/src/bytes.rs | 4 ---- ledger/narwhal/batch-certificate/src/bytes.rs | 4 ---- ledger/narwhal/batch-header/src/bytes.rs | 4 ---- ledger/narwhal/subdag/src/bytes.rs | 4 ---- ledger/narwhal/transmission/src/bytes.rs | 4 ---- synthesizer/process/src/stack/authorization/bytes.rs | 4 ---- synthesizer/program/src/logic/instruction/operation/call.rs | 1 - synthesizer/snark/src/certificate/bytes.rs | 4 ---- synthesizer/snark/src/proof/bytes.rs | 4 ---- 35 files changed, 1 insertion(+), 118 deletions(-) diff --git a/console/program/src/data/ciphertext/bytes.rs b/console/program/src/data/ciphertext/bytes.rs index 212a6e84d5..d983d9bb71 100644 --- a/console/program/src/data/ciphertext/bytes.rs +++ b/console/program/src/data/ciphertext/bytes.rs @@ -66,7 +66,6 @@ mod tests { // Check the byte representation. let expected_bytes = expected.to_bytes_le()?; assert_eq!(expected, Ciphertext::read_le(&expected_bytes[..])?); - // assert!(Ciphertext::::read_le(&expected_bytes[1..]).is_err()); } Ok(()) } diff --git a/console/program/src/data/future/bytes.rs b/console/program/src/data/future/bytes.rs index f4e492bdd8..95878055f1 100644 --- a/console/program/src/data/future/bytes.rs +++ b/console/program/src/data/future/bytes.rs @@ -84,7 +84,6 @@ mod tests { // Check the byte representation. let expected_bytes = expected.to_bytes_le()?; assert_eq!(expected, Future::read_le(&expected_bytes[..])?); - assert!(Future::::read_le(&expected_bytes[1..]).is_err()); Ok(()) } diff --git a/console/program/src/data/identifier/bytes.rs b/console/program/src/data/identifier/bytes.rs index e90d7fbae3..7342dd07ab 100644 --- a/console/program/src/data/identifier/bytes.rs +++ b/console/program/src/data/identifier/bytes.rs @@ -72,7 +72,6 @@ mod tests { // Check the byte representation. let expected_bytes = expected.to_bytes_le()?; assert_eq!(expected, Identifier::read_le(&expected_bytes[..])?); - assert!(Identifier::::read_le(&expected_bytes[1..]).is_err()); } Ok(()) } diff --git a/console/program/src/data/literal/bytes.rs b/console/program/src/data/literal/bytes.rs index d52f43045b..1f77bf3430 100644 --- a/console/program/src/data/literal/bytes.rs +++ b/console/program/src/data/literal/bytes.rs @@ -132,8 +132,6 @@ mod tests { // Check the byte representation. let expected_bytes = expected.to_bytes_le()?; assert_eq!(expected, Literal::read_le(&expected_bytes[..])?); - assert!(Literal::::read_le(&expected_bytes[1..]).is_err()); - // assert!(Literal::::read_le(&expected_bytes[2..]).is_err()); Ok(()) } diff --git a/console/program/src/data/plaintext/bytes.rs b/console/program/src/data/plaintext/bytes.rs index a6c4867bc4..99cdd82ed4 100644 --- a/console/program/src/data/plaintext/bytes.rs +++ b/console/program/src/data/plaintext/bytes.rs @@ -131,9 +131,6 @@ mod tests { // Check the byte representation. let expected_bytes = expected.to_bytes_le()?; assert_eq!(expected, Plaintext::read_le(&expected_bytes[..])?); - // assert!(Plaintext::::read_le(&expected_bytes[1..]).is_err()); - // assert!(Plaintext::::read_le(&expected_bytes[2..]).is_err()); - // assert!(Plaintext::::read_le(&expected_bytes[3..]).is_err()); Ok(()) } @@ -225,7 +222,6 @@ mod tests { // Check the byte representation. let expected_bytes = expected.to_bytes_le()?; assert_eq!(expected, Plaintext::read_le(&expected_bytes[..])?); - assert!(Plaintext::::read_le(&expected_bytes[1..]).is_err()); // Check the array manually. let expected = Plaintext::::from_str("[ 1u8, 2u8, 3u8, 4u8, 5u8, 6u8, 7u8, 8u8, 9u8, 10u8 ]")?; @@ -233,7 +229,6 @@ mod tests { // Check the byte representation. let expected_bytes = expected.to_bytes_le()?; assert_eq!(expected, Plaintext::read_le(&expected_bytes[..])?); - assert!(Plaintext::::read_le(&expected_bytes[1..]).is_err()); Ok(()) } diff --git a/console/program/src/data/record/bytes.rs b/console/program/src/data/record/bytes.rs index 6c74f0b1ad..a787040499 100644 --- a/console/program/src/data/record/bytes.rs +++ b/console/program/src/data/record/bytes.rs @@ -95,7 +95,6 @@ mod tests { // Check the byte representation. let expected_bytes = expected.to_bytes_le()?; assert_eq!(expected, Record::read_le(&expected_bytes[..])?); - assert!(Record::>::read_le(&expected_bytes[1..]).is_err()); Ok(()) } } diff --git a/console/program/src/data/value/bytes.rs b/console/program/src/data/value/bytes.rs index 8bfa9fcade..50e8567f05 100644 --- a/console/program/src/data/value/bytes.rs +++ b/console/program/src/data/value/bytes.rs @@ -67,7 +67,6 @@ mod tests { // Check the byte representation. let expected_bytes = expected.to_bytes_le()?; assert_eq!(expected, Value::read_le(&expected_bytes[..])?); - assert!(Value::::read_le(&expected_bytes[1..]).is_err()); Ok(()) } @@ -81,7 +80,6 @@ mod tests { // Check the byte representation. let expected_bytes = expected.to_bytes_le()?; assert_eq!(expected, Value::read_le(&expected_bytes[..])?); - assert!(Value::::read_le(&expected_bytes[1..]).is_err()); Ok(()) } } diff --git a/console/program/src/request/bytes.rs b/console/program/src/request/bytes.rs index 761b6b1340..ec664b9c48 100644 --- a/console/program/src/request/bytes.rs +++ b/console/program/src/request/bytes.rs @@ -100,9 +100,6 @@ impl ToBytes for Request { #[cfg(test)] mod tests { use super::*; - use snarkvm_console_network::Testnet3; - - type CurrentNetwork = Testnet3; #[test] fn test_bytes() { @@ -112,7 +109,6 @@ mod tests { // Check the byte representation. let expected_bytes = expected.to_bytes_le().unwrap(); assert_eq!(expected, Request::read_le(&expected_bytes[..]).unwrap()); - assert!(Request::::read_le(&expected_bytes[1..]).is_err()); } } } diff --git a/console/program/src/state_path/header_leaf/bytes.rs b/console/program/src/state_path/header_leaf/bytes.rs index cde4608989..16f2b03bca 100644 --- a/console/program/src/state_path/header_leaf/bytes.rs +++ b/console/program/src/state_path/header_leaf/bytes.rs @@ -39,9 +39,6 @@ impl ToBytes for HeaderLeaf { #[cfg(test)] mod tests { use super::*; - use snarkvm_console_network::Testnet3; - - type CurrentNetwork = Testnet3; const ITERATIONS: u64 = 1000; @@ -56,7 +53,6 @@ mod tests { // Check the byte representation. let expected_bytes = expected.to_bytes_le()?; assert_eq!(expected, HeaderLeaf::read_le(&expected_bytes[..])?); - assert!(HeaderLeaf::::read_le(&expected_bytes[1..]).is_err()); } Ok(()) } diff --git a/console/program/src/state_path/transaction_leaf/bytes.rs b/console/program/src/state_path/transaction_leaf/bytes.rs index 602c66689c..db10cf1f90 100644 --- a/console/program/src/state_path/transaction_leaf/bytes.rs +++ b/console/program/src/state_path/transaction_leaf/bytes.rs @@ -43,9 +43,6 @@ impl ToBytes for TransactionLeaf { #[cfg(test)] mod tests { use super::*; - use snarkvm_console_network::Testnet3; - - type CurrentNetwork = Testnet3; const ITERATIONS: u64 = 1000; @@ -60,7 +57,6 @@ mod tests { // Check the byte representation. let expected_bytes = expected.to_bytes_le()?; assert_eq!(expected, TransactionLeaf::read_le(&expected_bytes[..])?); - assert!(TransactionLeaf::::read_le(&expected_bytes[1..]).is_err()); } Ok(()) } diff --git a/console/program/src/state_path/transition_leaf/bytes.rs b/console/program/src/state_path/transition_leaf/bytes.rs index 90a6ac9beb..b06f9def4e 100644 --- a/console/program/src/state_path/transition_leaf/bytes.rs +++ b/console/program/src/state_path/transition_leaf/bytes.rs @@ -51,9 +51,6 @@ impl ToBytes for TransitionLeaf { #[cfg(test)] mod tests { use super::*; - use snarkvm_console_network::Testnet3; - - type CurrentNetwork = Testnet3; const ITERATIONS: u64 = 1000; @@ -68,7 +65,6 @@ mod tests { // Check the byte representation. let expected_bytes = expected.to_bytes_le()?; assert_eq!(expected, TransitionLeaf::read_le(&expected_bytes[..])?); - assert!(TransitionLeaf::::read_le(&expected_bytes[1..]).is_err()); } Ok(()) } diff --git a/console/types/string/src/bytes.rs b/console/types/string/src/bytes.rs index 137dd5f0ac..46fd7fcf33 100644 --- a/console/types/string/src/bytes.rs +++ b/console/types/string/src/bytes.rs @@ -67,7 +67,6 @@ mod tests { // Check the byte representation. let expected_bytes = expected.to_bytes_le()?; assert_eq!(expected, StringType::read_le(&expected_bytes[..])?); - assert!(StringType::::read_le(&expected_bytes[1..]).is_err()); } Ok(()) } diff --git a/ledger/authority/src/bytes.rs b/ledger/authority/src/bytes.rs index 45ccbe65b4..1d710be1c6 100644 --- a/ledger/authority/src/bytes.rs +++ b/ledger/authority/src/bytes.rs @@ -52,9 +52,7 @@ impl ToBytes for Authority { #[cfg(test)] mod tests { use super::*; - use console::{network::Testnet3, prelude::TestRng}; - - type CurrentNetwork = Testnet3; + use console::prelude::TestRng; #[test] fn test_bytes() { @@ -64,7 +62,6 @@ mod tests { // Check the byte representation. let expected_bytes = expected.to_bytes_le().unwrap(); assert_eq!(expected, Authority::read_le(&expected_bytes[..]).unwrap()); - assert!(Authority::::read_le(&expected_bytes[1..]).is_err()); } } } diff --git a/ledger/block/src/bytes.rs b/ledger/block/src/bytes.rs index 7c72e849f3..448c24cc3d 100644 --- a/ledger/block/src/bytes.rs +++ b/ledger/block/src/bytes.rs @@ -134,7 +134,6 @@ mod tests { // Check the byte representation. let expected_bytes = expected.to_bytes_le()?; assert_eq!(expected, Block::read_le(&expected_bytes[..])?); - assert!(Block::::read_le(&expected_bytes[1..]).is_err()); } Ok(()) } @@ -147,7 +146,6 @@ mod tests { // Check the byte representation. let expected_bytes = genesis_block.to_bytes_le()?; assert_eq!(genesis_block, Block::read_le(&expected_bytes[..])?); - assert!(Block::::read_le(&expected_bytes[1..]).is_err()); Ok(()) } diff --git a/ledger/block/src/ratifications/bytes.rs b/ledger/block/src/ratifications/bytes.rs index 0db7fd3311..aa8d6f4a9a 100644 --- a/ledger/block/src/ratifications/bytes.rs +++ b/ledger/block/src/ratifications/bytes.rs @@ -53,9 +53,6 @@ impl ToBytes for Ratifications { #[cfg(test)] mod tests { use super::*; - use console::network::Testnet3; - - type CurrentNetwork = Testnet3; const ITERATIONS: u32 = 100; @@ -68,7 +65,6 @@ mod tests { // Check the byte representation. let expected_bytes = expected.to_bytes_le()?; assert_eq!(expected, Ratifications::read_le(&expected_bytes[..])?); - assert!(Ratifications::::read_le(&expected_bytes[1..]).is_err()); } Ok(()) } diff --git a/ledger/block/src/ratify/bytes.rs b/ledger/block/src/ratify/bytes.rs index 2cd5cad850..bab8503907 100644 --- a/ledger/block/src/ratify/bytes.rs +++ b/ledger/block/src/ratify/bytes.rs @@ -94,9 +94,6 @@ impl ToBytes for Ratify { #[cfg(test)] mod tests { use super::*; - use console::network::Testnet3; - - type CurrentNetwork = Testnet3; #[test] fn test_bytes() { @@ -106,7 +103,6 @@ mod tests { // Check the byte representation. let expected_bytes = expected.to_bytes_le().unwrap(); assert_eq!(expected, Ratify::read_le(&expected_bytes[..]).unwrap()); - assert!(Ratify::::read_le(&expected_bytes[1..]).is_err()); } } } diff --git a/ledger/block/src/transaction/bytes.rs b/ledger/block/src/transaction/bytes.rs index ee6c194dcc..299c27be99 100644 --- a/ledger/block/src/transaction/bytes.rs +++ b/ledger/block/src/transaction/bytes.rs @@ -139,9 +139,6 @@ impl ToBytes for Transaction { #[cfg(test)] mod tests { use super::*; - use console::network::Testnet3; - - type CurrentNetwork = Testnet3; #[test] fn test_bytes() -> Result<()> { @@ -158,7 +155,6 @@ mod tests { // Check the byte representation. let expected_bytes = expected.to_bytes_le()?; assert_eq!(expected, Transaction::read_le(&expected_bytes[..])?); - assert!(Transaction::::read_le(&expected_bytes[1..]).is_err()); } Ok(()) } diff --git a/ledger/block/src/transaction/deployment/bytes.rs b/ledger/block/src/transaction/deployment/bytes.rs index 09a8e90966..e8e97757a6 100644 --- a/ledger/block/src/transaction/deployment/bytes.rs +++ b/ledger/block/src/transaction/deployment/bytes.rs @@ -76,9 +76,6 @@ impl ToBytes for Deployment { #[cfg(test)] mod tests { use super::*; - use console::network::Testnet3; - - type CurrentNetwork = Testnet3; #[test] fn test_bytes() -> Result<()> { @@ -90,7 +87,6 @@ mod tests { // Check the byte representation. let expected_bytes = expected.to_bytes_le()?; assert_eq!(expected, Deployment::read_le(&expected_bytes[..])?); - assert!(Deployment::::read_le(&expected_bytes[1..]).is_err()); Ok(()) } } diff --git a/ledger/block/src/transaction/execution/bytes.rs b/ledger/block/src/transaction/execution/bytes.rs index 417530360b..c10a8c8fda 100644 --- a/ledger/block/src/transaction/execution/bytes.rs +++ b/ledger/block/src/transaction/execution/bytes.rs @@ -75,9 +75,6 @@ impl ToBytes for Execution { #[cfg(test)] mod tests { use super::*; - use console::network::Testnet3; - - type CurrentNetwork = Testnet3; #[test] fn test_bytes() -> Result<()> { @@ -89,7 +86,6 @@ mod tests { // Check the byte representation. let expected_bytes = expected.to_bytes_le()?; assert_eq!(expected, Execution::read_le(&expected_bytes[..])?); - assert!(Execution::::read_le(&expected_bytes[1..]).is_err()); Ok(()) } } diff --git a/ledger/block/src/transaction/fee/bytes.rs b/ledger/block/src/transaction/fee/bytes.rs index 42443a9981..1f156f622f 100644 --- a/ledger/block/src/transaction/fee/bytes.rs +++ b/ledger/block/src/transaction/fee/bytes.rs @@ -64,9 +64,6 @@ impl ToBytes for Fee { #[cfg(test)] mod tests { use super::*; - use console::network::Testnet3; - - type CurrentNetwork = Testnet3; #[test] fn test_bytes() -> Result<()> { @@ -78,7 +75,6 @@ mod tests { // Check the byte representation. let expected_bytes = expected.to_bytes_le()?; assert_eq!(expected, Fee::read_le(&expected_bytes[..])?); - assert!(Fee::::read_le(&expected_bytes[1..]).is_err()); // Construct a new public fee. let expected = crate::transaction::fee::test_helpers::sample_fee_public_hardcoded(rng); @@ -86,7 +82,6 @@ mod tests { // Check the byte representation. let expected_bytes = expected.to_bytes_le()?; assert_eq!(expected, Fee::read_le(&expected_bytes[..])?); - assert!(Fee::::read_le(&expected_bytes[1..]).is_err()); Ok(()) } diff --git a/ledger/block/src/transactions/bytes.rs b/ledger/block/src/transactions/bytes.rs index 99df0668db..d76e8625ba 100644 --- a/ledger/block/src/transactions/bytes.rs +++ b/ledger/block/src/transactions/bytes.rs @@ -53,9 +53,6 @@ impl ToBytes for Transactions { #[cfg(test)] mod tests { use super::*; - use console::network::Testnet3; - - type CurrentNetwork = Testnet3; #[test] fn test_bytes() -> Result<()> { @@ -65,7 +62,6 @@ mod tests { // Check the byte representation. let expected_bytes = expected.to_bytes_le()?; assert_eq!(expected, Transactions::read_le(&expected_bytes[..])?); - assert!(Transactions::::read_le(&expected_bytes[1..]).is_err()); } Ok(()) } diff --git a/ledger/block/src/transactions/confirmed/bytes.rs b/ledger/block/src/transactions/confirmed/bytes.rs index ff7ceb4772..16f929215c 100644 --- a/ledger/block/src/transactions/confirmed/bytes.rs +++ b/ledger/block/src/transactions/confirmed/bytes.rs @@ -143,9 +143,6 @@ impl ToBytes for ConfirmedTransaction { #[cfg(test)] mod tests { use super::*; - use console::network::Testnet3; - - type CurrentNetwork = Testnet3; #[test] fn test_bytes() { @@ -153,7 +150,6 @@ mod tests { // Check the byte representation. let expected_bytes = expected.to_bytes_le().unwrap(); assert_eq!(expected, ConfirmedTransaction::read_le(&expected_bytes[..]).unwrap()); - assert!(ConfirmedTransaction::::read_le(&expected_bytes[1..]).is_err()); } } } diff --git a/ledger/block/src/transactions/rejected/bytes.rs b/ledger/block/src/transactions/rejected/bytes.rs index 402b2daeff..c5cff5fe43 100644 --- a/ledger/block/src/transactions/rejected/bytes.rs +++ b/ledger/block/src/transactions/rejected/bytes.rs @@ -63,9 +63,6 @@ impl ToBytes for Rejected { #[cfg(test)] mod tests { use super::*; - use console::network::Testnet3; - - type CurrentNetwork = Testnet3; #[test] fn test_bytes() { @@ -73,7 +70,6 @@ mod tests { // Check the byte representation. let expected_bytes = expected.to_bytes_le().unwrap(); assert_eq!(expected, Rejected::read_le(&expected_bytes[..]).unwrap()); - assert!(Rejected::::read_le(&expected_bytes[1..]).is_err()); } } } diff --git a/ledger/block/src/transition/bytes.rs b/ledger/block/src/transition/bytes.rs index e59403fead..dacc875df8 100644 --- a/ledger/block/src/transition/bytes.rs +++ b/ledger/block/src/transition/bytes.rs @@ -98,9 +98,6 @@ impl ToBytes for Transition { #[cfg(test)] mod tests { use super::*; - use console::network::Testnet3; - - type CurrentNetwork = Testnet3; #[test] fn test_bytes() -> Result<()> { @@ -112,7 +109,6 @@ mod tests { // Check the byte representation. let expected_bytes = expected.to_bytes_le()?; assert_eq!(expected, Transition::read_le(&expected_bytes[..])?); - assert!(Transition::::read_le(&expected_bytes[1..]).is_err()); Ok(()) } diff --git a/ledger/block/src/transition/input/bytes.rs b/ledger/block/src/transition/input/bytes.rs index e5d53ba277..faceae3a05 100644 --- a/ledger/block/src/transition/input/bytes.rs +++ b/ledger/block/src/transition/input/bytes.rs @@ -115,9 +115,6 @@ impl ToBytes for Input { #[cfg(test)] mod tests { use super::*; - use console::network::Testnet3; - - type CurrentNetwork = Testnet3; #[test] fn test_bytes() { @@ -125,7 +122,6 @@ mod tests { // Check the byte representation. let expected_bytes = expected.to_bytes_le().unwrap(); assert_eq!(expected, Input::read_le(&expected_bytes[..]).unwrap()); - assert!(Input::::read_le(&expected_bytes[1..]).is_err()); } } } diff --git a/ledger/block/src/transition/output/bytes.rs b/ledger/block/src/transition/output/bytes.rs index 0ef6003f7e..867b6600d6 100644 --- a/ledger/block/src/transition/output/bytes.rs +++ b/ledger/block/src/transition/output/bytes.rs @@ -148,9 +148,6 @@ impl ToBytes for Output { #[cfg(test)] mod tests { use super::*; - use console::network::Testnet3; - - type CurrentNetwork = Testnet3; #[test] fn test_bytes() { @@ -158,7 +155,6 @@ mod tests { // Check the byte representation. let expected_bytes = expected.to_bytes_le().unwrap(); assert_eq!(expected, Output::read_le(&expected_bytes[..]).unwrap()); - assert!(Output::::read_le(&expected_bytes[1..]).is_err()); } } } diff --git a/ledger/committee/src/bytes.rs b/ledger/committee/src/bytes.rs index 9ae159af1f..d55a80ab41 100644 --- a/ledger/committee/src/bytes.rs +++ b/ledger/committee/src/bytes.rs @@ -78,9 +78,6 @@ impl ToBytes for Committee { #[cfg(test)] mod tests { use super::*; - use console::network::Testnet3; - - type CurrentNetwork = Testnet3; #[test] fn test_bytes() { @@ -90,7 +87,6 @@ mod tests { // Check the byte representation. let expected_bytes = expected.to_bytes_le().unwrap(); assert_eq!(expected, Committee::read_le(&expected_bytes[..]).unwrap()); - assert!(Committee::::read_le(&expected_bytes[1..]).is_err()); } } } diff --git a/ledger/narwhal/batch-certificate/src/bytes.rs b/ledger/narwhal/batch-certificate/src/bytes.rs index d7dbd25dc2..aa204b010c 100644 --- a/ledger/narwhal/batch-certificate/src/bytes.rs +++ b/ledger/narwhal/batch-certificate/src/bytes.rs @@ -70,9 +70,6 @@ impl ToBytes for BatchCertificate { #[cfg(test)] mod tests { use super::*; - use console::network::Testnet3; - - type CurrentNetwork = Testnet3; #[test] fn test_bytes() { @@ -82,7 +79,6 @@ mod tests { // Check the byte representation. let expected_bytes = expected.to_bytes_le().unwrap(); assert_eq!(expected, BatchCertificate::read_le(&expected_bytes[..]).unwrap()); - assert!(BatchCertificate::::read_le(&expected_bytes[1..]).is_err()); } } } diff --git a/ledger/narwhal/batch-header/src/bytes.rs b/ledger/narwhal/batch-header/src/bytes.rs index 30f7a2cb83..f564e58c19 100644 --- a/ledger/narwhal/batch-header/src/bytes.rs +++ b/ledger/narwhal/batch-header/src/bytes.rs @@ -101,9 +101,6 @@ impl ToBytes for BatchHeader { #[cfg(test)] mod tests { use super::*; - use console::network::Testnet3; - - type CurrentNetwork = Testnet3; #[test] fn test_bytes() { @@ -113,7 +110,6 @@ mod tests { // Check the byte representation. let expected_bytes = expected.to_bytes_le().unwrap(); assert_eq!(expected, BatchHeader::read_le(&expected_bytes[..]).unwrap()); - assert!(BatchHeader::::read_le(&expected_bytes[1..]).is_err()); } } } diff --git a/ledger/narwhal/subdag/src/bytes.rs b/ledger/narwhal/subdag/src/bytes.rs index a5cc0e5dc9..c5435663e0 100644 --- a/ledger/narwhal/subdag/src/bytes.rs +++ b/ledger/narwhal/subdag/src/bytes.rs @@ -73,9 +73,6 @@ impl ToBytes for Subdag { #[cfg(test)] mod tests { use super::*; - use console::network::Testnet3; - - type CurrentNetwork = Testnet3; #[test] fn test_bytes() { @@ -85,7 +82,6 @@ mod tests { // Check the byte representation. let expected_bytes = expected.to_bytes_le().unwrap(); assert_eq!(expected, Subdag::read_le(&expected_bytes[..]).unwrap()); - assert!(Subdag::::read_le(&expected_bytes[1..]).is_err()); } } } diff --git a/ledger/narwhal/transmission/src/bytes.rs b/ledger/narwhal/transmission/src/bytes.rs index f7349fbac3..7d06ef6077 100644 --- a/ledger/narwhal/transmission/src/bytes.rs +++ b/ledger/narwhal/transmission/src/bytes.rs @@ -59,9 +59,6 @@ impl ToBytes for Transmission { #[cfg(test)] mod tests { use super::*; - use console::network::Testnet3; - - type CurrentNetwork = Testnet3; #[test] fn test_bytes() { @@ -71,7 +68,6 @@ mod tests { // Check the byte representation. let expected_bytes = expected.to_bytes_le().unwrap(); assert_eq!(expected, Transmission::read_le(&expected_bytes[..]).unwrap()); - assert!(Transmission::::read_le(&expected_bytes[1..]).is_err()); } } } diff --git a/synthesizer/process/src/stack/authorization/bytes.rs b/synthesizer/process/src/stack/authorization/bytes.rs index f2aa2ee130..d9caf4dfea 100644 --- a/synthesizer/process/src/stack/authorization/bytes.rs +++ b/synthesizer/process/src/stack/authorization/bytes.rs @@ -71,9 +71,6 @@ impl ToBytes for Authorization { #[cfg(test)] mod tests { use super::*; - use console::network::Testnet3; - - type CurrentNetwork = Testnet3; #[test] fn test_bytes() -> Result<()> { @@ -85,7 +82,6 @@ mod tests { // Check the byte representation. let expected_bytes = expected.to_bytes_le()?; assert_eq!(expected, Authorization::read_le(&expected_bytes[..])?); - assert!(Authorization::::read_le(&expected_bytes[1..]).is_err()); Ok(()) } } diff --git a/synthesizer/program/src/logic/instruction/operation/call.rs b/synthesizer/program/src/logic/instruction/operation/call.rs index aa489f5ea8..12cc42168d 100644 --- a/synthesizer/program/src/logic/instruction/operation/call.rs +++ b/synthesizer/program/src/logic/instruction/operation/call.rs @@ -544,7 +544,6 @@ mod tests { // Check the byte representation. let expected_bytes = expected.to_bytes_le().unwrap(); assert_eq!(expected, Call::read_le(&expected_bytes[..]).unwrap()); - assert!(Call::::read_le(&expected_bytes[1..]).is_err()); } } } diff --git a/synthesizer/snark/src/certificate/bytes.rs b/synthesizer/snark/src/certificate/bytes.rs index 3d21b0ad83..df0ebfecef 100644 --- a/synthesizer/snark/src/certificate/bytes.rs +++ b/synthesizer/snark/src/certificate/bytes.rs @@ -43,9 +43,6 @@ impl ToBytes for Certificate { #[cfg(test)] mod tests { use super::*; - use console::network::Testnet3; - - type CurrentNetwork = Testnet3; #[test] fn test_bytes() -> Result<()> { @@ -55,7 +52,6 @@ mod tests { // Check the byte representation. let expected_bytes = expected.to_bytes_le()?; assert_eq!(expected, Certificate::read_le(&expected_bytes[..])?); - assert!(Certificate::::read_le(&expected_bytes[1..]).is_err()); Ok(()) } diff --git a/synthesizer/snark/src/proof/bytes.rs b/synthesizer/snark/src/proof/bytes.rs index 88bc0f922a..e343178603 100644 --- a/synthesizer/snark/src/proof/bytes.rs +++ b/synthesizer/snark/src/proof/bytes.rs @@ -43,9 +43,6 @@ impl ToBytes for Proof { #[cfg(test)] mod tests { use super::*; - use console::network::Testnet3; - - type CurrentNetwork = Testnet3; #[test] fn test_bytes() -> Result<()> { @@ -55,7 +52,6 @@ mod tests { // Check the byte representation. let expected_bytes = expected.to_bytes_le()?; assert_eq!(expected, Proof::read_le(&expected_bytes[..])?); - assert!(Proof::::read_le(&expected_bytes[1..]).is_err()); Ok(()) } From 31661bd3047f2820a2c49d074b18349f3e70fec7 Mon Sep 17 00:00:00 2001 From: ljedrz Date: Fri, 27 Oct 2023 10:24:47 +0200 Subject: [PATCH 2/2] tests: remove confirmed flakiness caused by subslice assertions Signed-off-by: ljedrz --- ledger/narwhal/transmission-id/src/bytes.rs | 4 ---- synthesizer/program/src/logic/finalize_operation/bytes.rs | 4 ---- 2 files changed, 8 deletions(-) diff --git a/ledger/narwhal/transmission-id/src/bytes.rs b/ledger/narwhal/transmission-id/src/bytes.rs index ed46201b1f..a8a49a3d7b 100644 --- a/ledger/narwhal/transmission-id/src/bytes.rs +++ b/ledger/narwhal/transmission-id/src/bytes.rs @@ -50,9 +50,6 @@ impl ToBytes for TransmissionID { #[cfg(test)] mod tests { use super::*; - use console::network::Testnet3; - - type CurrentNetwork = Testnet3; #[test] fn test_bytes() { @@ -62,7 +59,6 @@ mod tests { // Check the byte representation. let expected_bytes = expected.to_bytes_le().unwrap(); assert_eq!(expected, TransmissionID::read_le(&expected_bytes[..]).unwrap()); - assert!(TransmissionID::::read_le(&expected_bytes[1..]).is_err()); } } } diff --git a/synthesizer/program/src/logic/finalize_operation/bytes.rs b/synthesizer/program/src/logic/finalize_operation/bytes.rs index 907fa3d750..a88e65a10c 100644 --- a/synthesizer/program/src/logic/finalize_operation/bytes.rs +++ b/synthesizer/program/src/logic/finalize_operation/bytes.rs @@ -134,9 +134,6 @@ impl ToBytes for FinalizeOperation { #[cfg(test)] mod tests { use super::*; - use console::network::Testnet3; - - type CurrentNetwork = Testnet3; #[test] fn test_bytes() { @@ -144,7 +141,6 @@ mod tests { // Check the byte representation. let expected_bytes = expected.to_bytes_le().unwrap(); assert_eq!(expected, FinalizeOperation::read_le(&expected_bytes[..]).unwrap()); - assert!(FinalizeOperation::::read_le(&expected_bytes[1..]).is_err()); } } }