Skip to content

Commit

Permalink
Burner tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yahgwai committed Aug 27, 2024
1 parent 94d1194 commit 893f40d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/express-lane-auction/Burner.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@ pragma solidity ^0.8.0;
import {
ERC20BurnableUpgradeable
} from "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20BurnableUpgradeable.sol";
import "./Errors.sol";

/// @notice A simple contract that can burn any tokens that are transferred to it
contract Burner {
ERC20BurnableUpgradeable public immutable token;

constructor(address _token) {
if (_token == address(0)) {
revert ZeroAddress();
}
token = ERC20BurnableUpgradeable(_token);
}

Expand Down
1 change: 1 addition & 0 deletions src/express-lane-auction/Errors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ error RoundTooLong(uint64 roundDurationSeconds);
error ZeroAuctionClosingSeconds();
error NegativeOffset();
error NegativeRoundStart(int64 roundStart);
error ZeroAddress();
5 changes: 5 additions & 0 deletions test/foundry/ExpressLaneBurner.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
ERC20BurnableUpgradeable
} from "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20BurnableUpgradeable.sol";
import {Burner} from "../../src/express-lane-auction/Burner.sol";
import "../../src/express-lane-auction/Errors.sol";

contract MockERC20 is ERC20BurnableUpgradeable {
function initialize() public initializer {
Expand All @@ -18,9 +19,13 @@ contract ExpressLaneBurner is Test {
event Transfer(address indexed from, address indexed to, uint256 value);

function testBurn() public {
vm.expectRevert(ZeroAddress.selector);
new Burner(address(0));

MockERC20 erc20 = new MockERC20();
erc20.initialize();
Burner burner = new Burner(address(erc20));
assertEq(address(burner.token()), address(erc20));

erc20.transfer(address(burner), 20);

Expand Down

0 comments on commit 893f40d

Please sign in to comment.