Skip to content

Commit b8adb4c

Browse files
authored
tests: use 'sender' in state tests if present (#28023)
A while back, statetests started coming with sender baked in, which at least evmone makes use of. Let's make use of that too, and save some cycles.
1 parent fe24d22 commit b8adb4c

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

tests/gen_sttransaction.go

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/state_test_util.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ type stTransaction struct {
115115
GasLimit []uint64 `json:"gasLimit"`
116116
Value []string `json:"value"`
117117
PrivateKey []byte `json:"secretKey"`
118+
Sender *common.Address `json:"sender"`
118119
BlobVersionedHashes []common.Hash `json:"blobVersionedHashes,omitempty"`
119120
BlobGasFeeCap *big.Int `json:"maxFeePerBlobGas,omitempty"`
120121
}
@@ -359,9 +360,12 @@ func (t *StateTest) genesis(config *params.ChainConfig) *core.Genesis {
359360
}
360361

361362
func (tx *stTransaction) toMessage(ps stPostState, baseFee *big.Int) (*core.Message, error) {
362-
// Derive sender from private key if present.
363363
var from common.Address
364-
if len(tx.PrivateKey) > 0 {
364+
// If 'sender' field is present, use that
365+
if tx.Sender != nil {
366+
from = *tx.Sender
367+
} else if len(tx.PrivateKey) > 0 {
368+
// Derive sender from private key if needed.
365369
key, err := crypto.ToECDSA(tx.PrivateKey)
366370
if err != nil {
367371
return nil, fmt.Errorf("invalid private key: %v", err)

0 commit comments

Comments
 (0)