This commit is contained in:
Jared Wasinger 2025-02-25 21:05:24 +01:00
parent 1501d8e99d
commit 1781bc8145

View file

@ -19,6 +19,9 @@ package ethtest
import ( import (
"crypto/rand" "crypto/rand"
"fmt" "fmt"
"reflect"
"sync"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/consensus/misc/eip4844" "github.com/ethereum/go-ethereum/consensus/misc/eip4844"
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
@ -29,8 +32,6 @@ import (
"github.com/ethereum/go-ethereum/p2p" "github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/p2p/enode" "github.com/ethereum/go-ethereum/p2p/enode"
"github.com/holiman/uint256" "github.com/holiman/uint256"
"reflect"
"sync"
) )
// Suite represents a structure used to test a node's conformance // Suite represents a structure used to test a node's conformance
@ -63,25 +64,27 @@ func NewSuite(dest *enode.Node, chainDir, engineURL, jwt string) (*Suite, error)
func (s *Suite) EthTests() []utesting.Test { func (s *Suite) EthTests() []utesting.Test {
return []utesting.Test{ return []utesting.Test{
// status /*
{Name: "Status", Fn: s.TestStatus}, // status
// get block headers {Name: "Status", Fn: s.TestStatus},
{Name: "GetBlockHeaders", Fn: s.TestGetBlockHeaders}, // get block headers
{Name: "SimultaneousRequests", Fn: s.TestSimultaneousRequests}, {Name: "GetBlockHeaders", Fn: s.TestGetBlockHeaders},
{Name: "SameRequestID", Fn: s.TestSameRequestID}, {Name: "SimultaneousRequests", Fn: s.TestSimultaneousRequests},
{Name: "ZeroRequestID", Fn: s.TestZeroRequestID}, {Name: "SameRequestID", Fn: s.TestSameRequestID},
// get block bodies {Name: "ZeroRequestID", Fn: s.TestZeroRequestID},
{Name: "GetBlockBodies", Fn: s.TestGetBlockBodies}, // get block bodies
// // malicious handshakes + status {Name: "GetBlockBodies", Fn: s.TestGetBlockBodies},
{Name: "MaliciousHandshake", Fn: s.TestMaliciousHandshake}, // // malicious handshakes + status
// test transactions {Name: "MaliciousHandshake", Fn: s.TestMaliciousHandshake},
{Name: "LargeTxRequest", Fn: s.TestLargeTxRequest, Slow: true}, // test transactions
{Name: "Transaction", Fn: s.TestTransaction}, {Name: "LargeTxRequest", Fn: s.TestLargeTxRequest, Slow: true},
{Name: "InvalidTxs", Fn: s.TestInvalidTxs}, {Name: "Transaction", Fn: s.TestTransaction},
{Name: "NewPooledTxs", Fn: s.TestNewPooledTxs}, {Name: "InvalidTxs", Fn: s.TestInvalidTxs},
{Name: "BlobViolations", Fn: s.TestBlobViolations}, {Name: "NewPooledTxs", Fn: s.TestNewPooledTxs},
{Name: "BlobViolations", Fn: s.TestBlobViolations},
*/
{Name: "TestBlobTxWithoutSidecar", Fn: s.TestBlobTxWithoutSidecar}, {Name: "TestBlobTxWithoutSidecar", Fn: s.TestBlobTxWithoutSidecar},
{Name: "TestBlobTxWithMismatchedSidecar", Fn: s.TestBlobTxWithMismatchedSidecar}, //{Name: "TestBlobTxWithMismatchedSidecar", Fn: s.TestBlobTxWithMismatchedSidecar},
} }
} }
@ -833,17 +836,12 @@ func (s *Suite) TestBlobViolations(t *utesting.T) {
// data has been modified to produce a different commitment hash. // data has been modified to produce a different commitment hash.
func mangleSidecar(tx *types.Transaction) *types.Transaction { func mangleSidecar(tx *types.Transaction) *types.Transaction {
sidecar := tx.BlobTxSidecar() sidecar := tx.BlobTxSidecar()
var copy types.BlobTxSidecar copy := types.BlobTxSidecar{
for _, b := range sidecar.Blobs { Blobs: append([]kzg4844.Blob{}, sidecar.Blobs...),
copy.Blobs = append(copy.Blobs, b) Commitments: append([]kzg4844.Commitment{}, sidecar.Commitments...),
Proofs: append([]kzg4844.Proof{}, sidecar.Proofs...),
} }
for _, c := range sidecar.Commitments { // zero the first commitment to alter the sidecar hash
copy.Commitments = append(copy.Commitments, c)
}
for _, p := range sidecar.Proofs {
copy.Proofs = append(copy.Proofs, p)
}
// zero the first commitment to create an invalid sidecar
copy.Commitments[0] = kzg4844.Commitment{} copy.Commitments[0] = kzg4844.Commitment{}
return tx.WithBlobTxSidecar(&copy) return tx.WithBlobTxSidecar(&copy)
} }
@ -999,10 +997,8 @@ func (s *Suite) testBadBlobTx(t *utesting.T, tx *types.Transaction, badTx *types
go goodPeer() go goodPeer()
go badPeer() go badPeer()
select { err := <-errc
case err := <-errc: if err != nil {
if err != nil { t.Fatalf("%v", err)
t.Fatalf("%v", err)
}
} }
} }