From bb2828c55bae99652e757da19aea956224cc6764 Mon Sep 17 00:00:00 2001 From: CJ42 Date: Mon, 21 Oct 2024 08:13:48 +0200 Subject: [PATCH] chore: remove duplicate remapping + re-use already defined test variable --- foundry.toml | 92 ++++++++++++++++++++++------------------------ test/HypLSP7.t.sol | 23 +++++------- 2 files changed, 54 insertions(+), 61 deletions(-) diff --git a/foundry.toml b/foundry.toml index e8bb305..6746770 100644 --- a/foundry.toml +++ b/foundry.toml @@ -1,59 +1,55 @@ # Full reference https://github.com/foundry-rs/foundry/tree/master/crates/config [profile.default] - auto_detect_solc = false - block_timestamp = 1_680_220_800 # March 31, 2023 at 00:00 GMT - bytecode_hash = "none" - evm_version = "shanghai" - fuzz = { runs = 1_000 } - gas_reports = ["*"] - optimizer = true - optimizer_runs = 10_000 - out = "out" - script = "script" - solc = "0.8.25" - src = "src" - test = "test" - -remappings = [ - "forge-std/=node_modules/forge-std/src/" -] +auto_detect_solc = false +block_timestamp = 1_680_220_800 # March 31, 2023 at 00:00 GMT +bytecode_hash = "none" +evm_version = "shanghai" +fuzz = { runs = 1_000 } +gas_reports = ["*"] +optimizer = true +optimizer_runs = 10_000 +out = "out" +script = "script" +solc = "0.8.25" +src = "src" +test = "test" [profile.ci] - fuzz = { runs = 10_000 } - verbosity = 4 +fuzz = { runs = 10_000 } +verbosity = 4 [etherscan] - arbitrum = { key = "${API_KEY_ARBISCAN}" } - avalanche = { key = "${API_KEY_SNOWTRACE}" } - base = { key = "${API_KEY_BASESCAN}" } - bnb_smart_chain = { key = "${API_KEY_BSCSCAN}" } - gnosis_chain = { key = "${API_KEY_GNOSISSCAN}" } - goerli = { key = "${API_KEY_ETHERSCAN}" } - mainnet = { key = "${API_KEY_ETHERSCAN}" } - optimism = { key = "${API_KEY_OPTIMISTIC_ETHERSCAN}" } - polygon = { key = "${API_KEY_POLYGONSCAN}" } - sepolia = { key = "${API_KEY_ETHERSCAN}" } +arbitrum = { key = "${API_KEY_ARBISCAN}" } +avalanche = { key = "${API_KEY_SNOWTRACE}" } +base = { key = "${API_KEY_BASESCAN}" } +bnb_smart_chain = { key = "${API_KEY_BSCSCAN}" } +gnosis_chain = { key = "${API_KEY_GNOSISSCAN}" } +goerli = { key = "${API_KEY_ETHERSCAN}" } +mainnet = { key = "${API_KEY_ETHERSCAN}" } +optimism = { key = "${API_KEY_OPTIMISTIC_ETHERSCAN}" } +polygon = { key = "${API_KEY_POLYGONSCAN}" } +sepolia = { key = "${API_KEY_ETHERSCAN}" } [fmt] - bracket_spacing = true - int_types = "long" - line_length = 120 - multiline_func_header = "all" - number_underscore = "thousands" - quote_style = "double" - tab_width = 4 - wrap_comments = true +bracket_spacing = true +int_types = "long" +line_length = 120 +multiline_func_header = "all" +number_underscore = "thousands" +quote_style = "double" +tab_width = 4 +wrap_comments = true [rpc_endpoints] - arbitrum = "https://arbitrum-mainnet.infura.io/v3/${API_KEY_INFURA}" - avalanche = "https://avalanche-mainnet.infura.io/v3/${API_KEY_INFURA}" - base = "https://mainnet.base.org" - bnb_smart_chain = "https://bsc-dataseed.binance.org" - gnosis_chain = "https://rpc.gnosischain.com" - goerli = "https://goerli.infura.io/v3/${API_KEY_INFURA}" - localhost = "http://localhost:8545" - mainnet = "https://eth-mainnet.g.alchemy.com/v2/${API_KEY_ALCHEMY}" - optimism = "https://optimism-mainnet.infura.io/v3/${API_KEY_INFURA}" - polygon = "https://polygon-mainnet.infura.io/v3/${API_KEY_INFURA}" - sepolia = "https://sepolia.infura.io/v3/${API_KEY_INFURA}" +arbitrum = "https://arbitrum-mainnet.infura.io/v3/${API_KEY_INFURA}" +avalanche = "https://avalanche-mainnet.infura.io/v3/${API_KEY_INFURA}" +base = "https://mainnet.base.org" +bnb_smart_chain = "https://bsc-dataseed.binance.org" +gnosis_chain = "https://rpc.gnosischain.com" +goerli = "https://goerli.infura.io/v3/${API_KEY_INFURA}" +localhost = "http://localhost:8545" +mainnet = "https://eth-mainnet.g.alchemy.com/v2/${API_KEY_ALCHEMY}" +optimism = "https://optimism-mainnet.infura.io/v3/${API_KEY_INFURA}" +polygon = "https://polygon-mainnet.infura.io/v3/${API_KEY_INFURA}" +sepolia = "https://sepolia.infura.io/v3/${API_KEY_INFURA}" diff --git a/test/HypLSP7.t.sol b/test/HypLSP7.t.sol index 796136a..6acfdc5 100644 --- a/test/HypLSP7.t.sol +++ b/test/HypLSP7.t.sol @@ -76,7 +76,7 @@ abstract contract HypTokenTest is Test { remoteToken.enrollRemoteRouter(ORIGIN, address(localToken).addressToBytes32()); } - function _expectRemoteBalance(address _user, uint256 _balance) internal { + function _expectRemoteBalance(address _user, uint256 _balance) internal view { assertEq(remoteToken.balanceOf(_user), _balance); } @@ -143,38 +143,35 @@ contract HypLSP7Test is HypTokenTest { HypLSP7 internal lsp7Token; - address internal owner = makeAddr("owner"); - function setUp() public override { super.setUp(); localToken = new HypLSP7(DECIMALS, address(localMailbox)); lsp7Token = HypLSP7(payable(address(localToken))); - vm.prank(owner); - lsp7Token.initialize(TOTAL_SUPPLY, NAME, SYMBOL, address(noopHook), address(0), owner); + vm.prank(OWNER); + lsp7Token.initialize(TOTAL_SUPPLY, NAME, SYMBOL, address(noopHook), address(0), OWNER); - vm.prank(owner); + vm.prank(OWNER); lsp7Token.enrollRemoteRouter(DESTINATION, address(remoteToken).addressToBytes32()); // from, to, amount, force, data - vm.prank(owner); - - lsp7Token.transfer(owner, ALICE, 1000e18, true, ""); + vm.prank(OWNER); + lsp7Token.transfer(OWNER, ALICE, 1000e18, true, ""); _enrollRemoteTokenRouter(); } function testInitialize_revert_ifAlreadyInitialized() public { vm.expectRevert("Initializable: contract is already initialized"); - lsp7Token.initialize(TOTAL_SUPPLY, NAME, SYMBOL, address(noopHook), address(0), owner); + lsp7Token.initialize(TOTAL_SUPPLY, NAME, SYMBOL, address(noopHook), address(0), OWNER); } - function testTotalSupply() public { + function testTotalSupply() public view { assertEq(lsp7Token.totalSupply(), TOTAL_SUPPLY); } - function testDecimals() public { + function testDecimals() public view { assertEq(lsp7Token.decimals(), DECIMALS); } @@ -189,7 +186,7 @@ contract HypLSP7Test is HypTokenTest { } function testRemoteTransfer() public { - vm.prank(owner); + vm.prank(OWNER); remoteToken.enrollRemoteRouter(ORIGIN, address(localToken).addressToBytes32()); uint256 balanceBefore = lsp7Token.balanceOf(ALICE);