Skip to content

Commit

Permalink
contracts/test: assert event SentMessageExtension1
Browse files Browse the repository at this point in the history
  • Loading branch information
bendanzhentan committed Nov 24, 2023
1 parent b6d603f commit 798a563
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions contracts/test/L2StandardBridgeBot.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ contract L2StandardBridgeBotTest is Test {
address user = 0x3977f9B1F4912a783B44aBa813dA388AC73a1428;
uint withdrawFee = 10000;
address constant LEGACY_ERC20_ETH = 0xDeadDeAddeAddEAddeadDEaDDEAdDeaDDeAD0000;
address constant L2_STANDARD_BRIDGE = 0x4200000000000000000000000000000000000010;

event WithdrawTo(address indexed from, address l2Token, address to, uint256 amount, uint32 minGasLimit, bytes extraData);

event SentMessageExtension1(address indexed sender , uint256 value);

function setUp() public {
opbnbMainnetFork = vm.createFork("https://opbnb-testnet-rpc.bnbchain.org");
vm.selectFork(opbnbMainnetFork);
Expand Down Expand Up @@ -83,14 +86,18 @@ contract L2StandardBridgeBotTest is Test {

vm.prank(user);
uint amount = 0;
bot.withdrawTo{value: withdrawFee + amount}(LEGACY_ERC20_ETH, user, amount, 200000, "");
bot.withdrawTo{value: withdrawFee + amount}(LEGACY_ERC20_ETH, user, amount, 200000, "");
uint round = 10;
for (uint i = 0; i < round; i++) {
bot.withdrawTo{value: withdrawFee + amount}(LEGACY_ERC20_ETH, user, amount, 200000, "");
}

uint256 postBalance = address(bot).balance;
assertEq(postBalance, prevBalance + withdrawFee * 2);
assertEq(postBalance, prevBalance + withdrawFee * round);

// WithdrawFeeToL1
vm.prank(deployer);
vm.expectEmit(true, true, true, true);
emit SentMessageExtension1(L2_STANDARD_BRIDGE, postBalance - withdrawFee);
bot.withdrawFeeToL1(user, 0, "");
}
}

0 comments on commit 798a563

Please sign in to comment.