Skip to content

test: expand stateful tests to test all stateful RPCs#5283

Open
JonathanOppenheimer wants to merge 5 commits intomasterfrom
JonathanOppenheimer/stateful-rpc-tests
Open

test: expand stateful tests to test all stateful RPCs#5283
JonathanOppenheimer wants to merge 5 commits intomasterfrom
JonathanOppenheimer/stateful-rpc-tests

Conversation

@JonathanOppenheimer
Copy link
Copy Markdown
Contributor

Why this should be merged

This PR add RPC-level tests for 6 state query methods: eth_getBalance, eth_getCode, eth_getStorageAt, eth_getProof, eth_estimateGas, and eth_createAccessList. I decided it would be cleanest if all of these RPC's just inhabited the same test, which I renamed to TestStatefulRPCs. This extension allows us to ensure each method is tested against both in-memory and on-disk block paths.

Closes #5244

@JonathanOppenheimer JonathanOppenheimer self-assigned this Apr 15, 2026
@JonathanOppenheimer JonathanOppenheimer added the evm Related to EVM functionality label Apr 15, 2026
Copilot AI review requested due to automatic review settings April 15, 2026 13:04
assert.Equal(t, uint256.NewInt(val).PaddedBytes(32), got)
blockNum := big.NewInt(int64(tt.num))

t.Run("eth_call", func(t *testing.T) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

// - eth_getHeaderByNumber
//
// Undocumented APIs:
// - eth_getBlockReceipts
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This RPC is actually already supported/tested, but it wasn't included in the list. When going through the list to add the ones for this PR, I thought I'd include it.

}

got, err := sut.CallContract(ctx, msg, big.NewInt(int64(tt.num)))
t.Logf("%T.CallContract(%+v, %d)", sut.Client, msg, tt.num) // avoids having to repeat in failure messages
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The test name hierarchy now provides this information

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Expands SAEVM RPC stateful testing to cover additional state-query JSON-RPC methods, ensuring they behave correctly across both in-memory and on-disk block lookup paths (issue #5244).

Changes:

  • Renamed/expanded the existing stateful RPC test into TestStatefulRPCs and added coverage for eth_getBalance, eth_getCode, eth_getStorageAt, eth_getProof, eth_estimateGas, and eth_createAccessList.
  • Added gethclient usage to exercise geth-specific methods (eth_getProof, eth_createAccessList) via client helpers.
  • Updated RPC server API list comments to reflect newly tested/available methods.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
vms/saevm/sae/rpc_stateful_test.go Expands the stateful RPC test to validate more state-query RPC methods across latest vs historical block paths.
vms/saevm/sae/rpc/server.go Updates the inline documentation list of registered eth_* APIs (comment-only change).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread vms/saevm/sae/rpc/server.go Outdated
Comment thread vms/saevm/sae/rpc_stateful_test.go Outdated
Copy link
Copy Markdown
Contributor

@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.

just few nits

Comment thread vms/saevm/sae/rpc_stateful_test.go
Comment on lines +243 to +244
common.LeftPadBytes(recv.Bytes(), 32),
common.Hash{}.Bytes(),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit/question: should we actually use abi.encode from abi package?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't know how much of an improvement that would be -- I think manually encoding is fine. There's a lot of ABI setup required, and the goal is test the RPCs. If you feel strongly I can change it.

Comment thread vms/saevm/sae/rpc_stateful_test.go
Comment thread vms/saevm/sae/rpc_stateful_test.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

evm Related to EVM functionality sae

Projects

None yet

Development

Successfully merging this pull request may close these issues.

API Support - state testing

3 participants