Skip to content

Conversation

almk-dev
Copy link
Member

@almk-dev almk-dev commented Sep 16, 2025

closes: #616, #371 and #522

displayDenom := evmtypes.GetEVMCoinDisplayDenom()
decimals := evmtypes.GetEVMCoinDecimals()
extendedDecimals := evmtypes.GetEVMCoinExtendedDecimals()

Check warning

Code scanning / CodeQL

Useless assignment to local variable Warning test

This definition of extendedDecimals is never used.

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.


Suggested changeset 1
tests/integration/ante/ante_test_suite.go

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/tests/integration/ante/ante_test_suite.go b/tests/integration/ante/ante_test_suite.go
--- a/tests/integration/ante/ante_test_suite.go
+++ b/tests/integration/ante/ante_test_suite.go
@@ -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)
EOF
@@ -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)
Copilot is powered by AI and may make mistakes. Always verify output.
displayDenom := evmtypes.GetEVMCoinDisplayDenom()
decimals := evmtypes.GetEVMCoinDecimals()
extendedDecimals := evmtypes.GetEVMCoinExtendedDecimals()

Check warning

Code scanning / CodeQL

Useless assignment to local variable Warning test

This definition of extendedDecimals is never used.

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.


Suggested changeset 1
tests/integration/x/vm/keeper_test_suite.go

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/tests/integration/x/vm/keeper_test_suite.go b/tests/integration/x/vm/keeper_test_suite.go
--- a/tests/integration/x/vm/keeper_test_suite.go
+++ b/tests/integration/x/vm/keeper_test_suite.go
@@ -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)
EOF
@@ -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)
Copilot is powered by AI and may make mistakes. Always verify output.
@almk-dev almk-dev changed the title Config refactor refactor!: clean up chain config Sep 16, 2025
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

This statement is unreachable.

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.


Suggested changeset 1
tests/integration/ante/test_evm_unit_04_validate.go

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/tests/integration/ante/test_evm_unit_04_validate.go b/tests/integration/ante/test_evm_unit_04_validate.go
--- a/tests/integration/ante/test_evm_unit_04_validate.go
+++ b/tests/integration/ante/test_evm_unit_04_validate.go
@@ -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.
EOF
@@ -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.
Copilot is powered by AI and may make mistakes. Always verify output.
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

This statement is unreachable.

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 file tests/integration/x/precisebank/test_burn_integration.go.

Suggested changeset 1
tests/integration/x/precisebank/test_burn_integration.go

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/tests/integration/x/precisebank/test_burn_integration.go b/tests/integration/x/precisebank/test_burn_integration.go
--- a/tests/integration/x/precisebank/test_burn_integration.go
+++ b/tests/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)
 
EOF
@@ -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)

Copilot is powered by AI and may make mistakes. Always verify output.
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

This statement is unreachable.
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

This statement is unreachable.
@almk-dev
Copy link
Member Author

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor EVM configurations to always use flags and .toml values
1 participant