Skip to content

Commit

Permalink
fix: mock and expect mint and burn
Browse files Browse the repository at this point in the history
  • Loading branch information
agusduha committed Aug 8, 2024
1 parent 8c1b387 commit 0f82686
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions packages/contracts-bedrock/test/L2/L2StandardBridgeInterop.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -193,17 +193,13 @@ contract L2StandardBridgeInterop_LegacyToSuper_Test is L2StandardBridgeInterop_T
_mockDeployments(address(l2OptimismMintableERC20Factory), _from, _remoteToken);
_mockDeployments(Predeploys.OPTIMISM_SUPERCHAIN_ERC20_FACTORY, _to, _remoteToken);

// Mock the `burn` and `mint` functions
vm.mockCall(_from, abi.encodeWithSelector(MintableAndBurnable.burn.selector, _caller, _amount), abi.encode());
vm.mockCall(_to, abi.encodeWithSelector(MintableAndBurnable.mint.selector, _caller, _amount), abi.encode());

// Expect the `Converted` event to be emitted
vm.expectEmit(true, true, true, true, address(l2StandardBridge));
emit Converted(_from, _to, _caller, _amount);

// Expect the `mint` and `burn` functions to be called
vm.expectCall(_from, abi.encodeWithSelector(MintableAndBurnable.burn.selector, _caller, _amount), 1);
vm.expectCall(_to, abi.encodeWithSelector(MintableAndBurnable.mint.selector, _caller, _amount), 1);
// Mock and expect the `burn` and `mint` functions
_mockAndExpect(_from, abi.encodeWithSelector(MintableAndBurnable.burn.selector, _caller, _amount), abi.encode());
_mockAndExpect(_to, abi.encodeWithSelector(MintableAndBurnable.mint.selector, _caller, _amount), abi.encode());

// Act
vm.prank(_caller);
Expand Down Expand Up @@ -346,17 +342,13 @@ contract L2StandardBridgeInterop_SuperToLegacy_Test is L2StandardBridgeInterop_T
_mockDeployments(address(l2OptimismMintableERC20Factory), _to, _remoteToken);
_mockDeployments(Predeploys.OPTIMISM_SUPERCHAIN_ERC20_FACTORY, _from, _remoteToken);

// Mock the `burn` and `mint` functions
vm.mockCall(_from, abi.encodeWithSelector(MintableAndBurnable.burn.selector, _caller, _amount), abi.encode());
vm.mockCall(_to, abi.encodeWithSelector(MintableAndBurnable.mint.selector, _caller, _amount), abi.encode());

// Expect the `Converted` event to be emitted
vm.expectEmit(true, true, true, true, address(l2StandardBridge));
emit Converted(_from, _to, _caller, _amount);

// Expect the `mint` and `burn` functions to be called
vm.expectCall(_from, abi.encodeWithSelector(MintableAndBurnable.burn.selector, _caller, _amount), 1);
vm.expectCall(_to, abi.encodeWithSelector(MintableAndBurnable.mint.selector, _caller, _amount), 1);
// Mock and expect the `burn` and `mint` functions
_mockAndExpect(_from, abi.encodeWithSelector(MintableAndBurnable.burn.selector, _caller, _amount), abi.encode());
_mockAndExpect(_to, abi.encodeWithSelector(MintableAndBurnable.mint.selector, _caller, _amount), abi.encode());

// Act
vm.prank(_caller);
Expand Down

0 comments on commit 0f82686

Please sign in to comment.