Skip to content

Commit

Permalink
replace ERC677 with ERC20 in tests that don't need it.
Browse files Browse the repository at this point in the history
  • Loading branch information
jhweintraub committed Nov 6, 2024
1 parent fb77e5b commit 0744916
Show file tree
Hide file tree
Showing 14 changed files with 142 additions and 141 deletions.
136 changes: 68 additions & 68 deletions contracts/gas-snapshots/ccip.gas-snapshot

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions contracts/scripts/native_solc_compile_all_ccip
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ compileContract ccip/tokenAdminRegistry/RegistryModuleOwnerCustom.sol
compileContract ccip/capability/CCIPHome.sol
compileContract ccip/NonceManager.sol
compileContract shared/token/ERC677/BurnMintERC677.sol
compileContract shared/token/ERC20/BurnMintERC20.sol


# Pools
Expand Down
10 changes: 5 additions & 5 deletions contracts/src/v0.8/ccip/test/TokenSetup.t.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.24;

import {BurnMintERC677} from "../../shared/token/ERC677/BurnMintERC677.sol";
import {BurnMintERC20} from "../../shared/token/ERC20/BurnMintERC20.sol";
import {Client} from "../libraries/Client.sol";
import {BurnMintTokenPool} from "../pools/BurnMintTokenPool.sol";
import {LockReleaseTokenPool} from "../pools/LockReleaseTokenPool.sol";
Expand All @@ -27,14 +27,14 @@ contract TokenSetup is RouterSetup {
mapping(address sourceToken => address destToken) internal s_destTokenBySourceToken;

function _deploySourceToken(string memory tokenName, uint256 dealAmount, uint8 decimals) internal returns (address) {
BurnMintERC677 token = new BurnMintERC677(tokenName, tokenName, decimals, 0);
BurnMintERC20 token = new BurnMintERC20(tokenName, tokenName, decimals, 0, 0);
s_sourceTokens.push(address(token));
deal(address(token), OWNER, dealAmount);
return address(token);
}

function _deployDestToken(string memory tokenName, uint256 dealAmount) internal returns (address) {
BurnMintERC677 token = new BurnMintERC677(tokenName, tokenName, 18, 0);
BurnMintERC20 token = new BurnMintERC20(tokenName, tokenName, 18, 0, 0);
s_destTokens.push(address(token));
deal(address(token), OWNER, dealAmount);
return address(token);
Expand Down Expand Up @@ -64,8 +64,8 @@ contract TokenSetup is RouterSetup {
}

BurnMintTokenPool pool =
new MaybeRevertingBurnMintTokenPool(BurnMintERC677(token), new address[](0), address(s_mockRMN), router);
BurnMintERC677(token).grantMintAndBurnRoles(address(pool));
new MaybeRevertingBurnMintTokenPool(BurnMintERC20(token), new address[](0), address(s_mockRMN), router);
BurnMintERC20(token).grantMintAndBurnRoles(address(pool));

if (isSourcePool) {
s_sourcePoolByToken[address(token)] = address(pool);
Expand Down
6 changes: 3 additions & 3 deletions contracts/src/v0.8/ccip/test/mocks/MockE2EUSDCTransmitter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pragma solidity ^0.8.0;

import {IMessageTransmitterWithRelay} from "./interfaces/IMessageTransmitterWithRelay.sol";

import {BurnMintERC677} from "../../../shared/token/ERC677/BurnMintERC677.sol";
import {BurnMintERC20} from "../../../shared/token/ERC20/BurnMintERC20.sol";

// solhint-disable
contract MockE2EUSDCTransmitter is IMessageTransmitterWithRelay {
Expand All @@ -28,7 +28,7 @@ contract MockE2EUSDCTransmitter is IMessageTransmitterWithRelay {
// Next available nonce from this source domain
uint64 public nextAvailableNonce;

BurnMintERC677 internal immutable i_token;
BurnMintERC20 internal immutable i_token;

/**
* @notice Emitted when a new message is dispatched
Expand All @@ -41,7 +41,7 @@ contract MockE2EUSDCTransmitter is IMessageTransmitterWithRelay {
i_localDomain = _localDomain;
s_shouldSucceed = true;

i_token = BurnMintERC677(token);
i_token = BurnMintERC20(token);
}

/// @param message The original message on the source chain
Expand Down
6 changes: 3 additions & 3 deletions contracts/src/v0.8/ccip/test/onRamp/OnRamp.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {IRMNRemote} from "../../interfaces/IRMNRemote.sol";
import {IRouter} from "../../interfaces/IRouter.sol";

import {Ownable2Step} from "../../../shared/access/Ownable2Step.sol";
import {BurnMintERC677} from "../../../shared/token/ERC677/BurnMintERC677.sol";
import {BurnMintERC20} from "../../../shared/token/ERC20/BurnMintERC20.sol";
import {FeeQuoter} from "../../FeeQuoter.sol";
import {Client} from "../../libraries/Client.sol";
import {Internal} from "../../libraries/Internal.sol";
Expand Down Expand Up @@ -532,9 +532,9 @@ contract OnRamp_forwardFromRouter is OnRampSetup {
vm.startPrank(OWNER);

MaybeRevertingBurnMintTokenPool newPool = new MaybeRevertingBurnMintTokenPool(
BurnMintERC677(sourceETH), new address[](0), address(s_mockRMNRemote), address(s_sourceRouter)
BurnMintERC20(sourceETH), new address[](0), address(s_mockRMNRemote), address(s_sourceRouter)
);
BurnMintERC677(sourceETH).grantMintAndBurnRoles(address(newPool));
BurnMintERC20(sourceETH).grantMintAndBurnRoles(address(newPool));
deal(address(sourceETH), address(newPool), type(uint256).max);

// Add TokenPool to OnRamp
Expand Down
26 changes: 13 additions & 13 deletions contracts/src/v0.8/ccip/test/pools/BurnFromMintTokenPool.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,27 @@ contract BurnFromMintTokenPoolSetup is BurnMintSetup {
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));
s_pool = new BurnFromMintTokenPool(s_burnMintERC20, new address[](0), address(s_mockRMN), address(s_sourceRouter));
s_burnMintERC20.grantMintAndBurnRoles(address(s_pool));

_applyChainUpdates(address(s_pool));
}
}

contract BurnFromMintTokenPool_lockOrBurn is BurnFromMintTokenPoolSetup {
function test_Setup_Success() public view {
assertEq(address(s_burnMintERC677), address(s_pool.getToken()));
assertEq(address(s_burnMintERC20), address(s_pool.getToken()));
assertEq(address(s_mockRMN), s_pool.getRmnProxy());
assertEq(false, s_pool.getAllowListEnabled());
assertEq(type(uint256).max, s_burnMintERC677.allowance(address(s_pool), address(s_pool)));
assertEq(type(uint256).max, s_burnMintERC20.allowance(address(s_pool), address(s_pool)));
assertEq("BurnFromMintTokenPool 1.5.0", s_pool.typeAndVersion());
}

function test_PoolBurn_Success() public {
uint256 burnAmount = 20_000e18;

deal(address(s_burnMintERC677), address(s_pool), burnAmount);
assertEq(s_burnMintERC677.balanceOf(address(s_pool)), burnAmount);
deal(address(s_burnMintERC20), address(s_pool), burnAmount);
assertEq(s_burnMintERC20.balanceOf(address(s_pool)), burnAmount);

vm.startPrank(s_burnMintOnRamp);

Expand All @@ -49,25 +49,25 @@ contract BurnFromMintTokenPool_lockOrBurn is BurnFromMintTokenPoolSetup {
emit TokenPool.Burned(address(s_burnMintOnRamp), burnAmount);

bytes4 expectedSignature = bytes4(keccak256("burnFrom(address,uint256)"));
vm.expectCall(address(s_burnMintERC677), abi.encodeWithSelector(expectedSignature, address(s_pool), burnAmount));
vm.expectCall(address(s_burnMintERC20), abi.encodeWithSelector(expectedSignature, address(s_pool), burnAmount));

s_pool.lockOrBurn(
Pool.LockOrBurnInV1({
originalSender: OWNER,
receiver: bytes(""),
amount: burnAmount,
remoteChainSelector: DEST_CHAIN_SELECTOR,
localToken: address(s_burnMintERC677)
localToken: address(s_burnMintERC20)
})
);

assertEq(s_burnMintERC677.balanceOf(address(s_pool)), 0);
assertEq(s_burnMintERC20.balanceOf(address(s_pool)), 0);
}

// Should not burn tokens if cursed.
function test_PoolBurnRevertNotHealthy_Revert() public {
s_mockRMN.setGlobalCursed(true);
uint256 before = s_burnMintERC677.balanceOf(address(s_pool));
uint256 before = s_burnMintERC20.balanceOf(address(s_pool));
vm.startPrank(s_burnMintOnRamp);

vm.expectRevert(TokenPool.CursedByRMN.selector);
Expand All @@ -77,11 +77,11 @@ contract BurnFromMintTokenPool_lockOrBurn is BurnFromMintTokenPoolSetup {
receiver: bytes(""),
amount: 1e5,
remoteChainSelector: DEST_CHAIN_SELECTOR,
localToken: address(s_burnMintERC677)
localToken: address(s_burnMintERC20)
})
);

assertEq(s_burnMintERC677.balanceOf(address(s_pool)), before);
assertEq(s_burnMintERC20.balanceOf(address(s_pool)), before);
}

function test_ChainNotAllowed_Revert() public {
Expand All @@ -92,7 +92,7 @@ contract BurnFromMintTokenPool_lockOrBurn is BurnFromMintTokenPoolSetup {
originalSender: bytes(""),
receiver: OWNER,
amount: 1,
localToken: address(s_burnMintERC677),
localToken: address(s_burnMintERC20),
remoteChainSelector: wrongChainSelector,
sourcePoolAddress: _generateSourceTokenData().sourcePoolAddress,
sourcePoolData: _generateSourceTokenData().extraData,
Expand Down
6 changes: 3 additions & 3 deletions contracts/src/v0.8/ccip/test/pools/BurnMintSetup.t.sol
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.24;

import {BurnMintERC677} from "../../../shared/token/ERC677/BurnMintERC677.sol";
import {BurnMintERC20} from "../../../shared/token/ERC20/BurnMintERC20.sol";
import {Router} from "../../Router.sol";
import {BurnMintTokenPool} from "../../pools/BurnMintTokenPool.sol";
import {TokenPool} from "../../pools/TokenPool.sol";
import {RouterSetup} from "../router/RouterSetup.t.sol";

contract BurnMintSetup is RouterSetup {
BurnMintERC677 internal s_burnMintERC677;
BurnMintERC20 internal s_burnMintERC20;
address internal s_burnMintOffRamp = makeAddr("burn_mint_offRamp");
address internal s_burnMintOnRamp = makeAddr("burn_mint_onRamp");

Expand All @@ -18,7 +18,7 @@ contract BurnMintSetup is RouterSetup {
function setUp() public virtual override {
RouterSetup.setUp();

s_burnMintERC677 = new BurnMintERC677("Chainlink Token", "LINK", 18, 0);
s_burnMintERC20 = new BurnMintERC20("Chainlink Token", "LINK", 18, 0, 0);
}

function _applyChainUpdates(
Expand Down
36 changes: 18 additions & 18 deletions contracts/src/v0.8/ccip/test/pools/BurnMintTokenPool.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ contract BurnMintTokenPoolSetup is BurnMintSetup {
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));
s_pool = new BurnMintTokenPool(s_burnMintERC20, new address[](0), address(s_mockRMN), address(s_sourceRouter));
s_burnMintERC20.grantMintAndBurnRoles(address(s_pool));

_applyChainUpdates(address(s_pool));
}
}

contract BurnMintTokenPool_lockOrBurn is BurnMintTokenPoolSetup {
function test_Setup_Success() public view {
assertEq(address(s_burnMintERC677), address(s_pool.getToken()));
assertEq(address(s_burnMintERC20), address(s_pool.getToken()));
assertEq(address(s_mockRMN), s_pool.getRmnProxy());
assertEq(false, s_pool.getAllowListEnabled());
assertEq("BurnMintTokenPool 1.5.0", s_pool.typeAndVersion());
Expand All @@ -33,8 +33,8 @@ contract BurnMintTokenPool_lockOrBurn is BurnMintTokenPoolSetup {
function test_PoolBurn_Success() public {
uint256 burnAmount = 20_000e18;

deal(address(s_burnMintERC677), address(s_pool), burnAmount);
assertEq(s_burnMintERC677.balanceOf(address(s_pool)), burnAmount);
deal(address(s_burnMintERC20), address(s_pool), burnAmount);
assertEq(s_burnMintERC20.balanceOf(address(s_pool)), burnAmount);

vm.startPrank(s_burnMintOnRamp);

Expand All @@ -48,25 +48,25 @@ contract BurnMintTokenPool_lockOrBurn is BurnMintTokenPoolSetup {
emit TokenPool.Burned(address(s_burnMintOnRamp), burnAmount);

bytes4 expectedSignature = bytes4(keccak256("burn(uint256)"));
vm.expectCall(address(s_burnMintERC677), abi.encodeWithSelector(expectedSignature, burnAmount));
vm.expectCall(address(s_burnMintERC20), abi.encodeWithSelector(expectedSignature, burnAmount));

s_pool.lockOrBurn(
Pool.LockOrBurnInV1({
originalSender: OWNER,
receiver: bytes(""),
amount: burnAmount,
remoteChainSelector: DEST_CHAIN_SELECTOR,
localToken: address(s_burnMintERC677)
localToken: address(s_burnMintERC20)
})
);

assertEq(s_burnMintERC677.balanceOf(address(s_pool)), 0);
assertEq(s_burnMintERC20.balanceOf(address(s_pool)), 0);
}

// Should not burn tokens if cursed.
function test_PoolBurnRevertNotHealthy_Revert() public {
s_mockRMN.setGlobalCursed(true);
uint256 before = s_burnMintERC677.balanceOf(address(s_pool));
uint256 before = s_burnMintERC20.balanceOf(address(s_pool));
vm.startPrank(s_burnMintOnRamp);

vm.expectRevert(TokenPool.CursedByRMN.selector);
Expand All @@ -76,11 +76,11 @@ contract BurnMintTokenPool_lockOrBurn is BurnMintTokenPoolSetup {
receiver: bytes(""),
amount: 1e5,
remoteChainSelector: DEST_CHAIN_SELECTOR,
localToken: address(s_burnMintERC677)
localToken: address(s_burnMintERC20)
})
);

assertEq(s_burnMintERC677.balanceOf(address(s_pool)), before);
assertEq(s_burnMintERC20.balanceOf(address(s_pool)), before);
}

function test_ChainNotAllowed_Revert() public {
Expand All @@ -93,7 +93,7 @@ contract BurnMintTokenPool_lockOrBurn is BurnMintTokenPoolSetup {
receiver: bytes(""),
amount: 1,
remoteChainSelector: wrongChainSelector,
localToken: address(s_burnMintERC677)
localToken: address(s_burnMintERC20)
})
);
}
Expand All @@ -114,21 +114,21 @@ contract BurnMintTokenPool_releaseOrMint is BurnMintTokenPoolSetup {
originalSender: bytes(""),
receiver: receiver,
amount: amount,
localToken: address(s_burnMintERC677),
localToken: address(s_burnMintERC20),
remoteChainSelector: DEST_CHAIN_SELECTOR,
sourcePoolAddress: abi.encode(s_remoteBurnMintPool),
sourcePoolData: "",
offchainTokenData: ""
})
);

assertEq(s_burnMintERC677.balanceOf(receiver), amount);
assertEq(s_burnMintERC20.balanceOf(receiver), amount);
}

function test_PoolMintNotHealthy_Revert() public {
// Should not mint tokens if cursed.
s_mockRMN.setGlobalCursed(true);
uint256 before = s_burnMintERC677.balanceOf(OWNER);
uint256 before = s_burnMintERC20.balanceOf(OWNER);
vm.startPrank(s_burnMintOffRamp);

vm.expectRevert(TokenPool.CursedByRMN.selector);
Expand All @@ -137,15 +137,15 @@ contract BurnMintTokenPool_releaseOrMint is BurnMintTokenPoolSetup {
originalSender: bytes(""),
receiver: OWNER,
amount: 1e5,
localToken: address(s_burnMintERC677),
localToken: address(s_burnMintERC20),
remoteChainSelector: DEST_CHAIN_SELECTOR,
sourcePoolAddress: _generateSourceTokenData().sourcePoolAddress,
sourcePoolData: _generateSourceTokenData().extraData,
offchainTokenData: ""
})
);

assertEq(s_burnMintERC677.balanceOf(OWNER), before);
assertEq(s_burnMintERC20.balanceOf(OWNER), before);
}

function test_ChainNotAllowed_Revert() public {
Expand All @@ -157,7 +157,7 @@ contract BurnMintTokenPool_releaseOrMint is BurnMintTokenPoolSetup {
originalSender: bytes(""),
receiver: OWNER,
amount: 1,
localToken: address(s_burnMintERC677),
localToken: address(s_burnMintERC20),
remoteChainSelector: wrongChainSelector,
sourcePoolAddress: _generateSourceTokenData().sourcePoolAddress,
sourcePoolData: _generateSourceTokenData().extraData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ contract BurnMintWithLockReleaseFlagTokenPoolSetup is BurnMintSetup {
BurnMintSetup.setUp();

s_pool = new BurnMintWithLockReleaseFlagTokenPool(
s_burnMintERC677, new address[](0), address(s_mockRMN), address(s_sourceRouter)
s_burnMintERC20, new address[](0), address(s_mockRMN), address(s_sourceRouter)
);
s_burnMintERC677.grantMintAndBurnRoles(address(s_pool));
s_burnMintERC20.grantMintAndBurnRoles(address(s_pool));

_applyChainUpdates(address(s_pool));
}
Expand All @@ -30,8 +30,8 @@ contract BurnMintWithLockReleaseFlagTokenPool_lockOrBurn is BurnMintWithLockRele
function test_LockOrBurn_CorrectReturnData_Success() public {
uint256 burnAmount = 20_000e18;

deal(address(s_burnMintERC677), address(s_pool), burnAmount);
assertEq(s_burnMintERC677.balanceOf(address(s_pool)), burnAmount);
deal(address(s_burnMintERC20), address(s_pool), burnAmount);
assertEq(s_burnMintERC20.balanceOf(address(s_pool)), burnAmount);

vm.startPrank(s_burnMintOnRamp);

Expand All @@ -45,19 +45,19 @@ contract BurnMintWithLockReleaseFlagTokenPool_lockOrBurn is BurnMintWithLockRele
emit TokenPool.Burned(address(s_burnMintOnRamp), burnAmount);

bytes4 expectedSignature = bytes4(keccak256("burn(uint256)"));
vm.expectCall(address(s_burnMintERC677), abi.encodeWithSelector(expectedSignature, burnAmount));
vm.expectCall(address(s_burnMintERC20), abi.encodeWithSelector(expectedSignature, burnAmount));

Pool.LockOrBurnOutV1 memory lockOrBurnOut = s_pool.lockOrBurn(
Pool.LockOrBurnInV1({
originalSender: OWNER,
receiver: bytes(""),
amount: burnAmount,
remoteChainSelector: DEST_CHAIN_SELECTOR,
localToken: address(s_burnMintERC677)
localToken: address(s_burnMintERC20)
})
);

assertEq(s_burnMintERC677.balanceOf(address(s_pool)), 0);
assertEq(s_burnMintERC20.balanceOf(address(s_pool)), 0);

assertEq(bytes4(lockOrBurnOut.destPoolData), LOCK_RELEASE_FLAG);
}
Expand Down
Loading

0 comments on commit 0744916

Please sign in to comment.