Skip to content

Commit

Permalink
Add U128 tests
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelsproul committed Aug 14, 2024
1 parent f28fd80 commit c312f0c
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion ssz/tests/tests.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use alloy_primitives::{Address, B256};
use alloy_primitives::{Address, B256, U128};
use ssz::{Decode, DecodeError, Encode};
use ssz_derive::{Decode, Encode};
use std::num::NonZeroUsize;
Expand Down Expand Up @@ -479,6 +479,28 @@ mod round_trip {
let data = vec![Arc::new(vec![0u64]), Arc::new(vec![u64::MAX; 10])];
round_trip(data);
}

#[test]
fn alloy_u128() {
let data = vec![
U128::from(0),
U128::from(u128::MAX),
U128::from(u64::MAX),
U128::from(255),
];
round_trip(data);
}

#[test]
fn vec_of_option_alloy_u128() {
let data = vec![
vec![Some(U128::from(u128::MAX)), Some(U128::from(0)), None],
vec![None],
vec![],
vec![Some(U128::from(0))],
];
round_trip(data);
}
}

/// Decode tests that are expected to fail.
Expand Down

0 comments on commit c312f0c

Please sign in to comment.