Skip to content
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

testgen: added EIP 7702 transaction receipt test and SignAuth #38

Merged
merged 8 commits into from
Jan 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions testgen/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,21 @@ func (c *Chain) MustSignTx(from common.Address, txdata types.TxData) *types.Tran
return types.MustSignNewTx(acc.Key, signer, txdata)
}

// SignAuth signs a SetCode Authorization for the specified from account, so long as that
// account was in the hivechain accounts dump.
func (c *Chain) SignAuth(from common.Address, auth types.SetCodeAuthorization) (types.SetCodeAuthorization, error) {
acc, ok := c.senders[from]
if !ok {
panic(fmt.Errorf("account not available for signing: %s", from))
}

signedAuth, err := types.SignSetCode(acc.Key, auth)
if err != nil {
return types.SetCodeAuthorization{}, err
}
return signedAuth, nil
}

func loadGenesis(genesisFile string) (core.Genesis, error) {
chainConfig, err := os.ReadFile(genesisFile)
if err != nil {
Expand Down
18 changes: 18 additions & 0 deletions testgen/generators.go
Original file line number Diff line number Diff line change
Expand Up @@ -1264,6 +1264,24 @@ var EthGetTransactionReceipt = MethodTests{
return nil
},
},
{
Name: "get-setcode-tx",
About: "gets the receipt for a EIP-7702 setcode transaction",
Run: func(ctx context.Context, t *T) error {
txhash := t.chain.txinfo.EIP7702.AuthorizeTx
receipt, err := t.eth.TransactionReceipt(ctx, txhash)
if err != nil {
return err
}
if receipt.TxHash != txhash {
return fmt.Errorf("wrong receipt returned")
}
if receipt.Type != types.SetCodeTxType {
return fmt.Errorf("wrong tx type in receipt")
}
return nil
},
},
{
Name: "get-empty-tx",
About: "requests the receipt for the zero tx hash",
Expand Down