Skip to content

Conversation

@JonathanOppenheimer
Copy link
Member

Why this should be merged

Replaces native minter e2e hardhat tests with golang bindings and a simulated backend test.

Part of #1228

How this works

Generates relevant golang bindings from sol files for the testing. Mirrors the hardhat test to a golang test using simulated backend.

How this was tested

CI

Need to be documented?

No

Need to update RELEASES.md?

No

@JonathanOppenheimer JonathanOppenheimer self-assigned this Nov 21, 2025
@JonathanOppenheimer JonathanOppenheimer added ci testing This primarly focuses on testing labels Nov 21, 2025
@JonathanOppenheimer JonathanOppenheimer force-pushed the JonathanOppenheimer/convert-native-minter-test branch from a93e2b6 to b7eec85 Compare November 21, 2025 20:59
@JonathanOppenheimer JonathanOppenheimer force-pushed the JonathanOppenheimer/convert-native-minter-test branch from 4131d69 to ef32f2f Compare November 21, 2025 21:11
@@ -0,0 +1,13 @@
// Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole package seems like a mess. Is the correct structure? It's not like the deployerallowlist package, because the minter is not tested seperately like allowlist is.

@@ -1,7 +1,7 @@
// Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved these in to match what you did for the deployerallowlist. I think all of these folders need to be cleaned up / reorganized, but I would appreciate your guidance @ceyonur

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xxxtest packages are mostly meant for test-related but not actual UT files (test utility files mostly). There is a cyclic dependency so we cannot really put these simulatedtest/binding files under the related precompile packages (like nativeminter/). I was going to suggest reverting other changes and add another simulatedtest packages but I was not aware that we had another cyclic dependency introduced with extstate cleanup.

I think in that case we can move all these precompile tests to their relevant test packages. (like nativemintertest or testnativeminter etc). If you feel like it will be cleaner we can introduce simulatetest packages, but it seems that we need to move config_test and contract_test into xxxtest packages anyway.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trying to put everything in the top level package also results in cyclic dependencies.

Would you like to put a PR up into this PR to restructure the files? I'm not sure if I follow exactly what you are suggesting. It really is a mess...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah gosh this is really messy. What are your thoughts on another bindings folder? or some way to split things up better?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see #1878

@JonathanOppenheimer JonathanOppenheimer marked this pull request as ready for review November 21, 2025 21:47
@JonathanOppenheimer JonathanOppenheimer requested review from a team and maru-ava as code owners November 21, 2025 21:47
@JonathanOppenheimer JonathanOppenheimer changed the title feat: convert native minter test to go framework feat: convert native minter npm test to go test Nov 21, 2025
test func(t *testing.T, backend *sim.Backend, nativeMinterIntf *INativeMinter)
}

testCases := []testCase{
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be getting rid of these ERC20 related testing (and openzeppelin lib)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the coverage still good now? post removal?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea I think so.

@@ -1,27 +1,31 @@
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we get rid of this file? I don't think this is a viable testing for this and we should not be importing any extra contracts.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead we can use a much simpler approach that only issues mintNativeCoin (similar to allowlist tests.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup I've deleted this file entirely -- let me know what you think of NativeMinterTest.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks good!

@@ -1,7 +1,7 @@
// Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xxxtest packages are mostly meant for test-related but not actual UT files (test utility files mostly). There is a cyclic dependency so we cannot really put these simulatedtest/binding files under the related precompile packages (like nativeminter/). I was going to suggest reverting other changes and add another simulatedtest packages but I was not aware that we had another cyclic dependency introduced with extstate cleanup.

I think in that case we can move all these precompile tests to their relevant test packages. (like nativemintertest or testnativeminter etc). If you feel like it will be cleaner we can introduce simulatetest packages, but it seems that we need to move config_test and contract_test into xxxtest packages anyway.

@@ -1,7 +1,7 @@
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did we move these files to Solidity? I think it makes sense to keep them together with their bindings.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was just trying to simplify the structure -- I think it needs a more thorough approach though.

test func(t *testing.T, backend *sim.Backend, nativeMinterIntf *INativeMinter)
}

testCases := []testCase{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be getting rid of these ERC20 related testing (and openzeppelin lib)

Comment on lines 88 to 93
func setAsEnabled(t *testing.T, b *sim.Backend, nativeMinter *INativeMinter, auth *bind.TransactOpts, address common.Address) {
t.Helper()
tx, err := nativeMinter.SetEnabled(auth, address)
require.NoError(t, err)
testutils.WaitReceiptSuccessful(t, b, tx)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can be move to allowlisttest package as a test helper.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't move a test package there because there's another importcycle when I do it that way

feemanager (test) -> allowlisttest -> ethclient/simulated -> core -> feemanager

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I put the allowlist test helpers in testutils.

return addr, contract
}

func verifyRole(t *testing.T, nativeMinter *INativeMinter, address common.Address, expectedRole allowlist.Role) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be move to allowlisttest package as a test helper.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above comment.

Copy link
Collaborator

@ceyonur ceyonur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall it's looking good. We just need to the helper file and decide the test structure in #1878

"github.com/stretchr/testify/require"

"github.com/ava-labs/subnet-evm/accounts/abi/bind"
"github.com/ava-labs/subnet-evm/precompile/allowlist"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it best to move this file to the allowlisttest to reduce the imported packages?

test func(t *testing.T, backend *sim.Backend, nativeMinterIntf *INativeMinter)
}

testCases := []testCase{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea I think so.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the file looking good 👍 , it's just would fit better to allowlisttest.

@@ -1,27 +1,31 @@
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks good!

@@ -1,7 +1,7 @@
// Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see #1878

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci testing This primarly focuses on testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants