Skip to content
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
945cf95
refactor(systemtests): change CheckTxsQueuedSync to CheckTxsQueuedAsync
cloudgray Oct 14, 2025
7723a96
refactor(systemtests): remove calling AfterEachAction from TestTxsOrd…
cloudgray Oct 14, 2025
b200286
refactor(systemtests): refactor account type
cloudgray Oct 14, 2025
c547ce0
refactor(systemtests): apply mutex for accounts
cloudgray Oct 14, 2025
6c54985
refactor(systemtests): apply account pool to test cases
cloudgray Oct 14, 2025
4545f7a
refactor(systemtests): apply account pool to eip7702 test
cloudgray Oct 14, 2025
9f81d0d
refactor(systemtests): fix CheckTxsQueuedAsync
cloudgray Oct 14, 2025
544dd55
refactor(systemtests): apply global chain
cloudgray Oct 14, 2025
74b48ba
refactor(systemtests): fix eip7702 test
cloudgray Oct 14, 2025
bcb7711
refactor(systemtests): fix test suite
cloudgray Oct 14, 2025
9210700
chore(systemtests): refactor test suite
cloudgray Oct 14, 2025
a2bb3fc
refactor(systemtests): fix eip712 test
cloudgray Oct 14, 2025
d9bf2eb
refactor(systemtests): fix validation method
cloudgray Oct 14, 2025
807bbe9
refactor(systemtests): refactor suite
cloudgray Oct 14, 2025
0fca2e4
WIP: refactor test suite
cloudgray Oct 14, 2025
fefa55b
chore: modify makefile
cloudgray Oct 14, 2025
7196b9f
Merge branch 'main' into refactor/systemtests
aljo242 Oct 15, 2025
b3477b9
refactor: change upgrade test file name and apply --mempool.max-txs=0…
cloudgray Oct 17, 2025
c56e5a0
refactor test suite
cloudgray Oct 17, 2025
4927921
refactor(systemtest): add test cases
cloudgray Oct 17, 2025
dda7167
refactor(systemtest): enable chainupgrade test
cloudgray Oct 17, 2025
219f64d
refactor(systemtest): refactor suite
cloudgray Oct 17, 2025
9db3ac0
fix system tests
cloudgray Oct 17, 2025
f6f5410
fix system tests
cloudgray Oct 17, 2025
5f3fba5
Merge branch 'main' into refactor/systemtests
cloudgray Oct 17, 2025
f8499e5
fix system tests
cloudgray Oct 17, 2025
f83b2e5
refactor test cases
cloudgray Oct 17, 2025
f57e42c
chore: change test name
cloudgray Oct 17, 2025
dc8e0d0
fix upgrade test
cloudgray Oct 17, 2025
fd4dccd
fix upgrade test
cloudgray Oct 17, 2025
06cff50
Merge branch 'main' into refactor/systemtests
cloudgray Oct 19, 2025
3bafdd6
resolve merge conflic
cloudgray Oct 19, 2025
4d456b4
test(systemtests): remove additional test accounts setting
cloudgray Oct 20, 2025
491aca4
test(systemtests): fix helper function for pending txs
cloudgray Oct 20, 2025
e3fe2e8
test(systemtests): fix test case
cloudgray Oct 20, 2025
c5a21e9
tet(systemtests): refactor test execution
cloudgray Oct 20, 2025
8479fa1
test(systemtests): remove account pool
cloudgray Oct 20, 2025
0addd12
test(systemtests): fix pending cosmos tx verification
cloudgray Oct 20, 2025
349afbd
chore: update CHANGELOG.md
cloudgray Oct 20, 2025
b8ec74d
chore: update comments
cloudgray Oct 20, 2025
e922c54
test(systemtests): increase block time of replacement test cases
cloudgray Oct 20, 2025
289fb7b
fix: rollback block time increase for test
cloudgray Oct 20, 2025
50ac4e6
test(systemtests): apply 6s blocktime only for specific test case
cloudgray Oct 20, 2025
6ae5a77
test(systemtests): apply 9s blocktime only for specific test case
cloudgray Oct 20, 2025
786b4d3
chore: modify Makefile
cloudgray Oct 20, 2025
4b20c3e
test(systemtest): disable non-deterministic test case
cloudgray Oct 20, 2025
9523ea5
Merge branch 'main' into refactor/systemtests
cloudgray Oct 21, 2025
6cacc47
resolve merge conflict
cloudgray Oct 23, 2025
3dc5193
Merge branch 'main' into refactor/systemtests
cloudgray Oct 23, 2025
b6fb49b
Merge branch 'main' into refactor/systemtests
cloudgray Oct 27, 2025
9aa206e
Merge branch 'main' into refactor/systemtests
aljo242 Oct 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions tests/systemtests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
WAIT_TIME ?= 20s

test:
go test -failfast -timeout=30m -p=1 -mod=readonly -tags='system_test' -v ./... -run TestTxsOrdering --wait-time=$(WAIT_TIME) --block-time=3s --binary evmd --chain-id local-4221
go test -failfast -timeout=30m -p=1 -mod=readonly -tags='system_test' -v ./... -run TestTxsReplacement --wait-time=$(WAIT_TIME) --block-time=9.5s --binary evmd --chain-id local-4221
go test -failfast -timeout=30m -p=1 -mod=readonly -tags='system_test' -v ./... -run TestExceptions --wait-time=$(WAIT_TIME) --block-time=8s --binary evmd --chain-id local-4221
go test -failfast -timeout=30m -p=1 -mod=readonly -tags='system_test' -v ./... -run TestEIP7702 --wait-time=$(WAIT_TIME) --block-time=5s --binary evmd --chain-id local-4221
go test -failfast -timeout=30m -p=1 -mod=readonly -tags='system_test' -v ./... -run TestEIP712 --wait-time=$(WAIT_TIME) --block-time=5s --binary evmd --chain-id local-4221
go test -failfast -timeout=30m -p=1 -mod=readonly -tags='system_test' -v ./... -run 'TestUpgrade|TestEth' --wait-time=$(WAIT_TIME) --block-time=5s --binary evmd --chain-id local-4221
go test -failfast -timeout=30m -mod=readonly -tags='system_test' -v ./... --block-time=8s --binary evmd --chain-id local-4221
# go test -failfast -timeout=30m -mod=readonly -tags='system_test' -v ./... -run TestTxsOrdering --wait-time=$(WAIT_TIME) --block-time=3s --binary evmd --chain-id local-4221
# go test -failfast -timeout=30m -mod=readonly -tags='system_test' -v ./... -run TestTxsReplacement --wait-time=$(WAIT_TIME) --block-time=9.5s --binary evmd --chain-id local-4221
# go test -failfast -timeout=30m -mod=readonly -tags='system_test' -v ./... -run TestExceptions --wait-time=$(WAIT_TIME) --block-time=8s --binary evmd --chain-id local-4221
# go test -failfast -timeout=30m -mod=readonly -tags='system_test' -v ./... -run TestEIP7702 --wait-time=$(WAIT_TIME) --block-time=5s --binary evmd --chain-id local-4221
# go test -failfast -timeout=30m -mod=readonly -tags='system_test' -v ./... -run TestEIP712 --wait-time=$(WAIT_TIME) --block-time=5s --binary evmd --chain-id local-4221
# go test -failfast -timeout=30m -mod=readonly -tags='system_test' -v ./... -run 'TestUpgrade|TestEth' --wait-time=$(WAIT_TIME) --block-time=5s --binary evmd --chain-id local-4221
31 changes: 0 additions & 31 deletions tests/systemtests/accountabstraction/interface.go

This file was deleted.

73 changes: 44 additions & 29 deletions tests/systemtests/accountabstraction/test_eip7702.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,41 @@ import (
. "github.com/onsi/ginkgo/v2"
//nolint:revive // dot imports are fine for Ginkgo
. "github.com/onsi/gomega"
)

func TestEIP7702(t *testing.T) {
const (
user0 = "acc0"
user1 = "acc1"
)
basesuite "github.com/cosmos/evm/tests/systemtests/suite"
)

func RunEIP7702(t *testing.T, base *basesuite.SystemTestSuite) {
Describe("test EIP-7702 scenorios", Ordered, func() {
var (
s AccountAbstractionTestSuite
s *TestSuite
user0Acc *basesuite.TestAccount
user1Acc *basesuite.TestAccount
user0 string
user1 string
)

// We intentionally use BeforeAll instead of BeforeAll because,
// The test takes too much time if we restart network for each test case.
BeforeAll(func() {
s = NewTestSuite(t)
s = NewTestSuite(base)
user0Acc = s.SystemTestSuite.AcquireAcc()
user1Acc = s.SystemTestSuite.AcquireAcc()
user0 = user0Acc.ID
user1 = user1Acc.ID
s.SetPrimaryAccount(user0Acc)
s.SetupTest(t)
})

AfterAll(func() {
if user0Acc != nil {
s.SystemTestSuite.ReleaseAcc(user0Acc)
}
if user1Acc != nil {
s.SystemTestSuite.ReleaseAcc(user1Acc)
}
})

AfterEach(func() {
// Reset code of EoAs to 0x0 address
//
Expand Down Expand Up @@ -59,20 +74,20 @@ func TestEIP7702(t *testing.T) {
authChainID func() uint64
authNonce func() uint64
authAddress func() common.Address
authSigner string
txSender string
authSigner func() string
txSender func() string
expDelegation bool
}

DescribeTable("SetCode authorization scenarios", func(tc testCase) {
authorization := createSetCodeAuthorization(tc.authChainID(), tc.authNonce(), tc.authAddress())
signedAuthorization, err := signSetCodeAuthorization(s.GetPrivKey(tc.authSigner), authorization)
signedAuthorization, err := signSetCodeAuthorization(s.GetPrivKey(tc.authSigner()), authorization)
Expect(err).To(BeNil())

txHash, err := s.SendSetCodeTx(tc.txSender, signedAuthorization)
txHash, err := s.SendSetCodeTx(tc.txSender(), signedAuthorization)
Expect(err).To(BeNil(), "error while sending SetCode tx")
s.WaitForCommit(txHash)
s.CheckSetCode(tc.authSigner, tc.authAddress(), tc.expDelegation)
s.CheckSetCode(tc.authSigner(), tc.authAddress(), tc.expDelegation)
},
Entry("setCode with invalid chainID should fail", testCase{
authChainID: func() uint64 { return s.GetChainID() + 1 },
Expand All @@ -82,8 +97,8 @@ func TestEIP7702(t *testing.T) {
authAddress: func() common.Address {
return s.GetCounterAddr()
},
authSigner: user0,
txSender: user0,
authSigner: func() string { return user0 },
txSender: func() string { return user0 },
expDelegation: false,
}),
Entry("setCode with empty address should reset delegation", testCase{
Expand All @@ -94,8 +109,8 @@ func TestEIP7702(t *testing.T) {
authAddress: func() common.Address {
return common.HexToAddress("0x0")
},
authSigner: user0,
txSender: user0,
authSigner: func() string { return user0 },
txSender: func() string { return user0 },
expDelegation: false,
}),
Entry("setCode with invalid address should fail", testCase{
Expand All @@ -106,8 +121,8 @@ func TestEIP7702(t *testing.T) {
authAddress: func() common.Address {
return common.BytesToAddress([]byte("invalid"))
},
authSigner: user0,
txSender: user0,
authSigner: func() string { return user0 },
txSender: func() string { return user0 },
expDelegation: true,
}),
Entry("setCode with EoA address should fail", testCase{
Expand All @@ -118,8 +133,8 @@ func TestEIP7702(t *testing.T) {
authAddress: func() common.Address {
return s.GetAddr(user1)
},
authSigner: user0,
txSender: user0,
authSigner: func() string { return user0 },
txSender: func() string { return user0 },
expDelegation: true,
}),
Entry("same signer/sender with matching nonce should fail", testCase{
Expand All @@ -130,8 +145,8 @@ func TestEIP7702(t *testing.T) {
authAddress: func() common.Address {
return s.GetCounterAddr()
},
authSigner: user0,
txSender: user0,
authSigner: func() string { return user0 },
txSender: func() string { return user0 },
expDelegation: false,
}),
Entry("same signer/sender with future nonce sholud succeed", testCase{
Expand All @@ -142,8 +157,8 @@ func TestEIP7702(t *testing.T) {
authAddress: func() common.Address {
return s.GetCounterAddr()
},
authSigner: user0,
txSender: user0,
authSigner: func() string { return user0 },
txSender: func() string { return user0 },
expDelegation: true,
}),
Entry("different signer/sender with current nonce should succeed", testCase{
Expand All @@ -154,8 +169,8 @@ func TestEIP7702(t *testing.T) {
authAddress: func() common.Address {
return s.GetCounterAddr()
},
authSigner: user1,
txSender: user0,
authSigner: func() string { return user1 },
txSender: func() string { return user0 },
expDelegation: true,
}),
Entry("different signer/sender with future nonce should fail", testCase{
Expand All @@ -166,8 +181,8 @@ func TestEIP7702(t *testing.T) {
authAddress: func() common.Address {
return s.GetCounterAddr()
},
authSigner: user1,
txSender: user0,
authSigner: func() string { return user1 },
txSender: func() string { return user0 },
expDelegation: false,
}),
)
Expand Down
37 changes: 25 additions & 12 deletions tests/systemtests/accountabstraction/test_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,38 @@ import (
type TestSuite struct {
*basesuite.SystemTestSuite

counterAddress common.Address
counterABI abi.ABI
counterAddress common.Address
counterABI abi.ABI
primaryAccountID string
}

func NewTestSuite(t *testing.T) *TestSuite {
func NewTestSuite(base *basesuite.SystemTestSuite) *TestSuite {
return &TestSuite{
SystemTestSuite: basesuite.NewSystemTestSuite(t),
SystemTestSuite: base,
}
}

// SetPrimaryAccount configures the account that will be used for contract deployment/setup.
func (s *TestSuite) SetPrimaryAccount(acc *basesuite.TestAccount) {
if acc == nil {
return
}
s.primaryAccountID = acc.ID
}

// SetupTest setup test suite and deploy test contracts
func (s *TestSuite) SetupTest(t *testing.T) {
s.SystemTestSuite.SetupTest(t)

if s.primaryAccountID == "" {
s.primaryAccountID = s.AccID(0)
}

counterPath := filepath.Join("..", "Counter", "out", "Counter.sol", "Counter.json")
bytecode, err := loadContractCreationBytecode(counterPath)
Expect(err).To(BeNil(), "failed to load counter creation bytecode")

addr, err := deployContract(s.EthClient, bytecode)
addr, err := deployContract(s.EthClient, s.EthAccount(s.primaryAccountID), bytecode)
require.NoError(t, err, "failed to deploy counter contract")
s.counterAddress = addr

Expand Down Expand Up @@ -72,7 +85,7 @@ func (s *TestSuite) GetNonce(accID string) uint64 {

// GetSequence returns the Cosmos account sequence for the given account ID.
func (s *TestSuite) GetSequence(accID string) uint64 {
cosmosAcc := s.CosmosClient.Accs[accID]
cosmosAcc := s.CosmosAccount(accID)
ctx := s.CosmosClient.ClientCtx.WithClient(s.CosmosClient.RpcClients["node0"])
account, err := ctx.AccountRetriever.GetAccount(ctx, cosmosAcc.AccAddress)
Expect(err).To(BeNil(), "unable to retrieve cosmos account for %s", accID)
Expand All @@ -81,12 +94,12 @@ func (s *TestSuite) GetSequence(accID string) uint64 {

// GetPrivKey returns ecdsa private key of account
func (s *TestSuite) GetPrivKey(accID string) *ecdsa.PrivateKey {
return s.EthClient.Accs[accID].PrivKey
return s.EthAccount(accID).PrivKey
}

// GetAddr returns ethereum address of account
func (s *TestSuite) GetAddr(accID string) common.Address {
return s.EthClient.Accs[accID].Address
return s.EthAccount(accID).Address
}

// GetCounterAddr returns the deployed counter contract address.
Expand All @@ -98,7 +111,7 @@ func (s *TestSuite) GetCounterAddr() common.Address {
func (s *TestSuite) SendSetCodeTx(accID string, signedAuths ...ethtypes.SetCodeAuthorization) (common.Hash, error) {
ctx := context.Background()
ethCli := s.EthClient.Clients["node0"]
acc := s.EthClient.Accs[accID]
acc := s.EthAccount(accID)
if acc == nil {
return common.Hash{}, fmt.Errorf("account %s not found", accID)
}
Expand Down Expand Up @@ -140,7 +153,7 @@ func (s *TestSuite) SendSetCodeTx(accID string, signedAuths ...ethtypes.SetCodeA

// CheckSetCode checks the account is EIP-7702 SetCode authorized.
func (s *TestSuite) CheckSetCode(authorityAccID string, delegate common.Address, expectDelegation bool) {
account := s.EthClient.Accs[authorityAccID]
account := s.EthAccount(authorityAccID)
Expect(account).ToNot(BeNil(), "account %s not found", authorityAccID)

ctx := context.Background()
Expand All @@ -163,7 +176,7 @@ func (s *TestSuite) CheckSetCode(authorityAccID string, delegate common.Address,

// InvokeCounter sends a transaction from the delegated account to execute a counter method.
func (s *TestSuite) InvokeCounter(accID string, method string, args ...interface{}) (common.Hash, error) {
account := s.EthClient.Accs[accID]
account := s.EthAccount(accID)
if account == nil {
return common.Hash{}, fmt.Errorf("account %s not found", accID)
}
Expand Down Expand Up @@ -224,7 +237,7 @@ func (s *TestSuite) InvokeCounter(accID string, method string, args ...interface

// QueryCounterNumber queries the delegated counter contract via the account code.
func (s *TestSuite) QueryCounterNumber(accID string) (*big.Int, error) {
account := s.EthClient.Accs[accID]
account := s.EthAccount(accID)
if account == nil {
return nil, fmt.Errorf("account %s not found", accID)
}
Expand Down
3 changes: 1 addition & 2 deletions tests/systemtests/accountabstraction/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,11 @@ func loadContractABI(filePath string) (abi.ABI, error) {
return parsedABI, nil
}

func deployContract(ethClient *clients.EthClient, creationBytecode []byte) (common.Address, error) {
func deployContract(ethClient *clients.EthClient, deployer *clients.EthAccount, creationBytecode []byte) (common.Address, error) {
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()

ethCli := ethClient.Clients["node0"]
deployer := ethClient.Accs["acc0"]

chainID, err := ethCli.ChainID(ctx)
if err != nil {
Expand Down
Loading
Loading