Skip to content

Commit

Permalink
Merge pull request #2126 from ljedrz/tests/remove_subslice_s11n_asserts
Browse files Browse the repository at this point in the history
Remove flakiness caused by subslice assertions
  • Loading branch information
howardwu authored Nov 1, 2023
2 parents 325f425 + 31661bd commit 0ebfd23
Show file tree
Hide file tree
Showing 37 changed files with 1 addition and 126 deletions.
1 change: 0 additions & 1 deletion console/program/src/data/ciphertext/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<CurrentNetwork>::read_le(&expected_bytes[1..]).is_err());
}
Ok(())
}
Expand Down
1 change: 0 additions & 1 deletion console/program/src/data/future/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<CurrentNetwork>::read_le(&expected_bytes[1..]).is_err());

Ok(())
}
Expand Down
1 change: 0 additions & 1 deletion console/program/src/data/identifier/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<CurrentNetwork>::read_le(&expected_bytes[1..]).is_err());
}
Ok(())
}
Expand Down
2 changes: 0 additions & 2 deletions console/program/src/data/literal/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<CurrentNetwork>::read_le(&expected_bytes[1..]).is_err());
// assert!(Literal::<CurrentNetwork>::read_le(&expected_bytes[2..]).is_err());
Ok(())
}

Expand Down
5 changes: 0 additions & 5 deletions console/program/src/data/plaintext/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<CurrentNetwork>::read_le(&expected_bytes[1..]).is_err());
// assert!(Plaintext::<CurrentNetwork>::read_le(&expected_bytes[2..]).is_err());
// assert!(Plaintext::<CurrentNetwork>::read_le(&expected_bytes[3..]).is_err());
Ok(())
}

Expand Down Expand Up @@ -225,15 +222,13 @@ mod tests {
// Check the byte representation.
let expected_bytes = expected.to_bytes_le()?;
assert_eq!(expected, Plaintext::read_le(&expected_bytes[..])?);
assert!(Plaintext::<CurrentNetwork>::read_le(&expected_bytes[1..]).is_err());

// Check the array manually.
let expected = Plaintext::<CurrentNetwork>::from_str("[ 1u8, 2u8, 3u8, 4u8, 5u8, 6u8, 7u8, 8u8, 9u8, 10u8 ]")?;

// Check the byte representation.
let expected_bytes = expected.to_bytes_le()?;
assert_eq!(expected, Plaintext::read_le(&expected_bytes[..])?);
assert!(Plaintext::<CurrentNetwork>::read_le(&expected_bytes[1..]).is_err());

Ok(())
}
Expand Down
1 change: 0 additions & 1 deletion console/program/src/data/record/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<CurrentNetwork, Plaintext<CurrentNetwork>>::read_le(&expected_bytes[1..]).is_err());
Ok(())
}
}
2 changes: 0 additions & 2 deletions console/program/src/data/value/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<CurrentNetwork>::read_le(&expected_bytes[1..]).is_err());
Ok(())
}

Expand All @@ -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::<CurrentNetwork>::read_le(&expected_bytes[1..]).is_err());
Ok(())
}
}
4 changes: 0 additions & 4 deletions console/program/src/request/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,6 @@ impl<N: Network> ToBytes for Request<N> {
#[cfg(test)]
mod tests {
use super::*;
use snarkvm_console_network::Testnet3;

type CurrentNetwork = Testnet3;

#[test]
fn test_bytes() {
Expand All @@ -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::<CurrentNetwork>::read_le(&expected_bytes[1..]).is_err());
}
}
}
4 changes: 0 additions & 4 deletions console/program/src/state_path/header_leaf/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ impl<N: Network> ToBytes for HeaderLeaf<N> {
#[cfg(test)]
mod tests {
use super::*;
use snarkvm_console_network::Testnet3;

type CurrentNetwork = Testnet3;

const ITERATIONS: u64 = 1000;

Expand All @@ -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::<CurrentNetwork>::read_le(&expected_bytes[1..]).is_err());
}
Ok(())
}
Expand Down
4 changes: 0 additions & 4 deletions console/program/src/state_path/transaction_leaf/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ impl<N: Network> ToBytes for TransactionLeaf<N> {
#[cfg(test)]
mod tests {
use super::*;
use snarkvm_console_network::Testnet3;

type CurrentNetwork = Testnet3;

const ITERATIONS: u64 = 1000;

Expand All @@ -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::<CurrentNetwork>::read_le(&expected_bytes[1..]).is_err());
}
Ok(())
}
Expand Down
4 changes: 0 additions & 4 deletions console/program/src/state_path/transition_leaf/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ impl<N: Network> ToBytes for TransitionLeaf<N> {
#[cfg(test)]
mod tests {
use super::*;
use snarkvm_console_network::Testnet3;

type CurrentNetwork = Testnet3;

const ITERATIONS: u64 = 1000;

Expand All @@ -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::<CurrentNetwork>::read_le(&expected_bytes[1..]).is_err());
}
Ok(())
}
Expand Down
1 change: 0 additions & 1 deletion console/types/string/src/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<CurrentEnvironment>::read_le(&expected_bytes[1..]).is_err());
}
Ok(())
}
Expand Down
5 changes: 1 addition & 4 deletions ledger/authority/src/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ impl<N: Network> ToBytes for Authority<N> {
#[cfg(test)]
mod tests {
use super::*;
use console::{network::Testnet3, prelude::TestRng};

type CurrentNetwork = Testnet3;
use console::prelude::TestRng;

#[test]
fn test_bytes() {
Expand All @@ -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::<CurrentNetwork>::read_le(&expected_bytes[1..]).is_err());
}
}
}
2 changes: 0 additions & 2 deletions ledger/block/src/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<CurrentNetwork>::read_le(&expected_bytes[1..]).is_err());
}
Ok(())
}
Expand All @@ -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::<CurrentNetwork>::read_le(&expected_bytes[1..]).is_err());

Ok(())
}
Expand Down
4 changes: 0 additions & 4 deletions ledger/block/src/ratifications/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ impl<N: Network> ToBytes for Ratifications<N> {
#[cfg(test)]
mod tests {
use super::*;
use console::network::Testnet3;

type CurrentNetwork = Testnet3;

const ITERATIONS: u32 = 100;

Expand All @@ -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::<CurrentNetwork>::read_le(&expected_bytes[1..]).is_err());
}
Ok(())
}
Expand Down
4 changes: 0 additions & 4 deletions ledger/block/src/ratify/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,6 @@ impl<N: Network> ToBytes for Ratify<N> {
#[cfg(test)]
mod tests {
use super::*;
use console::network::Testnet3;

type CurrentNetwork = Testnet3;

#[test]
fn test_bytes() {
Expand All @@ -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::<CurrentNetwork>::read_le(&expected_bytes[1..]).is_err());
}
}
}
4 changes: 0 additions & 4 deletions ledger/block/src/transaction/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,6 @@ impl<N: Network> ToBytes for Transaction<N> {
#[cfg(test)]
mod tests {
use super::*;
use console::network::Testnet3;

type CurrentNetwork = Testnet3;

#[test]
fn test_bytes() -> Result<()> {
Expand All @@ -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::<CurrentNetwork>::read_le(&expected_bytes[1..]).is_err());
}
Ok(())
}
Expand Down
4 changes: 0 additions & 4 deletions ledger/block/src/transaction/deployment/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,6 @@ impl<N: Network> ToBytes for Deployment<N> {
#[cfg(test)]
mod tests {
use super::*;
use console::network::Testnet3;

type CurrentNetwork = Testnet3;

#[test]
fn test_bytes() -> Result<()> {
Expand All @@ -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::<CurrentNetwork>::read_le(&expected_bytes[1..]).is_err());
Ok(())
}
}
4 changes: 0 additions & 4 deletions ledger/block/src/transaction/execution/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,6 @@ impl<N: Network> ToBytes for Execution<N> {
#[cfg(test)]
mod tests {
use super::*;
use console::network::Testnet3;

type CurrentNetwork = Testnet3;

#[test]
fn test_bytes() -> Result<()> {
Expand All @@ -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::<CurrentNetwork>::read_le(&expected_bytes[1..]).is_err());
Ok(())
}
}
5 changes: 0 additions & 5 deletions ledger/block/src/transaction/fee/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ impl<N: Network> ToBytes for Fee<N> {
#[cfg(test)]
mod tests {
use super::*;
use console::network::Testnet3;

type CurrentNetwork = Testnet3;

#[test]
fn test_bytes() -> Result<()> {
Expand All @@ -78,15 +75,13 @@ mod tests {
// Check the byte representation.
let expected_bytes = expected.to_bytes_le()?;
assert_eq!(expected, Fee::read_le(&expected_bytes[..])?);
assert!(Fee::<CurrentNetwork>::read_le(&expected_bytes[1..]).is_err());

// Construct a new public fee.
let expected = crate::transaction::fee::test_helpers::sample_fee_public_hardcoded(rng);

// Check the byte representation.
let expected_bytes = expected.to_bytes_le()?;
assert_eq!(expected, Fee::read_le(&expected_bytes[..])?);
assert!(Fee::<CurrentNetwork>::read_le(&expected_bytes[1..]).is_err());

Ok(())
}
Expand Down
4 changes: 0 additions & 4 deletions ledger/block/src/transactions/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ impl<N: Network> ToBytes for Transactions<N> {
#[cfg(test)]
mod tests {
use super::*;
use console::network::Testnet3;

type CurrentNetwork = Testnet3;

#[test]
fn test_bytes() -> Result<()> {
Expand All @@ -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::<CurrentNetwork>::read_le(&expected_bytes[1..]).is_err());
}
Ok(())
}
Expand Down
4 changes: 0 additions & 4 deletions ledger/block/src/transactions/confirmed/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,17 +143,13 @@ impl<N: Network> ToBytes for ConfirmedTransaction<N> {
#[cfg(test)]
mod tests {
use super::*;
use console::network::Testnet3;

type CurrentNetwork = Testnet3;

#[test]
fn test_bytes() {
for expected in crate::transactions::confirmed::test_helpers::sample_confirmed_transactions() {
// Check the byte representation.
let expected_bytes = expected.to_bytes_le().unwrap();
assert_eq!(expected, ConfirmedTransaction::read_le(&expected_bytes[..]).unwrap());
assert!(ConfirmedTransaction::<CurrentNetwork>::read_le(&expected_bytes[1..]).is_err());
}
}
}
4 changes: 0 additions & 4 deletions ledger/block/src/transactions/rejected/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,13 @@ impl<N: Network> ToBytes for Rejected<N> {
#[cfg(test)]
mod tests {
use super::*;
use console::network::Testnet3;

type CurrentNetwork = Testnet3;

#[test]
fn test_bytes() {
for expected in crate::transactions::rejected::test_helpers::sample_rejected_transactions() {
// Check the byte representation.
let expected_bytes = expected.to_bytes_le().unwrap();
assert_eq!(expected, Rejected::read_le(&expected_bytes[..]).unwrap());
assert!(Rejected::<CurrentNetwork>::read_le(&expected_bytes[1..]).is_err());
}
}
}
4 changes: 0 additions & 4 deletions ledger/block/src/transition/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,6 @@ impl<N: Network> ToBytes for Transition<N> {
#[cfg(test)]
mod tests {
use super::*;
use console::network::Testnet3;

type CurrentNetwork = Testnet3;

#[test]
fn test_bytes() -> Result<()> {
Expand All @@ -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::<CurrentNetwork>::read_le(&expected_bytes[1..]).is_err());

Ok(())
}
Expand Down
Loading

0 comments on commit 0ebfd23

Please sign in to comment.