Skip to content

Commit

Permalink
chore: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ifechukwudaniel committed Jan 9, 2025
1 parent c93ebfb commit c61a95d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
19 changes: 16 additions & 3 deletions examples/erc4626/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use alloc::vec::Vec;

use alloy_primitives::{Address, U256};
use openzeppelin_stylus::token::erc20::{
extensions::{Erc20Metadata, Erc4626, IERC4626},
extensions::{Erc20Metadata, Erc4626, IErc20Metadata, IERC4626},
utils::SafeErc20,
Erc20,
};
Expand All @@ -27,6 +27,14 @@ struct Erc4626Example {
#[public]
#[inherit(Erc20, Erc20Metadata)]
impl Erc4626Example {
fn name(&self) -> String {
self.metadata.name()
}

fn symbol(&self) -> String {
self.metadata.symbol()
}

fn total_assets(&self) -> U256 {
self.erc4626.total_assets(&self.erc20)
}
Expand Down Expand Up @@ -59,7 +67,6 @@ impl Erc4626Example {
self.erc4626.preview_mint(shares, &mut self.erc20)
}


fn mint(
&mut self,
shares: U256,
Expand All @@ -82,7 +89,13 @@ impl Erc4626Example {
receiver: Address,
owner: Address,
) -> Result<U256, Vec<u8>> {
Ok(self.erc4626.withdraw(assets, receiver, owner, &mut self.erc20, &mut self.safe_erc20)?)
Ok(self.erc4626.withdraw(
assets,
receiver,
owner,
&mut self.erc20,
&mut self.safe_erc20,
)?)
}

fn max_redeem(&mut self, owner: Address) -> U256 {
Expand Down
7 changes: 3 additions & 4 deletions examples/erc4626/tests/erc4626.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const VALUT_SYMBOL: &str = "TST Valut";
mod abi;

Check warning on line 20 in examples/erc4626/tests/erc4626.rs

View workflow job for this annotation

GitHub Actions / nightly / fmt

Diff in /home/runner/work/rust-contracts-stylus/rust-contracts-stylus/examples/erc4626/tests/erc4626.rs
mod mock;

const ADDRESS: Address = Address::ZERO;

sol!("src/constructor.sol");

Expand All @@ -46,9 +45,9 @@ async fn constructs(alice: Account) -> eyre::Result<()> {
let name = contract.name().call().await?.name;
let symbol = contract.symbol().call().await?.symbol;
let asset = contract.asset().call().await?.asset;
println!("name: {}, symbol: {} asset: {}", name, symbol, asset);
// assert_eq!(name, VALUT_NAME.to_owned());
// assert_eq!(symbol, VALUT_SYMBOL.to_owned());
assert_eq!(name, VALUT_NAME.to_owned());
assert_eq!(symbol, VALUT_SYMBOL.to_owned());
assert_eq!(asset, mock_token_address);
Ok(())
}

Expand Down

0 comments on commit c61a95d

Please sign in to comment.