Skip to content

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

Closed
JonathanOppenheimer wants to merge 5 commits intomainfrom
JonathanOppenheimer/stateful-rpc-tests
Closed

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

Conversation

@JonathanOppenheimer
Copy link
Copy Markdown
Contributor

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 ava-labs/avalanchego#5244

@JonathanOppenheimer JonathanOppenheimer self-assigned this Mar 4, 2026
@JonathanOppenheimer JonathanOppenheimer added the testing Related to testing efforts label Mar 4, 2026
@JonathanOppenheimer JonathanOppenheimer marked this pull request as draft March 4, 2026 22:27
@JonathanOppenheimer JonathanOppenheimer added the DO NOT MERGE This PR is not meant to be merged in its current state label Mar 4, 2026
Comment thread sae/rpc.go Outdated
Comment thread sae/rpc_stateful_test.go
@JonathanOppenheimer JonathanOppenheimer force-pushed the JonathanOppenheimer/nonce-rpcs branch 2 times, most recently from daea4bb to 97f08b5 Compare March 5, 2026 17:23
@JonathanOppenheimer JonathanOppenheimer force-pushed the JonathanOppenheimer/stateful-rpc-tests branch from c36f3fa to b0a9eb6 Compare March 5, 2026 17:28
@JonathanOppenheimer JonathanOppenheimer force-pushed the JonathanOppenheimer/nonce-rpcs branch from 97f08b5 to eac6cee Compare March 10, 2026 14:26
@JonathanOppenheimer JonathanOppenheimer force-pushed the JonathanOppenheimer/stateful-rpc-tests branch from b0a9eb6 to 82407b0 Compare March 10, 2026 14:38
@JonathanOppenheimer JonathanOppenheimer marked this pull request as ready for review March 10, 2026 14:38
@JonathanOppenheimer JonathanOppenheimer force-pushed the JonathanOppenheimer/nonce-rpcs branch from 204b3cd to e8c58cf Compare March 13, 2026 15:11
@JonathanOppenheimer JonathanOppenheimer marked this pull request as draft March 13, 2026 16:54
Base automatically changed from JonathanOppenheimer/nonce-rpcs to main March 20, 2026 21:16
@JonathanOppenheimer JonathanOppenheimer force-pushed the JonathanOppenheimer/stateful-rpc-tests branch from 82407b0 to 54ee789 Compare March 23, 2026 17:17
@JonathanOppenheimer JonathanOppenheimer marked this pull request as ready for review March 23, 2026 17:17
Comment thread sae/rpc_stateful_test.go
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

Choose a reason for hiding this comment

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

Does it make sense to have all of these subtests in the same test? I think the answer is no, since a lot of these do not need the infrastrucure required by others

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.

wdym? these all require the sut. are you referring to the last two?

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.

Talked in person. I personally think leaving all of the appropriate tests in the loop so they can share the block test cases make sense, but I will split out the two outliers. Would appreciate other opinions.

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.

Actually, hm I still don't like doing this because, then I need to literally 1-1 triply duplicate escrowAddr, recv, sign, and b.

Thoughts?

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.

The single-test approach is the right call here I think. All 7 RPCs need identical expensive setup (VM init -> deploy -> execute -> settle -> evict), and the block-number (in-memory vs on-disk) is the shared property being tested. Splitting would either duplicate the setup code or if we do a shared helper it would carry around 10 values back via a struct which is more indirection for no gain, since each test function would collapse to a trivial few lines wrapper. Seeing all RPCs side by side is easier to read. The two outliers (eth_estimateGas, eth_createAccessList) are correctly outside the loop with a clear comment.

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.

Got it! Appreciate the vote of confidence haha.

@JonathanOppenheimer JonathanOppenheimer removed the DO NOT MERGE This PR is not meant to be merged in its current state label Mar 24, 2026
@JonathanOppenheimer
Copy link
Copy Markdown
Contributor Author

Replaced by ava-labs/avalanchego#5283

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

Labels

testing Related to testing efforts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

API Support - state testing

3 participants