Skip to content

Commit

Permalink
Add missing test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
jacek-casper committed Mar 28, 2024
1 parent 7a40dbe commit 766c005
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions types/src/binary_port/type_wrappers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ impl FromBytes for TransactionWithExecutionInfo {

/// A query result for a dictionary item, contains the dictionary item key and a global state query
/// result.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq)]
pub struct DictionaryQueryResult {
key: Key,
query_result: GlobalStateQueryResult,
Expand Down Expand Up @@ -359,7 +359,7 @@ mod tests {
use rand::Rng;

use super::*;
use crate::testing::TestRng;
use crate::{execution::ExecutionResult, testing::TestRng, BlockHash, CLValue, StoredValue};

#[test]
fn uptime_roundtrip() {
Expand Down Expand Up @@ -422,4 +422,29 @@ mod tests {
Some(TimeDiff::from_millis(rng.gen())),
));
}

#[test]
fn transaction_with_execution_info_roundtrip() {
let rng = &mut TestRng::new();
bytesrepr::test_serialization_roundtrip(&TransactionWithExecutionInfo::new(
Transaction::random(rng),
rng.gen::<bool>().then(|| ExecutionInfo {
block_hash: BlockHash::random(rng),
block_height: rng.gen(),
execution_result: rng.gen::<bool>().then(|| ExecutionResult::random(rng)),
}),
));
}

#[test]
fn dictionary_query_result_roundtrip() {
let rng = &mut TestRng::new();
bytesrepr::test_serialization_roundtrip(&DictionaryQueryResult::new(
Key::Account(rng.gen()),
GlobalStateQueryResult::new(
StoredValue::CLValue(CLValue::from_t(rng.gen::<i32>()).unwrap()),
vec![],
),
));
}
}

0 comments on commit 766c005

Please sign in to comment.