-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
3 changed files
with
177 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,21 @@ | ||
BurnTest:testDeployment() (gas: 56874) | ||
BurnTest:test_Burn() (gas: 124436) | ||
BurnTest:testDeployment() (gas: 61274) | ||
BurnTest:test_Burn() (gas: 122496) | ||
BurnTest:test_RevertWhen_SenderIsNotBridge() (gas: 10076) | ||
MintTest:testDeployment() (gas: 56874) | ||
MintTest:test_Mint() (gas: 110237) | ||
ChangeControllerTest:testDeployment() (gas: 43370) | ||
ChangeControllerTest:test_changeController() (gas: 26089) | ||
ClaimTokensTest:testDeployment() (gas: 43574) | ||
ClaimTokensTest:test_ClaimERC20() (gas: 57947) | ||
ClaimTokensTest:test_ClaimETH() (gas: 11558) | ||
ERC165Test:testDeployment() (gas: 61274) | ||
ERC165Test:test_supportInterface() (gas: 7836) | ||
MintTest:testDeployment() (gas: 61274) | ||
MintTest:test_Mint() (gas: 109895) | ||
MintTest:test_RevertWhen_SenderIsNotBridge() (gas: 10076) | ||
OptmismMintableMiniMeTokenTest:testDeployment() (gas: 56874) | ||
OnApproveTest:testDeployment() (gas: 43370) | ||
OnApproveTest:test_onApprove() (gas: 5865) | ||
OnTransferTest:testDeployment() (gas: 43370) | ||
OnTransferTest:test_onTransfer() (gas: 5777) | ||
OptmismMintableMiniMeTokenTest:testDeployment() (gas: 61274) | ||
ProxyPaymentTest:testDeployment() (gas: 43325) | ||
ProxyPaymentTest:test_proxyPayment() (gas: 5666) | ||
SNTOptimismControllerTest:testDeployment() (gas: 43370) |
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,142 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.19; | ||
|
||
import { Test } from "forge-std/Test.sol"; | ||
import { DeployBridge } from "../script/DeployBridge.s.sol"; | ||
import { DeploymentConfig } from "../script/DeploymentConfig.s.sol"; | ||
|
||
import { SNTOptimismController } from "../contracts/SNTOptimismController.sol"; | ||
import { OptimismMintableMiniMeToken } from "../contracts/optimism/OptimismMintableMiniMeToken.sol"; | ||
|
||
import { MiniMeToken } from "@vacp2p/minime/contracts/MiniMeToken.sol"; | ||
|
||
contract SNTOptimismControllerTest is Test { | ||
DeploymentConfig internal deploymentConfig; | ||
SNTOptimismController internal tokenController; | ||
OptimismMintableMiniMeToken internal bridgeToken; | ||
|
||
address internal deployer; | ||
|
||
address internal bridgeAddress; | ||
|
||
function setUp() public virtual { | ||
DeployBridge deployment = new DeployBridge(); | ||
(deploymentConfig, bridgeToken, tokenController) = deployment.run(); | ||
(deployer, bridgeAddress,,,,,,,) = deploymentConfig.activeNetworkConfig(); | ||
} | ||
|
||
function testDeployment() public { | ||
( | ||
, | ||
address _bridgeAddress, | ||
address _remoteTokenAddress, | ||
address _parentTokenAddress, | ||
uint256 _parentSnapShotBlock, | ||
string memory _tokenName, | ||
uint8 _decimals, | ||
string memory _tokenSymbol, | ||
bool _transferEnabled | ||
) = deploymentConfig.activeNetworkConfig(); | ||
|
||
assertEq(bridgeToken.controller(), address(tokenController)); | ||
assertEq(address(tokenController.snt()), address(bridgeToken)); | ||
} | ||
} | ||
|
||
contract ChangeControllerTest is SNTOptimismControllerTest { | ||
function setUp() public virtual override { | ||
SNTOptimismControllerTest.setUp(); | ||
} | ||
|
||
function test_changeController() public { | ||
address payable newController = payable(address(0x123)); | ||
vm.prank(tokenController.owner()); | ||
tokenController.changeController(newController); | ||
assertEq(bridgeToken.controller(), newController); | ||
} | ||
} | ||
|
||
contract ClaimTokensTest is SNTOptimismControllerTest { | ||
function setUp() public virtual override { | ||
SNTOptimismControllerTest.setUp(); | ||
} | ||
|
||
function test_ClaimERC20() public { | ||
vm.pauseGasMetering(); | ||
vm.startPrank(tokenController.owner()); | ||
MiniMeToken claimTest = new MiniMeToken( | ||
MiniMeToken(payable(address(0))), | ||
0, | ||
"TestClaim", | ||
18, | ||
"TST", | ||
true | ||
); | ||
claimTest.generateTokens(address(tokenController), 1234); | ||
|
||
assertEq( | ||
claimTest.balanceOf(address(tokenController)), 1234, "claimTest tokenController balance should be correct" | ||
); | ||
assertEq(claimTest.balanceOf(address(deployer)), 0, "claimTest deployer balance should be correct"); | ||
|
||
vm.resumeGasMetering(); | ||
tokenController.claimTokens(claimTest); | ||
vm.pauseGasMetering(); | ||
|
||
vm.stopPrank(); | ||
|
||
assertEq( | ||
claimTest.balanceOf(address(tokenController)), 0, "claimTest tokenController balance should be correct" | ||
); | ||
assertEq(claimTest.balanceOf(address(deployer)), 1234, "claimTest deployer balance should be correct"); | ||
vm.resumeGasMetering(); | ||
} | ||
|
||
function test_ClaimETH() public { | ||
vm.pauseGasMetering(); | ||
vm.startPrank(tokenController.owner()); | ||
vm.deal(address(tokenController), 1234); | ||
assertEq(address(tokenController).balance, 1234, "tokenController balance should be correct"); | ||
assertEq(address(deployer).balance, 0, "deployer balance should be correct"); | ||
|
||
vm.resumeGasMetering(); | ||
tokenController.claimTokens(MiniMeToken(payable(address(0)))); | ||
vm.pauseGasMetering(); | ||
|
||
assertEq(address(tokenController).balance, 0, "tokenController balance should be correct"); | ||
assertEq(address(deployer).balance, 1234, "deployer balance should be correct"); | ||
|
||
vm.stopPrank(); | ||
vm.resumeGasMetering(); | ||
} | ||
} | ||
|
||
contract OnTransferTest is SNTOptimismControllerTest { | ||
function setUp() public virtual override { | ||
SNTOptimismControllerTest.setUp(); | ||
} | ||
|
||
function test_onTransfer() public { | ||
assertEq(tokenController.onTransfer(address(0), address(0), 0), true); | ||
} | ||
} | ||
|
||
contract OnApproveTest is SNTOptimismControllerTest { | ||
function setUp() public virtual override { | ||
SNTOptimismControllerTest.setUp(); | ||
} | ||
|
||
function test_onApprove() public { | ||
assertEq(tokenController.onApprove(address(0), address(0), 0), true); | ||
} | ||
} | ||
|
||
contract ProxyPaymentTest is SNTOptimismControllerTest { | ||
function setUp() public virtual override { | ||
SNTOptimismControllerTest.setUp(); | ||
} | ||
|
||
function test_proxyPayment() public { | ||
assertEq(tokenController.proxyPayment(address(0)), false); | ||
} | ||
} |