-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
59a5613
commit 0ad4bb4
Showing
3 changed files
with
58 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
pragma solidity 0.8.20; | ||
|
||
import "forge-std/Test.sol"; | ||
import { IERC20 } from "openzeppelin-contracts/contracts/token/ERC20/IERC20.sol"; | ||
import { Ownable } from "openzeppelin-contracts/contracts/access/Ownable.sol"; | ||
import "../src/L2StandardBridgeBot.sol"; | ||
|
||
contract L2StandardBridgeBotTest is Test { | ||
L2StandardBridgeBot bot; | ||
uint256 opbnbMainnetFork; | ||
address deployer = address(0x1234); | ||
address usdt = 0xCF712f20c85421d00EAa1B6F6545AaEEb4492B75; | ||
address user = 0x3977f9B1F4912a783B44aBa813dA388AC73a1428; | ||
uint withdrawFee = 10000; | ||
address constant LEGACY_ERC20_ETH = 0xDeadDeAddeAddEAddeadDEaDDEAdDeaDDeAD0000; | ||
|
||
function setUp() public { | ||
opbnbMainnetFork = vm.createFork("https://opbnb-testnet-rpc.bnbchain.org"); | ||
vm.selectFork(opbnbMainnetFork); | ||
vm.rollFork(opbnbMainnetFork, 7125821); | ||
bot = new L2StandardBridgeBot(payable(deployer), withdrawFee); | ||
} | ||
|
||
function test_RevertSetDelegationFeeNotOwner() public { | ||
vm.expectRevert(); | ||
bot.setDelegationFee(100); | ||
} | ||
|
||
function test_setDelegationFee() public { | ||
vm.prank(deployer); | ||
bot.setDelegationFee(100); | ||
assertEq(bot.delegationFee(), 100); | ||
} | ||
|
||
function test_withdrawBNB() public { | ||
vm.prank(user); | ||
uint amount = 100; | ||
bot.withdrawTo{value: withdrawFee + amount}(LEGACY_ERC20_ETH, user, amount, 200000, ""); | ||
} | ||
|
||
function test_ERC20() public { | ||
uint amount = 100; | ||
uint balanceBefore = IERC20(usdt).balanceOf(user); | ||
console2.log("balanceBefore", balanceBefore); | ||
vm.prank(user); | ||
IERC20(usdt).approve(address(bot), amount); | ||
vm.prank(user); | ||
bot.withdrawTo{value: withdrawFee}(usdt, user, amount, 200000, ""); | ||
} | ||
} |