Skip to content

Commit

Permalink
tests: use 'sender' in state tests if present (ethereum#28023)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
holiman authored Aug 29, 2023
1 parent fe24d22 commit b8adb4c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 6 additions & 0 deletions tests/gen_sttransaction.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions tests/state_test_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ type stTransaction struct {
GasLimit []uint64 `json:"gasLimit"`
Value []string `json:"value"`
PrivateKey []byte `json:"secretKey"`
Sender *common.Address `json:"sender"`
BlobVersionedHashes []common.Hash `json:"blobVersionedHashes,omitempty"`
BlobGasFeeCap *big.Int `json:"maxFeePerBlobGas,omitempty"`
}
Expand Down Expand Up @@ -359,9 +360,12 @@ func (t *StateTest) genesis(config *params.ChainConfig) *core.Genesis {
}

func (tx *stTransaction) toMessage(ps stPostState, baseFee *big.Int) (*core.Message, error) {
// Derive sender from private key if present.
var from common.Address
if len(tx.PrivateKey) > 0 {
// If 'sender' field is present, use that
if tx.Sender != nil {
from = *tx.Sender
} else if len(tx.PrivateKey) > 0 {
// Derive sender from private key if needed.
key, err := crypto.ToECDSA(tx.PrivateKey)
if err != nil {
return nil, fmt.Errorf("invalid private key: %v", err)
Expand Down

0 comments on commit b8adb4c

Please sign in to comment.