Skip to content

Commit

Permalink
Fix shared unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Antony1060 committed Jan 21, 2024
1 parent 488c32f commit 027ba0e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
6 changes: 4 additions & 2 deletions shared/src/models/lookup/addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,17 @@ mod tests {
use ethers::providers::namehash;
use hex_literal::hex;

use crate::models::lookup::ENSLookup;

#[test]
fn test_calldata_address() {
assert_eq!(
Addr {}.calldata(&namehash("eth")),
ENSLookup::Addr.calldata(&namehash("eth")),
hex!("3b3b57de93cdeb708b7545dc668eb9280176169d1c33cfd8ed6f04690a0bcc88a93fc4ae")
);

assert_eq!(
Addr {}.calldata(&namehash("foo.eth")),
ENSLookup::Addr.calldata(&namehash("foo.eth")),
hex!("3b3b57dede9b09fd7c5f901e23a3f19fecc54828e9c848539801e86591bd9801b019f84f")
);
}
Expand Down
3 changes: 2 additions & 1 deletion shared/src/models/lookup/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,13 @@ pub async fn decode(data: &[u8], state: &LookupState) -> Result<String, ENSLooku

#[cfg(test)]
mod tests {
use crate::models::lookup::ENSLookup;
use ethers::providers::namehash;

#[test]
fn test_calldata_avatar() {
assert_eq!(
Image::from("avatar").calldata(&namehash("luc.eth")),
ENSLookup::Image("avatar".to_string()).calldata(&namehash("luc.eth")),
hex_literal::hex!("59d1d43ce1e7bcf2ca33c28a806ee265cfedf02fedf1b124ca73b2203ca80cc7c91a02ad000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000066176617461720000000000000000000000000000000000000000000000000000")
);
}
Expand Down
4 changes: 2 additions & 2 deletions shared/src/models/multicoin/cointype/coins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ mod tests {

#[test]
fn test_to_coin_type_evm() {
let coin_type: CoinType = CoinType::from(1);
let coin_type: CoinType = CoinType::from(2147483649);

assert_eq!(coin_type, CoinType::Evm(ChainId::Ethereum));
}

#[test]
fn test_to_coin_type_evm_gnosis() {
let coin_type: CoinType = CoinType::from(2147483658);
let coin_type: CoinType = CoinType::from(2147483748);

assert_eq!(coin_type, CoinType::Evm(ChainId::Gnosis));
}
Expand Down
16 changes: 7 additions & 9 deletions shared/src/models/universal_resolver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,22 +172,20 @@ mod tests {
use ethers_core::abi::ParamType;
use ethers_core::types::Address;

use crate::models::lookup::addr::Addr;
use crate::models::lookup::text::Text;
use crate::models::lookup::ENSLookup;
use crate::models::universal_resolver;

#[tokio::test]
async fn test_resolve_universal() {
let provider = Provider::<Http>::try_from("https://rpc.ankr.com/eth").unwrap();

let calldata: Vec<Box<dyn ENSLookup + Send + Sync>> = vec![
Addr {}.to_boxed(),
Text::from("com.discord").to_boxed(),
Text::from("com.github").to_boxed(),
Text::from("com.twitter").to_boxed(),
Text::from("org.telegram").to_boxed(),
Text::from("location").to_boxed(),
let calldata: Vec<ENSLookup> = vec![
ENSLookup::Addr,
ENSLookup::Text("com.discord".to_string()),
ENSLookup::Text("com.github".to_string()),
ENSLookup::Text("com.twitter".to_string()),
ENSLookup::Text("org.telegram".to_string()),
ENSLookup::Text("location".to_string()),
];

let res = universal_resolver::resolve_universal(
Expand Down

0 comments on commit 027ba0e

Please sign in to comment.