|
| 1 | +//! This test expects you to have a devnode running: |
| 2 | +//! <https://docs.arbitrum.io/run-arbitrum-node/run-nitro-dev-node> |
| 3 | +//! |
| 4 | +//! It also expects `cargo-stylus` and `cast` to be installed: |
| 5 | +//! - <https://github.com/OffchainLabs/cargo-stylus> |
| 6 | +//! - <https://book.getfoundry.sh/cast/> |
| 7 | +#![warn(clippy::pedantic)] |
| 8 | + |
| 9 | +use crate::{call, deploy, send, MUTEX}; |
| 10 | +use std::path::PathBuf; |
| 11 | + |
| 12 | +#[test] |
| 13 | +fn erc20() { |
| 14 | + let _lock = MUTEX.lock(); |
| 15 | + let (tempdir, address) = deploy( |
| 16 | + PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("integration/stylus/Uniswap/test/ERC20.sol"), |
| 17 | + "ERC20", |
| 18 | + true, |
| 19 | + ) |
| 20 | + .unwrap(); |
| 21 | + let dir = &tempdir; |
| 22 | + |
| 23 | + let balance = concat!("1000000", "000000000000000000"); |
| 24 | + |
| 25 | + let stdout = call(dir, &address, ["totalSupply()(uint256)"]).unwrap(); |
| 26 | + println!("{}", stdout); |
| 27 | + assert_eq!("0\n", stdout); |
| 28 | + |
| 29 | + let stdout = send(dir, &address, ["init(uint256)", balance]).unwrap(); |
| 30 | + println!("{}", stdout); |
| 31 | + |
| 32 | + // smoelius: Calling `init` a second time should revert. |
| 33 | + let error = send(dir, &address, ["init(uint256)", balance]).unwrap_err(); |
| 34 | + println!("{:?}", error); |
| 35 | + |
| 36 | + let stdout = call(dir, &address, ["totalSupply()(uint256)"]).unwrap(); |
| 37 | + println!("{}", stdout); |
| 38 | + assert_eq!("1000000000000000000000000 [1e24]\n", stdout); |
| 39 | +} |
0 commit comments