-
Notifications
You must be signed in to change notification settings - Fork 0
feat: blockstest and saetest.Wallet test helpers
#24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
alarso16
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actual mechanics look good to me, testing is super clear too
| } | ||
| } | ||
| b := build.NewBlock(t, txs, ModifyHeader(func(h *types.Header) { | ||
| h.GasLimit = 100e6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The gas limit is an annoying thing to have to specify every time, what if you just made it "sufficiently large" so that it won't cause problems for you rest?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only necessary when using a core.StateProcessor(), which will never be the case outside of this one single test as everything else will use the SAE executor.
| sdb, err := state.New(gen.SettledStateRoot(), state.NewDatabase(db), nil) | ||
| require.NoError(t, err, "state.New(genesis.SettledStateRoot())") | ||
| for i, addr := range wallet.Addresses() { | ||
| want := new(uint256.Int).SetAllOne() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could move this outside the loop, since it's shared
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I considered that, and in production I would, but I prioritised reducing cognitive load by co-locating the expected value with the assertion.
Co-authored-by: Austin Larson <78000745+alarso16@users.noreply.github.com> Signed-off-by: Arran Schlosberg <519948+ARR4N@users.noreply.github.com>
Introduces test-only builders of blocks and transactions. Maintaining block lineage and per-key nonces is a common pattern that I noticed in all of my SAE development, so these abstract them.
Testing is performed against a
libevm/core.BlockChainas the gold standard, as these helpers will be key to testing thesaexec.Executorto be introduced later.