-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CCIP-4114 refactor token pool tests for one function per file (#15119)
* refactor for one function per file * better align naming convention with source code * rename allowList test files * modify file name for more accuracy * fix compiler bugs that weren't caught for some reason
- Loading branch information
1 parent
0b38fca
commit dc5c1ec
Showing
51 changed files
with
4,432 additions
and
3,035 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
26 changes: 6 additions & 20 deletions
26
...ip/test/pools/BurnFromMintTokenPool.t.sol → ...ol/BurnFromMintTokenPool.lockOrBurn.t.sol
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
18 changes: 18 additions & 0 deletions
18
contracts/src/v0.8/ccip/test/pools/BurnFromMintTokenPool/BurnFromMintTokenPoolSetup.t.sol
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,18 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity 0.8.24; | ||
|
||
import {BurnFromMintTokenPool} from "../../../pools/BurnFromMintTokenPool.sol"; | ||
import {BurnMintSetup} from "../BurnMintTokenPool/BurnMintSetup.t.sol"; | ||
|
||
contract BurnFromMintTokenPoolSetup is BurnMintSetup { | ||
BurnFromMintTokenPool internal s_pool; | ||
|
||
function setUp() public virtual override { | ||
BurnMintSetup.setUp(); | ||
|
||
s_pool = new BurnFromMintTokenPool(s_burnMintERC677, new address[](0), address(s_mockRMN), address(s_sourceRouter)); | ||
s_burnMintERC677.grantMintAndBurnRoles(address(s_pool)); | ||
|
||
_applyChainUpdates(address(s_pool)); | ||
} | ||
} |
10 changes: 5 additions & 5 deletions
10
.../v0.8/ccip/test/pools/BurnMintSetup.t.sol → ...ols/BurnMintTokenPool/BurnMintSetup.t.sol
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
90 changes: 90 additions & 0 deletions
90
contracts/src/v0.8/ccip/test/pools/BurnMintTokenPool/BurnMintTokenPool.releaseOrMint.t.sol
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,90 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity 0.8.24; | ||
|
||
import {Pool} from "../../../libraries/Pool.sol"; | ||
import {BurnMintTokenPool} from "../../../pools/BurnMintTokenPool.sol"; | ||
import {TokenPool} from "../../../pools/TokenPool.sol"; | ||
import {BurnMintSetup} from "./BurnMintSetup.t.sol"; | ||
|
||
import {IERC20} from "../../../../vendor/openzeppelin-solidity/v4.8.3/contracts/token/ERC20/IERC20.sol"; | ||
|
||
contract BurnMintTokenPoolSetup is BurnMintSetup { | ||
BurnMintTokenPool internal s_pool; | ||
|
||
function setUp() public virtual override { | ||
BurnMintSetup.setUp(); | ||
|
||
s_pool = new BurnMintTokenPool(s_burnMintERC677, new address[](0), address(s_mockRMN), address(s_sourceRouter)); | ||
s_burnMintERC677.grantMintAndBurnRoles(address(s_pool)); | ||
|
||
_applyChainUpdates(address(s_pool)); | ||
} | ||
} | ||
|
||
contract BurnMintTokenPool_releaseOrMint is BurnMintTokenPoolSetup { | ||
function test_PoolMint_Success() public { | ||
uint256 amount = 1e19; | ||
address receiver = makeAddr("receiver_address"); | ||
|
||
vm.startPrank(s_burnMintOffRamp); | ||
|
||
vm.expectEmit(); | ||
emit IERC20.Transfer(address(0), receiver, amount); | ||
|
||
s_pool.releaseOrMint( | ||
Pool.ReleaseOrMintInV1({ | ||
originalSender: bytes(""), | ||
receiver: receiver, | ||
amount: amount, | ||
localToken: address(s_burnMintERC677), | ||
remoteChainSelector: DEST_CHAIN_SELECTOR, | ||
sourcePoolAddress: abi.encode(s_remoteBurnMintPool), | ||
sourcePoolData: "", | ||
offchainTokenData: "" | ||
}) | ||
); | ||
|
||
assertEq(s_burnMintERC677.balanceOf(receiver), amount); | ||
} | ||
|
||
function test_PoolMintNotHealthy_Revert() public { | ||
// Should not mint tokens if cursed. | ||
s_mockRMN.setGlobalCursed(true); | ||
uint256 before = s_burnMintERC677.balanceOf(OWNER); | ||
vm.startPrank(s_burnMintOffRamp); | ||
|
||
vm.expectRevert(TokenPool.CursedByRMN.selector); | ||
s_pool.releaseOrMint( | ||
Pool.ReleaseOrMintInV1({ | ||
originalSender: bytes(""), | ||
receiver: OWNER, | ||
amount: 1e5, | ||
localToken: address(s_burnMintERC677), | ||
remoteChainSelector: DEST_CHAIN_SELECTOR, | ||
sourcePoolAddress: _generateSourceTokenData().sourcePoolAddress, | ||
sourcePoolData: _generateSourceTokenData().extraData, | ||
offchainTokenData: "" | ||
}) | ||
); | ||
|
||
assertEq(s_burnMintERC677.balanceOf(OWNER), before); | ||
} | ||
|
||
function test_ChainNotAllowed_Revert() public { | ||
uint64 wrongChainSelector = 8838833; | ||
|
||
vm.expectRevert(abi.encodeWithSelector(TokenPool.ChainNotAllowed.selector, wrongChainSelector)); | ||
s_pool.releaseOrMint( | ||
Pool.ReleaseOrMintInV1({ | ||
originalSender: bytes(""), | ||
receiver: OWNER, | ||
amount: 1, | ||
localToken: address(s_burnMintERC677), | ||
remoteChainSelector: wrongChainSelector, | ||
sourcePoolAddress: _generateSourceTokenData().sourcePoolAddress, | ||
sourcePoolData: _generateSourceTokenData().extraData, | ||
offchainTokenData: "" | ||
}) | ||
); | ||
} | ||
} |
Oops, something went wrong.