Skip to content

Commit

Permalink
ref: temporarily comment out erc20-related benches
Browse files Browse the repository at this point in the history
  • Loading branch information
0xNeshi committed Nov 20, 2024
1 parent 65ca111 commit d1e4ee7
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 32 deletions.
1 change: 0 additions & 1 deletion benches/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ struct ArbOtherFields {

/// Cache options for the contract.
/// `Bid(0)` will likely cache the contract on the nitro test node.
#[derive(Clone)]
pub enum CacheOpt {
None,
Bid(u32),
Expand Down
60 changes: 29 additions & 31 deletions benches/src/vesting_wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use alloy::{
sol_types::{SolCall, SolConstructor},
uint,
};
use alloy_primitives::U256;
use e2e::{receipt, Account};

use crate::{
Expand All @@ -31,22 +30,17 @@ sol!(
function vestedAmount(uint64 timestamp) external view returns (uint256 vestedAmount);
function vestedAmount(address token, uint64 timestamp) external view returns (uint256 vestedAmount);
}

#[sol(rpc)]
contract Erc20 {
function mint(address account, uint256 amount) external;
}
);

sol!("../examples/vesting-wallet/src/constructor.sol");
sol!("../examples/erc20/src/constructor.sol");
// sol!("../examples/erc20/src/constructor.sol");

const START_TIMESTAMP: u64 = 1000;
const DURATION_SECONDS: u64 = 1000;

const TOKEN_NAME: &str = "Test Token";
const TOKEN_SYMBOL: &str = "TTK";
const CAP: U256 = uint!(1_000_000_U256);
// const TOKEN_NAME: &str = "Test Token";
// const TOKEN_SYMBOL: &str = "TTK";
// const CAP: U256 = uint!(1_000_000_U256);

pub async fn bench() -> eyre::Result<ContractReport> {
let reports = run_with(CacheOpt::None).await?;
Expand All @@ -72,16 +66,20 @@ pub async fn run_with(
.wallet(EthereumWallet::from(alice.signer.clone()))
.on_http(alice.url().parse()?);

let contract_addr = deploy(&alice, cache_opt.clone()).await?;
let erc20_addr = deploy_token(&alice, cache_opt).await?;
let contract_addr = deploy(&alice, cache_opt).await?;
// let erc20_addr = deploy_token(&alice, cache_opt).await?;

let contract = VestingWallet::new(contract_addr, &alice_wallet);
let erc20 = Erc20::new(erc20_addr, &alice_wallet);
// let erc20 = Erc20::new(erc20_addr, &alice_wallet);

let _ = receipt!(contract.receiveEther().value(uint!(1000_U256)))?;
let _ = receipt!(erc20.mint(contract_addr, uint!(1000_U256)))?;
// let _ = receipt!(erc20.mint(contract_addr, uint!(1000_U256)))?;

let timestamp = START_TIMESTAMP + DURATION_SECONDS / 2;

// IMPORTANT: Order matters!
// TODO: uncomment ERC-20-related benches once solution to
// `error` ProgramNotActivated()` is found.
use VestingWallet::*;
#[rustfmt::skip]
let receipts = vec![
Expand All @@ -90,13 +88,13 @@ pub async fn run_with(
(durationCall::SIGNATURE, receipt!(contract.duration())?),
(endCall::SIGNATURE, receipt!(contract.end())?),
(released_0Call::SIGNATURE, receipt!(contract.released_0())?),
(released_1Call::SIGNATURE, receipt!(contract.released_1(erc20_addr))?),
// (released_1Call::SIGNATURE, receipt!(contract.released_1(erc20_addr))?),
(releasable_0Call::SIGNATURE, receipt!(contract.releasable_0())?),
(releasable_1Call::SIGNATURE, receipt!(contract.releasable_1(erc20_addr))?),
// (releasable_1Call::SIGNATURE, receipt!(contract.releasable_1(erc20_addr))?),
(release_0Call::SIGNATURE, receipt!(contract.release_0())?),
(release_1Call::SIGNATURE, receipt!(contract.release_1(erc20_addr))?),
(vestedAmount_0Call::SIGNATURE, receipt!(contract.vestedAmount_0(START_TIMESTAMP))?),
(vestedAmount_1Call::SIGNATURE, receipt!(contract.vestedAmount_1(erc20_addr, START_TIMESTAMP))?),
// (release_1Call::SIGNATURE, receipt!(contract.release_1(erc20_addr))?),
(vestedAmount_0Call::SIGNATURE, receipt!(contract.vestedAmount_0(timestamp))?),
// (vestedAmount_1Call::SIGNATURE, receipt!(contract.vestedAmount_1(erc20_addr, timestamp))?),
];

receipts
Expand All @@ -118,15 +116,15 @@ async fn deploy(
crate::deploy(account, "vesting-wallet", Some(args), cache_opt).await
}

async fn deploy_token(
account: &Account,
cache_opt: CacheOpt,
) -> eyre::Result<Address> {
let args = Erc20Example::constructorCall {
name_: TOKEN_NAME.to_owned(),
symbol_: TOKEN_SYMBOL.to_owned(),
cap_: CAP,
};
let args = alloy::hex::encode(args.abi_encode());
crate::deploy(account, "erc20", Some(args), cache_opt).await
}
// async fn deploy_token(
// account: &Account,
// cache_opt: CacheOpt,
// ) -> eyre::Result<Address> {
// let args = Erc20Example::constructorCall {
// name_: TOKEN_NAME.to_owned(),
// symbol_: TOKEN_SYMBOL.to_owned(),
// cap_: CAP,
// };
// let args = alloy::hex::encode(args.abi_encode());
// crate::deploy(account, "erc20", Some(args), cache_opt).await
// }

0 comments on commit d1e4ee7

Please sign in to comment.