-
Notifications
You must be signed in to change notification settings - Fork 97
refactor!: clean up chain config #608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
displayDenom := evmtypes.GetEVMCoinDisplayDenom() | ||
decimals := evmtypes.GetEVMCoinDecimals() | ||
extendedDecimals := evmtypes.GetEVMCoinExtendedDecimals() |
Check warning
Code scanning / CodeQL
Useless assignment to local variable Warning test
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 3 days ago
The function assigns the result of evmtypes.GetEVMCoinExtendedDecimals()
to the extendedDecimals
variable and then immediately uses it as a field value in the struct evmtypes.EvmCoinInfo
. Thereafter, the variable is never referenced, so its assignment is superfluous. The best fix is to eliminate the extendedDecimals
variable completely, and directly use the function call as the value for the ExtendedDecimals
field in evmtypes.EvmCoinInfo
. Only the affected lines around the variable definition and struct literal need to be changed. No imports or other changes are required.
-
Copy modified line R129
@@ -118,7 +118,6 @@ | ||
// when resetting the chain config | ||
displayDenom := evmtypes.GetEVMCoinDisplayDenom() | ||
decimals := evmtypes.GetEVMCoinDecimals() | ||
extendedDecimals := evmtypes.GetEVMCoinExtendedDecimals() | ||
|
||
configurator := evmtypes.NewEvmConfig() | ||
configurator.ResetTestConfig() | ||
@@ -127,7 +126,7 @@ | ||
WithEVMCoinInfo(evmtypes.EvmCoinInfo{ | ||
DisplayDenom: displayDenom, | ||
Decimals: decimals, | ||
ExtendedDecimals: extendedDecimals, | ||
ExtendedDecimals: evmtypes.GetEVMCoinExtendedDecimals(), | ||
}). | ||
Apply() | ||
s.Require().NoError(err) |
displayDenom := evmtypes.GetEVMCoinDisplayDenom() | ||
decimals := evmtypes.GetEVMCoinDecimals() | ||
extendedDecimals := evmtypes.GetEVMCoinExtendedDecimals() |
Check warning
Code scanning / CodeQL
Useless assignment to local variable Warning test
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 2 days ago
The best way to fix the problem is to remove the assignment to the local variable extendedDecimals
, and instead use the function call to evmtypes.GetEVMCoinExtendedDecimals()
directly in the assignment for the struct field ExtendedDecimals
. Specifically, in the file tests/integration/x/vm/keeper_test_suite.go
, in method SetupTest
, remove line 108:
108: extendedDecimals := evmtypes.GetEVMCoinExtendedDecimals()
and, in the struct initialization, replace:
117: ExtendedDecimals: extendedDecimals,
with:
117: ExtendedDecimals: evmtypes.GetEVMCoinExtendedDecimals(),
No new methods, imports, or definitions are necessary.
-
Copy modified line R116
@@ -105,7 +105,6 @@ | ||
// because we'll need to set them again when resetting the chain config | ||
displayDenom := evmtypes.GetEVMCoinDisplayDenom() | ||
decimals := evmtypes.GetEVMCoinDecimals() | ||
extendedDecimals := evmtypes.GetEVMCoinExtendedDecimals() | ||
|
||
configurator := evmtypes.NewEvmConfig() | ||
configurator.ResetTestConfig() | ||
@@ -114,7 +113,7 @@ | ||
WithEVMCoinInfo(evmtypes.EvmCoinInfo{ | ||
DisplayDenom: displayDenom, | ||
Decimals: decimals, | ||
ExtendedDecimals: extendedDecimals, | ||
ExtendedDecimals: evmtypes.GetEVMCoinExtendedDecimals(), | ||
}). | ||
Apply() | ||
s.Require().NoError(err) |
configurator.ResetTestConfig() | ||
s.Require().NoError(configurator.WithEVMCoinInfo(testconstants.ExampleChainCoinInfo[chainID]).Configure()) | ||
s.Require().NoError(configurator.WithEVMCoinInfo(testconfig.ExampleChainCoinInfo[chainID]).Apply()) |
Check warning
Code scanning / CodeQL
Unreachable statement Warning test
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 2 days ago
To fix the unreachable statement, you need to examine the block directly before line 249 to identify what control flow blocks execution from reaching it. Most likely, a previous assertion or a method with FailNow
or panic
stops the test, making the subsequent statement unreachable. You should remove or reposition the unreachable statement (line 249) as appropriate, to ensure the code's logic and goals are maintained. If the statement is indeed not required, remove it. If it is necessary, restructure the test so that it becomes reachable (e.g., by ensuring no panic or failed assertion occurs before it).
For this snippet, edit only the lines you've been shown in file tests/integration/ante/test_evm_unit_04_validate.go
. Remove line 249 if it is unnecessary, as further down, the necessary checks are performed, so it should be safe to remove.
@@ -246,7 +246,6 @@ | ||
// function to be tested. | ||
configurator := evmtypes.NewEvmConfig() | ||
configurator.ResetTestConfig() | ||
s.Require().NoError(configurator.WithEVMCoinInfo(testconfig.ExampleChainCoinInfo[chainID]).Apply()) | ||
|
||
// If decimals is not 18 decimals, we have to convert txFeeInfo to original | ||
// decimals representation. |
configurator.ResetTestConfig() | ||
configurator.WithEVMCoinInfo(testconstants.ExampleChainCoinInfo[testconstants.SixDecimalsChainID]) | ||
err := configurator.Configure() | ||
configurator.WithEVMCoinInfo(testconfig.ExampleChainCoinInfo[testconfig.ExampleSixDecimalsChainID]) |
Check warning
Code scanning / CodeQL
Unreachable statement Warning test
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 2 days ago
The unreachable statement at line 503 should be examined and either relocated or removed. The recommended approach is:
- Inspect the lines immediately preceding 503 for an errant return, panic, or loop that never terminates.
- If the previous line contains an error or termination, ensure
configurator.WithEVMCoinInfo(...)
is located after all such statements so that it executes as intended. - If the statement is genuinely unreachable and no longer needed, simply remove line 503.
- Only change the minimum necessary lines near line 503 within the
FuzzBurnCoins
function in filetests/integration/x/precisebank/test_burn_integration.go
.
@@ -500,7 +500,6 @@ | ||
func FuzzBurnCoins(f *testing.F) { | ||
configurator := evmtypes.NewEvmConfig() | ||
configurator.ResetTestConfig() | ||
configurator.WithEVMCoinInfo(testconfig.ExampleChainCoinInfo[testconfig.ExampleSixDecimalsChainID]) | ||
err := configurator.Apply() | ||
require.NoError(f, err) | ||
|
configurator.ResetTestConfig() | ||
configurator.WithEVMCoinInfo(testconstants.ExampleChainCoinInfo[testconstants.SixDecimalsChainID]) | ||
err := configurator.Configure() | ||
configurator.WithEVMCoinInfo(testconfig.ExampleChainCoinInfo[testconfig.ExampleSixDecimalsChainID]) |
Check warning
Code scanning / CodeQL
Unreachable statement Warning test
configurator.ResetTestConfig() | ||
configurator.WithEVMCoinInfo(testconstants.ExampleChainCoinInfo[testconstants.SixDecimalsChainID]) | ||
err := configurator.Configure() | ||
configurator.WithEVMCoinInfo(testconfig.ExampleChainCoinInfo[testconfig.ExampleSixDecimalsChainID]) |
Check warning
Code scanning / CodeQL
Unreachable statement Warning test
@Eric-Warehime @vladjdk please take a look for a first pass in terms of direction and generally use useful the new patterns are before I mark as r4r |
closes: #616, #371 and #522