Skip to content

Commit

Permalink
use nonce management for L1->L2 test
Browse files Browse the repository at this point in the history
  • Loading branch information
count-sum committed Oct 22, 2024
1 parent c37559e commit a65d3da
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions e2e/src/bridge-tokens.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,17 @@ describe("Bridge ERC20 Tokens L1 -> L2 and L2 -> L1", () => {
]);

console.log("Approving tokens to L1 TokenBridge");
const approveTx = await l1Token.connect(l1Account).approve(l1TokenBridge.getAddress(), ethers.parseEther("100"));

const l1Provider = config.getL1Provider();
let { maxPriorityFeePerGas: l1MaxPriorityFeePerGas, maxFeePerGas: l1MaxFeePerGas } = await l1Provider.getFeeData();

let nonce = await l1Provider.getTransactionCount(l1Account.address, "pending");

const approveTx = await l1Token.connect(l1Account).approve(l1TokenBridge.getAddress(), ethers.parseEther("100"), {
maxPriorityFeePerGas: l1MaxPriorityFeePerGas,
maxFeePerGas: l1MaxFeePerGas,
nonce: nonce,
});
await approveTx.wait();

const l1TokenBridgeAddress = await l1TokenBridge.getAddress();
Expand All @@ -35,11 +45,16 @@ describe("Bridge ERC20 Tokens L1 -> L2 and L2 -> L1", () => {

console.log("Calling the bridgeToken function on the L1 TokenBridge contract");

({ maxPriorityFeePerGas: l1MaxPriorityFeePerGas, maxFeePerGas: l1MaxFeePerGas } = await l1Provider.getFeeData());
nonce = await l1Provider.getTransactionCount(l1Account.address, "pending");

const bridgeTokenTx = await l1TokenBridge
.connect(l1Account)
.bridgeToken(l1TokenAddress, bridgeAmount, l2Account.address, {
value: etherToWei("0.01"),
gasPrice: ethers.parseUnits("300", "gwei"),
maxPriorityFeePerGas: l1MaxPriorityFeePerGas,
maxFeePerGas: l1MaxFeePerGas,
nonce: nonce,
});

let receipt = await bridgeTokenTx.wait();
Expand Down

0 comments on commit a65d3da

Please sign in to comment.