From 944db01ba1909ed06afed86b3feadf82fdd838b7 Mon Sep 17 00:00:00 2001 From: Daniel Wang Date: Thu, 28 Mar 2024 18:07:50 +0800 Subject: [PATCH] Update Lib1559Math.t.sol --- packages/protocol/test/L2/Lib1559Math.t.sol | 31 +++++++-------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/packages/protocol/test/L2/Lib1559Math.t.sol b/packages/protocol/test/L2/Lib1559Math.t.sol index a4edccf67a..b08f65185f 100644 --- a/packages/protocol/test/L2/Lib1559Math.t.sol +++ b/packages/protocol/test/L2/Lib1559Math.t.sol @@ -7,30 +7,19 @@ contract TestLib1559Math is TaikoTest { using LibMath for uint256; function test_eip1559_math() external { - uint256 gasTarget = 15 * 1e6 * 10; + uint256 gasTarget = 60_000_000; uint256 adjustmentQuotient = 8; uint256 adjustmentFactor = gasTarget * adjustmentQuotient; - // The expected values are calculated in eip1559_util.py - _assertAmostEq( - 999_999_916, - Lib1559Math.basefee({ _gasExcess: 49_954_623_777, _adjustmentFactor: adjustmentFactor }) - ); - _assertAmostEq( - 48_246_703_821_869_050_543_408_253_349_256_099_602_613_005_189_120, - Lib1559Math.basefee({ - _gasExcess: LibFixedPointMath.MAX_EXP_INPUT * adjustmentFactor - / LibFixedPointMath.SCALING_FACTOR, - _adjustmentFactor: adjustmentFactor - }) - ); - } + uint256 baseFee; + uint256 i; + for (; baseFee < 1 gwei; ++i) { + baseFee = Lib1559Math.basefee(gasTarget * i, adjustmentFactor); + console2.log("baseFee:", i, baseFee); + } - // Assert the different between two number is smaller than 1/1000000 - function _assertAmostEq(uint256 _a, uint256 _b) private { - uint256 min = _a.min(_b); - uint256 max = _a.max(_b); - assertTrue(max > 0 && ((max - min) * 1_000_000) / max <= 1); - console2.log(_a, " <> ", _b); + // basefee will reach 1 gwei if gasExcess > 19620000000 + console2.log("basefee will reach 1 gwei if gasExcess >", gasTarget * i); + assertEq(i, 327); } }