Skip to content

Commit

Permalink
update gas test
Browse files Browse the repository at this point in the history
  • Loading branch information
kovalgek committed Dec 12, 2023
1 parent a73bcf4 commit 6d37edc
Showing 1 changed file with 16 additions and 78 deletions.
94 changes: 16 additions & 78 deletions test/optimism/deposit-gas-estimation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import env from "../../utils/env";
import { wei } from "../../utils/wei";
import optimism from "../../utils/optimism";
import testing, { scenario } from "../../utils/testing";
import { ethers } from "hardhat";
import { BigNumber } from "ethers";

scenario("Optimism :: Bridging integration test", ctxFactory)
.after(async (ctx) => {
Expand Down Expand Up @@ -77,11 +75,7 @@ scenario("Optimism :: Bridging integration test", ctxFactory)
l2Token,
l1TokenRebasable,
l1ERC20TokenBridge,
l2TokenRebasable,
l1CrossDomainMessenger,
l2ERC20TokenBridge,
tokensRateOracle,
l1Provider
l2TokenRebasable
} = ctx;

const { accountA: tokenHolderA } = ctx.accounts;
Expand All @@ -99,25 +93,20 @@ scenario("Optimism :: Bridging integration test", ctxFactory)
l1ERC20TokenBridge.address
);

for(var x = 0; x< 2; ++x) {
const tx0 = await l1ERC20TokenBridge
.connect(tokenHolderA.l1Signer)
.depositERC20(
l1Token.address,
l2Token.address,
0,
200_000,
"0x"
);

const receipt0 = await tx0.wait();

console.log("l1Token gasUsed=",receipt0.gasUsed);
}
const tx0 = await l1ERC20TokenBridge
.connect(tokenHolderA.l1Signer)
.depositERC20(
l1Token.address,
l2Token.address,
0,
200_000,
"0x"
);

for(var x = 0; x< 2; ++x) {
const receipt0 = await tx0.wait();
console.log("l1Token gasUsed=",receipt0.gasUsed);

const tx = await l1ERC20TokenBridge
const tx1 = await l1ERC20TokenBridge
.connect(tokenHolderA.l1Signer)
.depositERC20(
l1TokenRebasable.address,
Expand All @@ -127,62 +116,11 @@ scenario("Optimism :: Bridging integration test", ctxFactory)
"0x"
);

const receipt1 = await tx.wait();

const receipt1 = await tx1.wait();
console.log("l1TokenRebasable gasUsed=",receipt1.gasUsed);
}
//const gasDifference = receipt1.gasUsed.sub(receipt0.gasUsed);

//console.log("gasUsed difference=", gasDifference);


// const blockNumber = await l1Provider.getBlockNumber();
// const blockTimestamp = (await l1Provider.getBlock(blockNumber)).timestamp;
// const blockTimestampStr = ethers.utils.hexZeroPad(ethers.utils.hexlify(blockTimestamp), 32)
// const tokensPerStEthStr = ethers.utils.hexZeroPad(tokensPerStEth.toHexString(), 32)
// const dataToSend = ethers.utils.hexConcat([tokensPerStEthStr, blockTimestampStr]);


// await assert.emits(l1ERC20TokenBridge, tx, "ERC20DepositInitiated", [
// l1TokenRebasable.address,
// l2TokenRebasable.address,
// tokenHolderA.address,
// tokenHolderA.address,
// 0,
// dataToSend,
// ]);

// const l2DepositCalldata = l2ERC20TokenBridge.interface.encodeFunctionData(
// "finalizeDeposit",
// [
// l1TokenRebasable.address,
// l2TokenRebasable.address,
// tokenHolderA.address,
// tokenHolderA.address,
// 0,
// dataToSend,
// ]
// );

// const messageNonce = await l1CrossDomainMessenger.messageNonce();

// await assert.emits(l1CrossDomainMessenger, tx, "SentMessage", [
// l2ERC20TokenBridge.address,
// l1ERC20TokenBridge.address,
// l2DepositCalldata,
// messageNonce,
// 200_000,
// ]);

// assert.equalBN(
// await l1Token.balanceOf(l1ERC20TokenBridge.address),
// l1ERC20TokenBridgeBalanceBefore
// );

// assert.equalBN(
// await l1TokenRebasable.balanceOf(tokenHolderA.address),
// tokenHolderABalanceBefore
// );
const gasDifference = receipt1.gasUsed.sub(receipt0.gasUsed);
console.log("gasUsed difference=", gasDifference);
})


Expand Down

0 comments on commit 6d37edc

Please sign in to comment.