Skip to content

Commit

Permalink
test: fix missing wasm test
Browse files Browse the repository at this point in the history
  • Loading branch information
xJonathanLEI committed Mar 27, 2024
1 parent 107e7c1 commit 6cd24e2
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions starknet-core/src/types/eth_address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ mod errors {
InvalidHexString,
}

#[derive(PartialEq, Debug)]
#[derive(Debug)]
pub struct FromFieldElementError;

#[derive(Debug)]
Expand Down Expand Up @@ -192,9 +192,10 @@ impl From<[u8; 20]> for EthAddress {

#[cfg(test)]
mod tests {
use super::EthAddress;
use crate::types::eth_address::FromFieldElementError;
use super::{EthAddress, FromBytesSliceError, FromFieldElementError};

use alloc::vec::*;

use hex_literal::hex;
use starknet_ff::FieldElement;

Expand Down Expand Up @@ -280,15 +281,18 @@ mod tests {
&FieldElement::from_hex_be("0x10000000000000000000000000000000000000000").unwrap(),
) {
Ok(_) => panic!("Expected error, but got Ok"),
Err(err) => assert_eq!(err, FromFieldElementError),
Err(FromFieldElementError) => {}
}
}

#[test]
#[should_panic(expected = "FromBytesSliceError")]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
fn test_eth_address_from_slice_invalid_slice() {
let buffer: Vec<u8> = vec![0, 1, 2, 3, 4, 5, 6, 7];

EthAddress::try_from(&buffer[0..4]).unwrap();
match EthAddress::try_from(&buffer[0..4]) {
Ok(_) => panic!("Expected error, but got Ok"),
Err(FromBytesSliceError) => {}
}
}
}

0 comments on commit 6cd24e2

Please sign in to comment.