Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
44367b02
Unverified
Commit
44367b02
authored
Nov 23, 2024
by
Michael Amadi
Committed by
GitHub
Nov 23, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add LegacyMintableERC20 tests (#13049)
* add LegacyMintableERC20 tests * fixes
parent
80465cd6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
68 additions
and
0 deletions
+68
-0
LegacyMintableERC20.t.sol
...s/contracts-bedrock/test/legacy/LegacyMintableERC20.t.sol
+68
-0
No files found.
packages/contracts-bedrock/test/legacy/LegacyMintableERC20.t.sol
0 → 100644
View file @
44367b02
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;
// Testing utilities
import { CommonTest } from "test/setup/CommonTest.sol";
import { LegacyMintableERC20 } from "src/legacy/LegacyMintableERC20.sol";
import { ILegacyMintableERC20 } from "src/universal/interfaces/ILegacyMintableERC20.sol";
contract LegacyMintableERC20_Test is CommonTest {
LegacyMintableERC20 legacyMintableERC20;
function setUp() public override {
super.setUp();
legacyMintableERC20 = new LegacyMintableERC20(address(l2StandardBridge), address(L1Token), "_L2Token_", "_L2T_");
}
/// @notice Tests that the constructor sets the correct values
function test_constructor_works() public view {
assertEq(legacyMintableERC20.l2Bridge(), address(l2StandardBridge));
assertEq(legacyMintableERC20.l1Token(), address(L1Token));
assertEq(legacyMintableERC20.name(), "_L2Token_");
assertEq(legacyMintableERC20.symbol(), "_L2T_");
assertEq(legacyMintableERC20.decimals(), 18);
}
/// @notice Tests that the contract supports the correct interfaces
function test_supportsInterface_works() public view {
assertEq(legacyMintableERC20.supportsInterface(bytes4(keccak256("supportsInterface(bytes4)"))), true);
assertEq(
legacyMintableERC20.supportsInterface(
ILegacyMintableERC20.l1Token.selector ^ ILegacyMintableERC20.mint.selector
^ ILegacyMintableERC20.burn.selector
),
true
);
}
/// @notice Tests that the mint function works when called by the bridge
function test_mint_byBridge_succeeds() public {
vm.prank(address(l2StandardBridge));
legacyMintableERC20.mint(address(this), 1000);
assertEq(legacyMintableERC20.balanceOf(address(this)), 1000);
}
/// @notice Tests that the mint function fails when called by an address other than the bridge
function test_mint_byNonBridge_reverts() public {
vm.expectRevert(bytes("Only L2 Bridge can mint and burn"));
legacyMintableERC20.mint(address(this), 1000);
}
/// @notice Tests that the burn function works when called by the bridge
function test_burn_byBridge_succeeds() public {
vm.prank(address(l2StandardBridge));
legacyMintableERC20.mint(address(this), 1000);
vm.prank(address(l2StandardBridge));
legacyMintableERC20.burn(address(this), 1000);
assertEq(legacyMintableERC20.balanceOf(address(this)), 0);
}
/// @notice Tests that the burn function fails when called by an address other than the bridge
function test_burn_byNonBridge_reverts() public {
vm.expectRevert(bytes("Only L2 Bridge can mint and burn"));
legacyMintableERC20.burn(address(this), 1000);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment