Skip to content

Commit

Permalink
Simple test to include USDC burn in snapshot (#261)
Browse files Browse the repository at this point in the history
  • Loading branch information
matYang authored Nov 7, 2023
1 parent 57d2bca commit 7b19b40
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
7 changes: 4 additions & 3 deletions contracts/gas-snapshots/ccip.gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -399,9 +399,10 @@ TokenProxy_getFee:testGetFeeInvalidTokenReverts() (gas: 12628)
TokenProxy_getFee:testGetFeeNoDataAllowedReverts() (gas: 15775)
TokenProxy_getFee:testGetFeeSuccess() (gas: 74453)
USDCTokenPool__validateMessage:testValidateInvalidMessageReverts() (gas: 25338)
USDCTokenPool_lockOrBurn:testLockOrBurnWithAllowListReverts() (gas: 21968)
USDCTokenPool_lockOrBurn:testPermissionsErrorReverts() (gas: 12498)
USDCTokenPool_lockOrBurn:testUnknownDomainReverts() (gas: 183561)
USDCTokenPool_lockOrBurn:testLockOrBurnSuccess() (gas: 92355)
USDCTokenPool_lockOrBurn:testLockOrBurnWithAllowListReverts() (gas: 21946)
USDCTokenPool_lockOrBurn:testPermissionsErrorReverts() (gas: 12476)
USDCTokenPool_lockOrBurn:testUnknownDomainReverts() (gas: 183544)
USDCTokenPool_releaseOrMint:testReleaseOrMintRealTxSuccess() (gas: 56035)
USDCTokenPool_releaseOrMint:testTokenMaxCapacityExceededReverts() (gas: 27922)
USDCTokenPool_releaseOrMint:testUnlockingUSDCFailedReverts() (gas: 50764)
Expand Down
38 changes: 38 additions & 0 deletions contracts/src/v0.8/ccip/test/pools/USDCTokenPool.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,44 @@ contract USDCTokenPool_lockOrBurn is USDCTokenPoolSetup {
event Burned(address indexed sender, uint256 amount);
event TokensConsumed(uint256 tokens);

// Base test case, included for PR gas comparisons as fuzz tests are excluded from forge snapshot due to being flaky.
function testLockOrBurnSuccess() public {
bytes32 receiver = bytes32(uint256(uint160(STRANGER)));
uint256 amount = 1;
changePrank(s_routerAllowedOnRamp);
s_token.approve(address(s_usdcTokenPool), amount);

USDCTokenPool.Domain memory expectedDomain = s_usdcTokenPool.getDomain(DEST_CHAIN_ID);

vm.expectEmit();
emit TokensConsumed(amount);

vm.expectEmit();
emit DepositForBurn(
s_mockUSDC.s_nonce(),
address(s_token),
amount,
address(s_usdcTokenPool),
receiver,
expectedDomain.domainIdentifier,
s_mockUSDC.i_destinationTokenMessenger(),
expectedDomain.allowedCaller
);

vm.expectEmit();
emit Burned(s_routerAllowedOnRamp, amount);

bytes memory encodedNonce = s_usdcTokenPool.lockOrBurn(
OWNER,
abi.encodePacked(receiver),
amount,
DEST_CHAIN_ID,
bytes("")
);
uint64 nonce = abi.decode(encodedNonce, (uint64));
assertEq(s_mockUSDC.s_nonce() - 1, nonce);
}

function testFuzz_LockOrBurnSuccess(bytes32 destinationReceiver, uint256 amount) public {
vm.assume(amount < rateLimiterConfig().capacity);
vm.assume(amount > 0);
Expand Down

0 comments on commit 7b19b40

Please sign in to comment.