diff --git a/precompile/allowlist/allowlisttest/allowlist_test.go b/precompile/allowlist/allowlist_test.go similarity index 91% rename from precompile/allowlist/allowlisttest/allowlist_test.go rename to precompile/allowlist/allowlist_test.go index 1caad6053b..0c7bd19950 100644 --- a/precompile/allowlist/allowlisttest/allowlist_test.go +++ b/precompile/allowlist/allowlist_test.go @@ -1,7 +1,7 @@ // Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. -package allowlisttest +package allowlist_test import ( "testing" @@ -9,6 +9,7 @@ import ( "github.com/ava-labs/libevm/common" "github.com/ava-labs/subnet-evm/precompile/allowlist" + "github.com/ava-labs/subnet-evm/precompile/allowlist/allowlisttest" "github.com/ava-labs/subnet-evm/precompile/contract" "github.com/ava-labs/subnet-evm/precompile/modules" "github.com/ava-labs/subnet-evm/precompile/precompileconfig" @@ -63,5 +64,5 @@ func TestAllowListRun(t *testing.T) { Configurator: &dummyConfigurator{}, ConfigKey: "dummy", } - RunPrecompileWithAllowListTests(t, dummyModule, nil) + allowlisttest.RunPrecompileWithAllowListTests(t, dummyModule, nil) } diff --git a/precompile/allowlist/allowlisttest/AllowList.sol b/precompile/allowlist/allowlisttest/bindings/AllowList.sol similarity index 100% rename from precompile/allowlist/allowlisttest/AllowList.sol rename to precompile/allowlist/allowlisttest/bindings/AllowList.sol diff --git a/precompile/allowlist/allowlisttest/AllowListTest.sol b/precompile/allowlist/allowlisttest/bindings/AllowListTest.sol similarity index 100% rename from precompile/allowlist/allowlisttest/AllowListTest.sol rename to precompile/allowlist/allowlisttest/bindings/AllowListTest.sol diff --git a/precompile/allowlist/allowlisttest/IAllowList.sol b/precompile/allowlist/allowlisttest/bindings/IAllowList.sol similarity index 100% rename from precompile/allowlist/allowlisttest/IAllowList.sol rename to precompile/allowlist/allowlisttest/bindings/IAllowList.sol diff --git a/precompile/allowlist/allowlisttest/compile.go b/precompile/allowlist/allowlisttest/bindings/compile.go similarity index 76% rename from precompile/allowlist/allowlisttest/compile.go rename to precompile/allowlist/allowlisttest/bindings/compile.go index 20d3012ae3..6aa0654b6c 100644 --- a/precompile/allowlist/allowlisttest/compile.go +++ b/precompile/allowlist/allowlisttest/bindings/compile.go @@ -1,12 +1,12 @@ // Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. -package allowlisttest +package bindings // Step 1: Compile Solidity contracts to generate ABI and bin files //go:generate solc-v0.8.30 -o artifacts --overwrite --abi --bin --base-path . precompile/=../../ --evm-version paris AllowListTest.sol // Step 2: Generate Go bindings from the compiled artifacts -//go:generate go run github.com/ava-labs/libevm/cmd/abigen --pkg allowlisttest --type IAllowList --abi artifacts/IAllowList.abi --bin artifacts/IAllowList.bin --out gen_allowlist_binding.go -//go:generate go run github.com/ava-labs/libevm/cmd/abigen --pkg allowlisttest --type AllowListTest --abi artifacts/AllowListTest.abi --bin artifacts/AllowListTest.bin --out gen_allowlisttest_binding.go +//go:generate go run github.com/ava-labs/libevm/cmd/abigen --pkg bindings --type IAllowList --abi artifacts/IAllowList.abi --bin artifacts/IAllowList.bin --out gen_allowlist_binding.go +//go:generate go run github.com/ava-labs/libevm/cmd/abigen --pkg bindings --type AllowListTest --abi artifacts/AllowListTest.abi --bin artifacts/AllowListTest.bin --out gen_allowlisttest_binding.go // Step 3: Replace import paths in generated binding to use subnet-evm instead of libevm //go:generate sh -c "sed -i.bak -e 's|github.com/ava-labs/libevm/accounts/abi|github.com/ava-labs/subnet-evm/accounts/abi|g' -e 's|github.com/ava-labs/libevm/accounts/abi/bind|github.com/ava-labs/subnet-evm/accounts/abi/bind|g' gen_allowlist_binding.go gen_allowlisttest_binding.go && rm -f gen_allowlist_binding.go.bak gen_allowlisttest_binding.go.bak" diff --git a/precompile/allowlist/allowlisttest/gen_allowlist_binding.go b/precompile/allowlist/allowlisttest/bindings/gen_allowlist_binding.go similarity index 99% rename from precompile/allowlist/allowlisttest/gen_allowlist_binding.go rename to precompile/allowlist/allowlisttest/bindings/gen_allowlist_binding.go index 7b09e6358b..7f318a0c07 100644 --- a/precompile/allowlist/allowlisttest/gen_allowlist_binding.go +++ b/precompile/allowlist/allowlisttest/bindings/gen_allowlist_binding.go @@ -1,7 +1,7 @@ // Code generated - DO NOT EDIT. // This file is a generated binding and any manual changes will be lost. -package allowlisttest +package bindings import ( "errors" diff --git a/precompile/allowlist/allowlisttest/gen_allowlisttest_binding.go b/precompile/allowlist/allowlisttest/bindings/gen_allowlisttest_binding.go similarity index 99% rename from precompile/allowlist/allowlisttest/gen_allowlisttest_binding.go rename to precompile/allowlist/allowlisttest/bindings/gen_allowlisttest_binding.go index 6857532b26..d4a169501e 100644 --- a/precompile/allowlist/allowlisttest/gen_allowlisttest_binding.go +++ b/precompile/allowlist/allowlisttest/bindings/gen_allowlisttest_binding.go @@ -1,7 +1,7 @@ // Code generated - DO NOT EDIT. // This file is a generated binding and any manual changes will be lost. -package allowlisttest +package bindings import ( "errors" diff --git a/precompile/allowlist/allowlisttest/config_test.go b/precompile/allowlist/config_test.go similarity index 69% rename from precompile/allowlist/allowlisttest/config_test.go rename to precompile/allowlist/config_test.go index 544ead9de1..29a057f9e8 100644 --- a/precompile/allowlist/allowlisttest/config_test.go +++ b/precompile/allowlist/config_test.go @@ -1,12 +1,13 @@ // Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. -package allowlisttest +package allowlist_test import ( "testing" "github.com/ava-labs/subnet-evm/precompile/allowlist" + "github.com/ava-labs/subnet-evm/precompile/allowlist/allowlisttest" "github.com/ava-labs/subnet-evm/precompile/modules" ) @@ -18,9 +19,9 @@ var testModule = modules.Module{ } func TestVerifyAllowlist(t *testing.T) { - RunPrecompileWithAllowListTests(t, testModule, nil) + allowlisttest.RunPrecompileWithAllowListTests(t, testModule, nil) } func TestEqualAllowList(t *testing.T) { - EqualPrecompileWithAllowListTests(t, testModule, nil) + allowlisttest.EqualPrecompileWithAllowListTests(t, testModule, nil) } diff --git a/precompile/contracts/deployerallowlist/deployerallowlisttest/config_test.go b/precompile/contracts/deployerallowlist/config_test.go similarity index 98% rename from precompile/contracts/deployerallowlist/deployerallowlisttest/config_test.go rename to precompile/contracts/deployerallowlist/config_test.go index 0bad959a4a..6dc731b904 100644 --- a/precompile/contracts/deployerallowlist/deployerallowlisttest/config_test.go +++ b/precompile/contracts/deployerallowlist/config_test.go @@ -1,7 +1,7 @@ // Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. -package deployerallowlisttest +package deployerallowlist_test import ( "testing" diff --git a/precompile/contracts/deployerallowlist/deployerallowlisttest/contract_test.go b/precompile/contracts/deployerallowlist/contract_test.go similarity index 93% rename from precompile/contracts/deployerallowlist/deployerallowlisttest/contract_test.go rename to precompile/contracts/deployerallowlist/contract_test.go index cdbd234451..4807ede717 100644 --- a/precompile/contracts/deployerallowlist/deployerallowlisttest/contract_test.go +++ b/precompile/contracts/deployerallowlist/contract_test.go @@ -1,7 +1,7 @@ // Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. -package deployerallowlisttest +package deployerallowlist_test import ( "testing" diff --git a/precompile/contracts/deployerallowlist/deployerallowlisttest/simulated_test.go b/precompile/contracts/deployerallowlist/simulated_test.go similarity index 65% rename from precompile/contracts/deployerallowlist/deployerallowlisttest/simulated_test.go rename to precompile/contracts/deployerallowlist/simulated_test.go index 77d323f737..10cca45dfb 100644 --- a/precompile/contracts/deployerallowlist/deployerallowlisttest/simulated_test.go +++ b/precompile/contracts/deployerallowlist/simulated_test.go @@ -1,7 +1,7 @@ // Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. -package deployerallowlisttest +package deployerallowlist_test import ( "math/big" @@ -19,12 +19,12 @@ import ( "github.com/ava-labs/subnet-evm/params/extras" "github.com/ava-labs/subnet-evm/plugin/evm/customtypes" "github.com/ava-labs/subnet-evm/precompile/allowlist" - "github.com/ava-labs/subnet-evm/precompile/allowlist/allowlisttest" "github.com/ava-labs/subnet-evm/precompile/contracts/deployerallowlist" "github.com/ava-labs/subnet-evm/precompile/contracts/testutils" "github.com/ava-labs/subnet-evm/utils" sim "github.com/ava-labs/subnet-evm/ethclient/simulated" + allowlistbindings "github.com/ava-labs/subnet-evm/precompile/allowlist/allowlisttest/bindings" ) var ( @@ -61,9 +61,9 @@ func newBackendWithDeployerAllowList(t *testing.T) *sim.Backend { // Helper functions to reduce test boilerplate -func deployAllowListTest(t *testing.T, b *sim.Backend, auth *bind.TransactOpts) (common.Address, *allowlisttest.AllowListTest) { +func deployallowlistbindings(t *testing.T, b *sim.Backend, auth *bind.TransactOpts) (common.Address, *allowlistbindings.AllowListTest) { t.Helper() - addr, tx, contract, err := allowlisttest.DeployAllowListTest(auth, b.Client(), deployerallowlist.ContractAddress) + addr, tx, contract, err := allowlistbindings.DeployAllowListTest(auth, b.Client(), deployerallowlist.ContractAddress) require.NoError(t, err) testutils.WaitReceiptSuccessful(t, b, tx) return addr, contract @@ -76,81 +76,81 @@ func TestDeployerAllowList(t *testing.T) { type testCase struct { name string - test func(t *testing.T, backend *sim.Backend, precompileIntf *allowlisttest.IAllowList) + test func(t *testing.T, backend *sim.Backend, precompileIntf *allowlistbindings.IAllowList) } testCases := []testCase{ { name: "should verify sender is admin", - test: func(t *testing.T, _ *sim.Backend, allowList *allowlisttest.IAllowList) { + test: func(t *testing.T, _ *sim.Backend, allowList *allowlistbindings.IAllowList) { testutils.VerifyRole(t, allowList, adminAddress, allowlist.AdminRole) }, }, { name: "should verify new address has no role", - test: func(t *testing.T, backend *sim.Backend, allowList *allowlisttest.IAllowList) { - allowListTestAddr, _ := deployAllowListTest(t, backend, admin) - testutils.VerifyRole(t, allowList, allowListTestAddr, allowlist.NoRole) + test: func(t *testing.T, backend *sim.Backend, allowList *allowlistbindings.IAllowList) { + allowlistbindingsAddr, _ := deployallowlistbindings(t, backend, admin) + testutils.VerifyRole(t, allowList, allowlistbindingsAddr, allowlist.NoRole) }, }, { name: "should verify contract correctly reports admin status", - test: func(t *testing.T, backend *sim.Backend, allowList *allowlisttest.IAllowList) { - allowListTestAddr, allowListTest := deployAllowListTest(t, backend, admin) + test: func(t *testing.T, backend *sim.Backend, allowList *allowlistbindings.IAllowList) { + allowlistbindingsAddr, allowlistbindings := deployallowlistbindings(t, backend, admin) - testutils.VerifyRole(t, allowList, allowListTestAddr, allowlist.NoRole) + testutils.VerifyRole(t, allowList, allowlistbindingsAddr, allowlist.NoRole) - isAdmin, err := allowListTest.IsAdmin(nil, allowListTestAddr) + isAdmin, err := allowlistbindings.IsAdmin(nil, allowlistbindingsAddr) require.NoError(t, err) require.False(t, isAdmin) - isAdmin, err = allowListTest.IsAdmin(nil, adminAddress) + isAdmin, err = allowlistbindings.IsAdmin(nil, adminAddress) require.NoError(t, err) require.True(t, isAdmin) }, }, { name: "should not let address with no role deploy contracts", - test: func(t *testing.T, backend *sim.Backend, allowList *allowlisttest.IAllowList) { + test: func(t *testing.T, backend *sim.Backend, allowList *allowlistbindings.IAllowList) { testutils.VerifyRole(t, allowList, unprivilegedAddress, allowlist.NoRole) - _, allowListTest := deployAllowListTest(t, backend, admin) + _, allowlistbindings := deployallowlistbindings(t, backend, admin) // Try to deploy via unprivileged user - should fail - _, err := allowListTest.DeployContract(unprivileged) + _, err := allowlistbindings.DeployContract(unprivileged) // The error returned is a JSON Error rather than the vm.ErrExecutionReverted error require.ErrorContains(t, err, vm.ErrExecutionReverted.Error()) }, }, { name: "should allow admin to add contract as admin via precompile", - test: func(t *testing.T, backend *sim.Backend, allowList *allowlisttest.IAllowList) { - allowListTestAddr, allowListTest := deployAllowListTest(t, backend, admin) + test: func(t *testing.T, backend *sim.Backend, allowList *allowlistbindings.IAllowList) { + allowlistbindingsAddr, allowlistbindings := deployallowlistbindings(t, backend, admin) - testutils.VerifyRole(t, allowList, allowListTestAddr, allowlist.NoRole) - testutils.SetAsAdmin(t, backend, allowList, admin, allowListTestAddr) - testutils.VerifyRole(t, allowList, allowListTestAddr, allowlist.AdminRole) + testutils.VerifyRole(t, allowList, allowlistbindingsAddr, allowlist.NoRole) + testutils.SetAsAdmin(t, backend, allowList, admin, allowlistbindingsAddr) + testutils.VerifyRole(t, allowList, allowlistbindingsAddr, allowlist.AdminRole) - isAdmin, err := allowListTest.IsAdmin(nil, allowListTestAddr) + isAdmin, err := allowlistbindings.IsAdmin(nil, allowlistbindingsAddr) require.NoError(t, err) require.True(t, isAdmin) }, }, { name: "should allow admin to add deployer via contract", - test: func(t *testing.T, backend *sim.Backend, allowList *allowlisttest.IAllowList) { - allowListTestAddr, allowListTest := deployAllowListTest(t, backend, admin) - otherContractAddr, _ := deployAllowListTest(t, backend, admin) + test: func(t *testing.T, backend *sim.Backend, allowList *allowlistbindings.IAllowList) { + allowlistbindingsAddr, allowlistbindings := deployallowlistbindings(t, backend, admin) + otherContractAddr, _ := deployallowlistbindings(t, backend, admin) - testutils.VerifyRole(t, allowList, allowListTestAddr, allowlist.NoRole) - testutils.SetAsAdmin(t, backend, allowList, admin, allowListTestAddr) - testutils.VerifyRole(t, allowList, allowListTestAddr, allowlist.AdminRole) + testutils.VerifyRole(t, allowList, allowlistbindingsAddr, allowlist.NoRole) + testutils.SetAsAdmin(t, backend, allowList, admin, allowlistbindingsAddr) + testutils.VerifyRole(t, allowList, allowlistbindingsAddr, allowlist.AdminRole) - tx, err := allowListTest.SetEnabled(admin, otherContractAddr) + tx, err := allowlistbindings.SetEnabled(admin, otherContractAddr) require.NoError(t, err) testutils.WaitReceipt(t, backend, tx) - isEnabled, err := allowListTest.IsEnabled(nil, otherContractAddr) + isEnabled, err := allowlistbindings.IsEnabled(nil, otherContractAddr) require.NoError(t, err) require.True(t, isEnabled) testutils.VerifyRole(t, allowList, otherContractAddr, allowlist.EnabledRole) @@ -158,17 +158,17 @@ func TestDeployerAllowList(t *testing.T) { }, { name: "should allow enabled address to deploy contracts", - test: func(t *testing.T, backend *sim.Backend, allowList *allowlisttest.IAllowList) { - allowListTestAddr, allowListTest := deployAllowListTest(t, backend, admin) - deployerContractAddr, deployerContract := deployAllowListTest(t, backend, admin) + test: func(t *testing.T, backend *sim.Backend, allowList *allowlistbindings.IAllowList) { + allowlistbindingsAddr, allowlistbindings := deployallowlistbindings(t, backend, admin) + deployerContractAddr, deployerContract := deployallowlistbindings(t, backend, admin) - testutils.SetAsAdmin(t, backend, allowList, admin, allowListTestAddr) + testutils.SetAsAdmin(t, backend, allowList, admin, allowlistbindingsAddr) - tx, err := allowListTest.SetEnabled(admin, deployerContractAddr) + tx, err := allowlistbindings.SetEnabled(admin, deployerContractAddr) require.NoError(t, err) testutils.WaitReceipt(t, backend, tx) - isEnabled, err := allowListTest.IsEnabled(nil, deployerContractAddr) + isEnabled, err := allowlistbindings.IsEnabled(nil, deployerContractAddr) require.NoError(t, err) require.True(t, isEnabled) @@ -179,21 +179,21 @@ func TestDeployerAllowList(t *testing.T) { }, { name: "should allow admin to revoke deployer", - test: func(t *testing.T, backend *sim.Backend, allowList *allowlisttest.IAllowList) { - allowListTestAddr, allowListTest := deployAllowListTest(t, backend, admin) - deployerContractAddr, _ := deployAllowListTest(t, backend, admin) + test: func(t *testing.T, backend *sim.Backend, allowList *allowlistbindings.IAllowList) { + allowlistbindingsAddr, allowlistbindings := deployallowlistbindings(t, backend, admin) + deployerContractAddr, _ := deployallowlistbindings(t, backend, admin) - testutils.SetAsAdmin(t, backend, allowList, admin, allowListTestAddr) + testutils.SetAsAdmin(t, backend, allowList, admin, allowlistbindingsAddr) - tx, err := allowListTest.SetEnabled(admin, deployerContractAddr) + tx, err := allowlistbindings.SetEnabled(admin, deployerContractAddr) require.NoError(t, err) testutils.WaitReceipt(t, backend, tx) - isEnabled, err := allowListTest.IsEnabled(nil, deployerContractAddr) + isEnabled, err := allowlistbindings.IsEnabled(nil, deployerContractAddr) require.NoError(t, err) require.True(t, isEnabled) - tx, err = allowListTest.Revoke(admin, deployerContractAddr) + tx, err = allowlistbindings.Revoke(admin, deployerContractAddr) require.NoError(t, err) testutils.WaitReceipt(t, backend, tx) @@ -207,7 +207,7 @@ func TestDeployerAllowList(t *testing.T) { backend := newBackendWithDeployerAllowList(t) defer backend.Close() - allowList, err := allowlisttest.NewIAllowList(deployerallowlist.ContractAddress, backend.Client()) + allowList, err := allowlistbindings.NewIAllowList(deployerallowlist.ContractAddress, backend.Client()) require.NoError(t, err) tc.test(t, backend, allowList) @@ -223,19 +223,19 @@ func TestIAllowList_Events(t *testing.T) { type testCase struct { name string - testRun func(*allowlisttest.IAllowList, *bind.TransactOpts, *sim.Backend, *testing.T, common.Address) - expectedEvents []allowlisttest.IAllowListRoleSet + testRun func(*allowlistbindings.IAllowList, *bind.TransactOpts, *sim.Backend, *testing.T, common.Address) + expectedEvents []allowlistbindings.IAllowListRoleSet } testCases := []testCase{ { name: "should emit event after set admin", - testRun: func(allowList *allowlisttest.IAllowList, auth *bind.TransactOpts, backend *sim.Backend, t *testing.T, addr common.Address) { + testRun: func(allowList *allowlistbindings.IAllowList, auth *bind.TransactOpts, backend *sim.Backend, t *testing.T, addr common.Address) { tx, err := allowList.SetAdmin(auth, addr) require.NoError(t, err) testutils.WaitReceipt(t, backend, tx) }, - expectedEvents: []allowlisttest.IAllowListRoleSet{ + expectedEvents: []allowlistbindings.IAllowListRoleSet{ { Role: allowlist.AdminRole.Big(), Account: testAddress, @@ -246,12 +246,12 @@ func TestIAllowList_Events(t *testing.T) { }, { name: "should emit event after set manager", - testRun: func(allowList *allowlisttest.IAllowList, auth *bind.TransactOpts, backend *sim.Backend, t *testing.T, addr common.Address) { + testRun: func(allowList *allowlistbindings.IAllowList, auth *bind.TransactOpts, backend *sim.Backend, t *testing.T, addr common.Address) { tx, err := allowList.SetManager(auth, addr) require.NoError(t, err) testutils.WaitReceipt(t, backend, tx) }, - expectedEvents: []allowlisttest.IAllowListRoleSet{ + expectedEvents: []allowlistbindings.IAllowListRoleSet{ { Role: allowlist.ManagerRole.Big(), Account: testAddress, @@ -262,12 +262,12 @@ func TestIAllowList_Events(t *testing.T) { }, { name: "should emit event after set enabled", - testRun: func(allowList *allowlisttest.IAllowList, auth *bind.TransactOpts, backend *sim.Backend, t *testing.T, addr common.Address) { + testRun: func(allowList *allowlistbindings.IAllowList, auth *bind.TransactOpts, backend *sim.Backend, t *testing.T, addr common.Address) { tx, err := allowList.SetEnabled(auth, addr) require.NoError(t, err) testutils.WaitReceipt(t, backend, tx) }, - expectedEvents: []allowlisttest.IAllowListRoleSet{ + expectedEvents: []allowlistbindings.IAllowListRoleSet{ { Role: allowlist.EnabledRole.Big(), Account: testAddress, @@ -278,7 +278,7 @@ func TestIAllowList_Events(t *testing.T) { }, { name: "should emit event after set none", - testRun: func(allowList *allowlisttest.IAllowList, auth *bind.TransactOpts, backend *sim.Backend, t *testing.T, addr common.Address) { + testRun: func(allowList *allowlistbindings.IAllowList, auth *bind.TransactOpts, backend *sim.Backend, t *testing.T, addr common.Address) { // First set the address to Enabled so we can test setting it to None tx, err := allowList.SetEnabled(auth, addr) require.NoError(t, err) @@ -288,7 +288,7 @@ func TestIAllowList_Events(t *testing.T) { require.NoError(t, err) testutils.WaitReceipt(t, backend, tx) }, - expectedEvents: []allowlisttest.IAllowListRoleSet{ + expectedEvents: []allowlistbindings.IAllowListRoleSet{ { Role: allowlist.EnabledRole.Big(), Account: testAddress, @@ -312,7 +312,7 @@ func TestIAllowList_Events(t *testing.T) { backend := newBackendWithDeployerAllowList(t) defer backend.Close() - allowList, err := allowlisttest.NewIAllowList(deployerallowlist.ContractAddress, backend.Client()) + allowList, err := allowlistbindings.NewIAllowList(deployerallowlist.ContractAddress, backend.Client()) require.NoError(err) tc.testRun(allowList, admin, backend, t, testAddress) diff --git a/precompile/contracts/nativeminter/nativemintertest/config_test.go b/precompile/contracts/nativeminter/config_test.go similarity index 99% rename from precompile/contracts/nativeminter/nativemintertest/config_test.go rename to precompile/contracts/nativeminter/config_test.go index 322d1dd814..7472585c04 100644 --- a/precompile/contracts/nativeminter/nativemintertest/config_test.go +++ b/precompile/contracts/nativeminter/config_test.go @@ -1,7 +1,7 @@ // Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. -package nativemintertest +package nativeminter_test import ( "testing" diff --git a/precompile/contracts/nativeminter/nativemintertest/contract_test.go b/precompile/contracts/nativeminter/contract_test.go similarity index 99% rename from precompile/contracts/nativeminter/nativemintertest/contract_test.go rename to precompile/contracts/nativeminter/contract_test.go index 074eb273f9..ee731e8612 100644 --- a/precompile/contracts/nativeminter/nativemintertest/contract_test.go +++ b/precompile/contracts/nativeminter/contract_test.go @@ -1,7 +1,7 @@ // Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. -package nativemintertest +package nativeminter_test import ( "math/big" diff --git a/precompile/contracts/nativeminter/nativemintertest/INativeMinter.sol b/precompile/contracts/nativeminter/nativemintertest/bindings/INativeMinter.sol similarity index 82% rename from precompile/contracts/nativeminter/nativemintertest/INativeMinter.sol rename to precompile/contracts/nativeminter/nativemintertest/bindings/INativeMinter.sol index 376a872638..7fd63a55c9 100644 --- a/precompile/contracts/nativeminter/nativemintertest/INativeMinter.sol +++ b/precompile/contracts/nativeminter/nativemintertest/bindings/INativeMinter.sol @@ -1,6 +1,6 @@ //SPDX-License-Identifier: MIT pragma solidity ^0.8.24; -import "precompile/allowlist/allowlisttest/IAllowList.sol"; +import "precompile/allowlist/allowlisttest/bindings/IAllowList.sol"; interface INativeMinter is IAllowList { event NativeCoinMinted(address indexed sender, address indexed recipient, uint256 amount); diff --git a/precompile/contracts/nativeminter/nativemintertest/NativeMinterTest.sol b/precompile/contracts/nativeminter/nativemintertest/bindings/NativeMinterTest.sol similarity index 100% rename from precompile/contracts/nativeminter/nativemintertest/NativeMinterTest.sol rename to precompile/contracts/nativeminter/nativemintertest/bindings/NativeMinterTest.sol diff --git a/precompile/contracts/nativeminter/nativemintertest/compile.go b/precompile/contracts/nativeminter/nativemintertest/bindings/compile.go similarity index 68% rename from precompile/contracts/nativeminter/nativemintertest/compile.go rename to precompile/contracts/nativeminter/nativemintertest/bindings/compile.go index 2276dc318d..a6b791fcc8 100644 --- a/precompile/contracts/nativeminter/nativemintertest/compile.go +++ b/precompile/contracts/nativeminter/nativemintertest/bindings/compile.go @@ -1,12 +1,12 @@ // Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. -package nativemintertest +package bindings // Step 1: Compile Solidity contracts to generate ABI and bin files -//go:generate solc-v0.8.30 -o artifacts --overwrite --abi --bin --base-path ../../../.. precompile/=precompile/ --evm-version paris NativeMinterTest.sol +//go:generate solc-v0.8.30 -o artifacts --overwrite --abi --bin --base-path ../../../../.. precompile/=precompile/ --evm-version paris NativeMinterTest.sol // Step 2: Generate Go bindings from the compiled artifacts -//go:generate go run github.com/ava-labs/libevm/cmd/abigen --pkg nativemintertest --type INativeMinter --abi artifacts/INativeMinter.abi --bin artifacts/INativeMinter.bin --out gen_inativeminter_binding.go -//go:generate go run github.com/ava-labs/libevm/cmd/abigen --pkg nativemintertest --type NativeMinterTest --abi artifacts/NativeMinterTest.abi --bin artifacts/NativeMinterTest.bin --out gen_nativemintertest_binding.go +//go:generate go run github.com/ava-labs/libevm/cmd/abigen --pkg bindings --type INativeMinter --abi artifacts/INativeMinter.abi --bin artifacts/INativeMinter.bin --out gen_inativeminter_binding.go +//go:generate go run github.com/ava-labs/libevm/cmd/abigen --pkg bindings --type NativeMinterTest --abi artifacts/NativeMinterTest.abi --bin artifacts/NativeMinterTest.bin --out gen_nativemintertest_binding.go // Step 3: Replace import paths in generated binding to use subnet-evm instead of libevm //go:generate sh -c "sed -i.bak -e 's|github.com/ava-labs/libevm/accounts/abi|github.com/ava-labs/subnet-evm/accounts/abi|g' -e 's|github.com/ava-labs/libevm/accounts/abi/bind|github.com/ava-labs/subnet-evm/accounts/abi/bind|g' gen_inativeminter_binding.go gen_nativemintertest_binding.go && rm -f gen_inativeminter_binding.go.bak gen_nativemintertest_binding.go.bak" diff --git a/precompile/contracts/nativeminter/nativemintertest/gen_inativeminter_binding.go b/precompile/contracts/nativeminter/nativemintertest/bindings/gen_inativeminter_binding.go similarity index 99% rename from precompile/contracts/nativeminter/nativemintertest/gen_inativeminter_binding.go rename to precompile/contracts/nativeminter/nativemintertest/bindings/gen_inativeminter_binding.go index 85cfc1386e..6a1b88a40e 100644 --- a/precompile/contracts/nativeminter/nativemintertest/gen_inativeminter_binding.go +++ b/precompile/contracts/nativeminter/nativemintertest/bindings/gen_inativeminter_binding.go @@ -1,7 +1,7 @@ // Code generated - DO NOT EDIT. // This file is a generated binding and any manual changes will be lost. -package nativemintertest +package bindings import ( "errors" diff --git a/precompile/contracts/nativeminter/nativemintertest/gen_nativemintertest_binding.go b/precompile/contracts/nativeminter/nativemintertest/bindings/gen_nativemintertest_binding.go similarity index 98% rename from precompile/contracts/nativeminter/nativemintertest/gen_nativemintertest_binding.go rename to precompile/contracts/nativeminter/nativemintertest/bindings/gen_nativemintertest_binding.go index 5ca47ffad7..6d68d19bbd 100644 --- a/precompile/contracts/nativeminter/nativemintertest/gen_nativemintertest_binding.go +++ b/precompile/contracts/nativeminter/nativemintertest/bindings/gen_nativemintertest_binding.go @@ -1,7 +1,7 @@ // Code generated - DO NOT EDIT. // This file is a generated binding and any manual changes will be lost. -package nativemintertest +package bindings import ( "errors" @@ -32,7 +32,7 @@ var ( // NativeMinterTestMetaData contains all meta data concerning the NativeMinterTest contract. var NativeMinterTestMetaData = &bind.MetaData{ ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"nativeMinterPrecompile\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"mintNativeCoin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}]", - Bin: "0x608060405234801561001057600080fd5b50604051610355380380610355833981810160405281019061003291906100db565b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050610108565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006100a88261007d565b9050919050565b6100b88161009d565b81146100c357600080fd5b50565b6000815190506100d5816100af565b92915050565b6000602082840312156100f1576100f0610078565b5b60006100ff848285016100c6565b91505092915050565b61023e806101176000396000f3fe6080604052600436106100225760003560e01c80634f5aaaba1461002e57610029565b3661002957005b600080fd5b34801561003a57600080fd5b5061005560048036038101906100509190610181565b610057565b005b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16634f5aaaba83836040518363ffffffff1660e01b81526004016100b29291906101df565b600060405180830381600087803b1580156100cc57600080fd5b505af11580156100e0573d6000803e3d6000fd5b505050505050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610118826100ed565b9050919050565b6101288161010d565b811461013357600080fd5b50565b6000813590506101458161011f565b92915050565b6000819050919050565b61015e8161014b565b811461016957600080fd5b50565b60008135905061017b81610155565b92915050565b60008060408385031215610198576101976100e8565b5b60006101a685828601610136565b92505060206101b78582860161016c565b9150509250929050565b6101ca8161010d565b82525050565b6101d98161014b565b82525050565b60006040820190506101f460008301856101c1565b61020160208301846101d0565b939250505056fea26469706673582212206e879e9d2b7c685853fbe0c2f9b58ba8143aa591e0de8ca323e44034842231e464736f6c634300081e0033", + Bin: "0x608060405234801561001057600080fd5b50604051610355380380610355833981810160405281019061003291906100db565b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050610108565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006100a88261007d565b9050919050565b6100b88161009d565b81146100c357600080fd5b50565b6000815190506100d5816100af565b92915050565b6000602082840312156100f1576100f0610078565b5b60006100ff848285016100c6565b91505092915050565b61023e806101176000396000f3fe6080604052600436106100225760003560e01c80634f5aaaba1461002e57610029565b3661002957005b600080fd5b34801561003a57600080fd5b5061005560048036038101906100509190610181565b610057565b005b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16634f5aaaba83836040518363ffffffff1660e01b81526004016100b29291906101df565b600060405180830381600087803b1580156100cc57600080fd5b505af11580156100e0573d6000803e3d6000fd5b505050505050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610118826100ed565b9050919050565b6101288161010d565b811461013357600080fd5b50565b6000813590506101458161011f565b92915050565b6000819050919050565b61015e8161014b565b811461016957600080fd5b50565b60008135905061017b81610155565b92915050565b60008060408385031215610198576101976100e8565b5b60006101a685828601610136565b92505060206101b78582860161016c565b9150509250929050565b6101ca8161010d565b82525050565b6101d98161014b565b82525050565b60006040820190506101f460008301856101c1565b61020160208301846101d0565b939250505056fea264697066735822122015e7ba7848e540abe7669436e9631d564fdabb8aa8f73116cc6ce8bff34ee7e764736f6c634300081e0033", } // NativeMinterTestABI is the input ABI used to generate the binding from. diff --git a/precompile/contracts/nativeminter/nativemintertest/simulated_test.go b/precompile/contracts/nativeminter/simulated_test.go similarity index 89% rename from precompile/contracts/nativeminter/nativemintertest/simulated_test.go rename to precompile/contracts/nativeminter/simulated_test.go index a7e928c73d..e915319853 100644 --- a/precompile/contracts/nativeminter/nativemintertest/simulated_test.go +++ b/precompile/contracts/nativeminter/simulated_test.go @@ -1,7 +1,7 @@ // Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. -package nativemintertest +package nativeminter_test import ( "math/big" @@ -24,6 +24,7 @@ import ( "github.com/ava-labs/subnet-evm/utils" sim "github.com/ava-labs/subnet-evm/ethclient/simulated" + nativeminterbindings "github.com/ava-labs/subnet-evm/precompile/contracts/nativeminter/nativemintertest/bindings" ) var ( @@ -61,9 +62,9 @@ func newBackendWithNativeMinter(t *testing.T) *sim.Backend { // Helper functions to reduce test boilerplate -func deployNativeMinterTest(t *testing.T, b *sim.Backend, auth *bind.TransactOpts) (common.Address, *NativeMinterTest) { +func deployNativeMinterTest(t *testing.T, b *sim.Backend, auth *bind.TransactOpts) (common.Address, *nativeminterbindings.NativeMinterTest) { t.Helper() - addr, tx, contract, err := DeployNativeMinterTest(auth, b.Client(), nativeminter.ContractAddress) + addr, tx, contract, err := nativeminterbindings.DeployNativeMinterTest(auth, b.Client(), nativeminter.ContractAddress) require.NoError(t, err) testutils.WaitReceiptSuccessful(t, b, tx) return addr, contract @@ -78,13 +79,13 @@ func TestNativeMinter(t *testing.T) { type testCase struct { name string - test func(t *testing.T, backend *sim.Backend, nativeMinterIntf *INativeMinter) + test func(t *testing.T, backend *sim.Backend, nativeMinterIntf *nativeminterbindings.INativeMinter) } testCases := []testCase{ { name: "admin can mint directly", - test: func(t *testing.T, backend *sim.Backend, nativeMinter *INativeMinter) { + test: func(t *testing.T, backend *sim.Backend, nativeMinter *nativeminterbindings.INativeMinter) { testAddr := common.HexToAddress("0x1234567890123456789012345678901234567890") initialBalance, err := backend.Client().BalanceAt(t.Context(), testAddr, nil) @@ -104,7 +105,7 @@ func TestNativeMinter(t *testing.T) { }, { name: "unprivileged user cannot mint directly", - test: func(t *testing.T, _ *sim.Backend, nativeMinter *INativeMinter) { + test: func(t *testing.T, _ *sim.Backend, nativeMinter *nativeminterbindings.INativeMinter) { testAddr := common.HexToAddress("0x1234567890123456789012345678901234567890") // Unprivileged user tries to mint - should fail @@ -114,7 +115,7 @@ func TestNativeMinter(t *testing.T) { }, { name: "contract without permission cannot mint", - test: func(t *testing.T, backend *sim.Backend, nativeMinter *INativeMinter) { + test: func(t *testing.T, backend *sim.Backend, nativeMinter *nativeminterbindings.INativeMinter) { testContractAddr, testContract := deployNativeMinterTest(t, backend, admin) testutils.VerifyRole(t, nativeMinter, testContractAddr, allowlist.NoRole) @@ -128,7 +129,7 @@ func TestNativeMinter(t *testing.T) { }, { name: "contract can be added to allow list", - test: func(t *testing.T, backend *sim.Backend, nativeMinter *INativeMinter) { + test: func(t *testing.T, backend *sim.Backend, nativeMinter *nativeminterbindings.INativeMinter) { testContractAddr, _ := deployNativeMinterTest(t, backend, admin) testutils.VerifyRole(t, nativeMinter, testContractAddr, allowlist.NoRole) @@ -140,7 +141,7 @@ func TestNativeMinter(t *testing.T) { }, { name: "enabled contract can mint", - test: func(t *testing.T, backend *sim.Backend, nativeMinter *INativeMinter) { + test: func(t *testing.T, backend *sim.Backend, nativeMinter *nativeminterbindings.INativeMinter) { testContractAddr, testContract := deployNativeMinterTest(t, backend, admin) testAddr := common.HexToAddress("0x1234567890123456789012345678901234567890") @@ -168,7 +169,7 @@ func TestNativeMinter(t *testing.T) { backend := newBackendWithNativeMinter(t) defer backend.Close() - nativeMinter, err := NewINativeMinter(nativeminter.ContractAddress, backend.Client()) + nativeMinter, err := nativeminterbindings.NewINativeMinter(nativeminter.ContractAddress, backend.Client()) require.NoError(t, err) tc.test(t, backend, nativeMinter) @@ -185,7 +186,7 @@ func TestINativeMinter_Events(t *testing.T) { backend := newBackendWithNativeMinter(t) defer backend.Close() - nativeMinter, err := NewINativeMinter(nativeminter.ContractAddress, backend.Client()) + nativeMinter, err := nativeminterbindings.NewINativeMinter(nativeminter.ContractAddress, backend.Client()) require.NoError(t, err) t.Run("should emit NativeCoinMinted event", func(t *testing.T) {