forked from evmos/ethermint
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(rpc): patch gas used api for block less than upgrade height (evmo…
…s#1557) * patch gas used api for block less than upgrade height * configurable fix-revert-gas-refund-height * add test * fix flag * update dep * set default FixRevertGasRefundHeight * minor comments fix * fix lint Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com> Co-authored-by: Freddy Caceres <facs95@gmail.com>
- Loading branch information
1 parent
48c2a72
commit ea0134c
Showing
7 changed files
with
131 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package backend | ||
|
||
import ( | ||
"fmt" | ||
"math/big" | ||
|
||
ethermint "github.com/evmos/ethermint/types" | ||
) | ||
|
||
func (suite *BackendTestSuite) TestGetGasUsed() { | ||
origin := suite.backend.cfg.JSONRPC.FixRevertGasRefundHeight | ||
testCases := []struct { | ||
name string | ||
fixRevertGasRefundHeight int64 | ||
txResult *ethermint.TxResult | ||
price *big.Int | ||
gas uint64 | ||
exp uint64 | ||
}{ | ||
{ | ||
"success txResult", | ||
1, | ||
ðermint.TxResult{ | ||
Height: 1, | ||
Failed: false, | ||
GasUsed: 53026, | ||
}, | ||
new(big.Int).SetUint64(0), | ||
0, | ||
53026, | ||
}, | ||
{ | ||
"fail txResult before cap", | ||
2, | ||
ðermint.TxResult{ | ||
Height: 1, | ||
Failed: true, | ||
GasUsed: 53026, | ||
}, | ||
new(big.Int).SetUint64(200000), | ||
5000000000000, | ||
1000000000000000000, | ||
}, | ||
{ | ||
"fail txResult after cap", | ||
2, | ||
ðermint.TxResult{ | ||
Height: 3, | ||
Failed: true, | ||
GasUsed: 53026, | ||
}, | ||
new(big.Int).SetUint64(200000), | ||
5000000000000, | ||
53026, | ||
}, | ||
} | ||
for _, tc := range testCases { | ||
suite.Run(fmt.Sprintf("Case %s", tc.name), func() { | ||
suite.backend.cfg.JSONRPC.FixRevertGasRefundHeight = tc.fixRevertGasRefundHeight | ||
suite.Require().Equal(tc.exp, suite.backend.GetGasUsed(tc.txResult, tc.price, tc.gas)) | ||
suite.backend.cfg.JSONRPC.FixRevertGasRefundHeight = origin | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters