Skip to content

Commit

Permalink
chore: revert tests for ERC-721 Metadata example
Browse files Browse the repository at this point in the history
  • Loading branch information
bidzyyys committed Aug 22, 2024
1 parent 94b8d38 commit a5fa47d
Showing 1 changed file with 27 additions and 34 deletions.
61 changes: 27 additions & 34 deletions examples/erc721-metadata/tests/erc721.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use abi::Erc721;
use alloy::{
primitives::{Address, U256},
sol,
sol_types::SolValue,
};
use e2e::{receipt, watch, Account, EventExt, ReceiptExt, Revert};

Expand Down Expand Up @@ -46,14 +45,14 @@ async fn constructs(alice: Account) -> eyre::Result<()> {
.address()?;
let contract = Erc721::new(contract_addr, &alice.wallet);

// let Erc721::nameReturn { name } = contract.name().call().await?;
// let Erc721::symbolReturn { symbol } = contract.symbol().call().await?;
// let Erc721::baseUriReturn { baseURI } = contract.baseUri().call().await?;
//
// assert_eq!(TOKEN_NAME.to_owned(), name);
// assert_eq!(TOKEN_SYMBOL.to_owned(), symbol);
// assert_eq!(base_uri.to_owned(), baseURI);
//
let Erc721::nameReturn { name } = contract.name().call().await?;
let Erc721::symbolReturn { symbol } = contract.symbol().call().await?;
let Erc721::baseUriReturn { baseURI } = contract.baseUri().call().await?;

assert_eq!(TOKEN_NAME.to_owned(), name);
assert_eq!(TOKEN_SYMBOL.to_owned(), symbol);
assert_eq!(base_uri.to_owned(), baseURI);

Ok(())
}

Expand All @@ -69,9 +68,9 @@ async fn constructs_with_base_uri(alice: Account) -> eyre::Result<()> {
.address()?;
let contract = Erc721::new(contract_addr, &alice.wallet);

// let Erc721::baseUriReturn { baseURI } = contract.baseUri().call().await?;
//
// assert_eq!(base_uri.to_owned(), baseURI);
let Erc721::baseUriReturn { baseURI } = contract.baseUri().call().await?;

assert_eq!(base_uri.to_owned(), baseURI);

Ok(())
}
Expand Down Expand Up @@ -127,12 +126,6 @@ async fn return_empty_token_uri_when_without_base_uri_and_token_uri(
let Erc721::tokenURIReturn { tokenURI } =
contract.tokenURI(token_id).call().await?;

let expected = String::from("test string");
let encoded = expected.abi_encode();

let decoded: String =
SolValue::abi_decode(&encoded, true).expect("should decode");
assert_eq!(expected, decoded);
assert_eq!("", tokenURI);

Ok(())
Expand All @@ -157,10 +150,10 @@ async fn return_token_uri_with_base_uri_and_without_token_uri(

let _ = watch!(contract.mint(alice.address(), token_id))?;

// let Erc721::tokenURIReturn { tokenURI } =
// contract.tokenURI(token_id).call().await?;
//
// assert_eq!(base_uri.to_owned() + &token_id.to_string(), tokenURI);
let Erc721::tokenURIReturn { tokenURI } =
contract.tokenURI(token_id).call().await?;

assert_eq!(base_uri.to_owned() + &token_id.to_string(), tokenURI);
Ok(())
}

Expand Down Expand Up @@ -191,10 +184,10 @@ async fn return_token_uri_with_base_uri_and_token_uri(

assert!(receipt.emits(Erc721::MetadataUpdate { tokenId: token_id }));

// let Erc721::tokenURIReturn { tokenURI } =
// contract.tokenURI(token_id).call().await?;
//
// assert_eq!(base_uri.to_owned() + &token_uri, tokenURI);
let Erc721::tokenURIReturn { tokenURI } =
contract.tokenURI(token_id).call().await?;

assert_eq!(base_uri.to_owned() + &token_uri, tokenURI);

Ok(())
}
Expand Down Expand Up @@ -234,10 +227,10 @@ async fn set_token_uri_before_mint(alice: Account) -> eyre::Result<()> {

let _ = watch!(contract.mint(alice.address(), token_id))?;

// let Erc721::tokenURIReturn { tokenURI } =
// contract.tokenURI(token_id).call().await?;
//
// assert_eq!(base_uri.to_owned() + &token_uri, tokenURI);
let Erc721::tokenURIReturn { tokenURI } =
contract.tokenURI(token_id).call().await?;

assert_eq!(base_uri.to_owned() + &token_uri, tokenURI);

Ok(())
}
Expand Down Expand Up @@ -293,9 +286,9 @@ async fn return_token_uri_after_burn_and_remint(
contract.ownerOf(token_id).call().await?;
assert_eq!(alice_addr, owner_of);

// let Erc721::tokenURIReturn { tokenURI } =
// contract.tokenURI(token_id).call().await?;
//
// assert_eq!(base_uri.to_owned() + &token_id.to_string(), tokenURI);
let Erc721::tokenURIReturn { tokenURI } =
contract.tokenURI(token_id).call().await?;

assert_eq!(base_uri.to_owned() + &token_id.to_string(), tokenURI);
Ok(())
}

0 comments on commit a5fa47d

Please sign in to comment.