build: run full unit test cases, except ./tests

This commit is contained in:
NathanBSC 2023-09-13 11:46:47 +08:00 committed by buddho
parent fe5df933b6
commit 782aea5841
5 changed files with 58 additions and 22 deletions

@ -333,10 +333,7 @@ func doTest(cmdline []string) {
gotest.Args = append(gotest.Args, "-race") gotest.Args = append(gotest.Args, "-race")
} }
packages := []string{"./accounts/...", "./cmd/geth/...", "./common/...", "./consensus/...", "./console/...", packages := []string{"./..."}
"./core/...", "./crypto/...", "./eth/...", "./ethstats/...", "./ethclient/...", "./ethdb/...", "./event/...",
"./graphql/...", "./internal/...", "./les/...", "./light/...", "./log/...", "./metrics/...", "./miner/...",
"./node/...", "./p2p/...", "./params/...", "./rlp/...", "./rpc/...", "./signer/...", "./tests/...", "./trie/..."}
if len(flag.CommandLine.Args()) > 0 { if len(flag.CommandLine.Args()) > 0 {
packages = flag.CommandLine.Args() packages = flag.CommandLine.Args()
} }

@ -30,6 +30,7 @@ import (
"github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/eth/protocols/eth" "github.com/ethereum/go-ethereum/eth/protocols/eth"
"github.com/ethereum/go-ethereum/internal/utesting" "github.com/ethereum/go-ethereum/internal/utesting"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/p2p" "github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/p2p/rlpx" "github.com/ethereum/go-ethereum/p2p/rlpx"
) )
@ -202,6 +203,29 @@ loop:
if err := c.Write(status); err != nil { if err := c.Write(status); err != nil {
return nil, fmt.Errorf("write to connection failed: %v", err) return nil, fmt.Errorf("write to connection failed: %v", err)
} }
// exchange UpgradeStatus
if c.negotiatedProtoVersion >= eth.ETH67 {
extensionRaw, _ := (&eth.UpgradeStatusExtension{}).Encode()
upgradeStatus := UpgradeStatus{
Extension: extensionRaw,
}
if err := c.Write(upgradeStatus); err != nil {
return nil, fmt.Errorf("write to connection failed: %v", err)
}
switch msg := c.Read().(type) {
case *UpgradeStatus:
log.Debug("receive UpgradeStatus")
case *Disconnect:
return nil, fmt.Errorf("disconnect received: %v", msg.Reason)
case *Ping:
c.Write(&Pong{}) // TODO (renaynay): in the future, this should be an error
// (PINGs should not be a response upon fresh connection)
default:
return nil, fmt.Errorf("bad status message: %s", pretty.Sdump(msg))
}
}
return message, nil return message, nil
} }

@ -80,10 +80,11 @@ func TestSnapSuite(t *testing.T) {
func runGeth() (*node.Node, error) { func runGeth() (*node.Node, error) {
stack, err := node.New(&node.Config{ stack, err := node.New(&node.Config{
P2P: p2p.Config{ P2P: p2p.Config{
ListenAddr: "127.0.0.1:0", ListenAddr: "127.0.0.1:0",
NoDiscovery: true, NoDiscovery: true,
MaxPeers: 10, // in case a test requires multiple connections, can be changed in the future MaxPeers: 10, // in case a test requires multiple connections, can be changed in the future
NoDial: true, MaxPeersPerIP: 10,
NoDial: true,
}, },
}) })
if err != nil { if err != nil {
@ -116,6 +117,7 @@ func setupGeth(stack *node.Node) error {
TrieDirtyCache: 16, TrieDirtyCache: 16,
TrieTimeout: 60 * time.Minute, TrieTimeout: 60 * time.Minute,
SnapshotCache: 10, SnapshotCache: 10,
TriesInMemory: 128,
}) })
if err != nil { if err != nil {
return err return err

@ -87,6 +87,11 @@ type Status eth.StatusPacket
func (msg Status) Code() int { return 16 } func (msg Status) Code() int { return 16 }
func (msg Status) ReqID() uint64 { return 0 } func (msg Status) ReqID() uint64 { return 0 }
type UpgradeStatus eth.UpgradeStatusPacket
func (msg UpgradeStatus) Code() int { return 27 } // p2p.baseProtocolLength + eth.UpgradeStatusMsg
func (msg UpgradeStatus) ReqID() uint64 { return 0 }
// NewBlockHashes is the network packet for the block announcements. // NewBlockHashes is the network packet for the block announcements.
type NewBlockHashes eth.NewBlockHashesPacket type NewBlockHashes eth.NewBlockHashesPacket
@ -179,6 +184,8 @@ func (c *Conn) Read() Message {
msg = new(Disconnect) msg = new(Disconnect)
case (Status{}).Code(): case (Status{}).Code():
msg = new(Status) msg = new(Status)
case (UpgradeStatus{}).Code():
msg = new(UpgradeStatus)
case (GetBlockHeaders{}).Code(): case (GetBlockHeaders{}).Code():
ethMsg := new(eth.GetBlockHeadersPacket66) ethMsg := new(eth.GetBlockHeadersPacket66)
if err := rlp.DecodeBytes(rawData, ethMsg); err != nil { if err := rlp.DecodeBytes(rawData, ethMsg); err != nil {

@ -243,14 +243,17 @@ func TestT8n(t *testing.T) {
output: t8nOutput{alloc: false, result: false}, output: t8nOutput{alloc: false, result: false},
expExitCode: 3, expExitCode: 3,
}, },
{ // Test base fee calculation // base fee logic is different with go-ethereum
base: "./testdata/25", /*
input: t8nInput{ { // Test base fee calculation
"alloc.json", "txs.json", "env.json", "Merge", "", base: "./testdata/25",
input: t8nInput{
"alloc.json", "txs.json", "env.json", "Merge", "",
},
output: t8nOutput{alloc: true, result: true},
expOut: "exp.json",
}, },
output: t8nOutput{alloc: true, result: true}, */
expOut: "exp.json",
},
{ // Test withdrawals transition { // Test withdrawals transition
base: "./testdata/26", base: "./testdata/26",
input: t8nInput{ input: t8nInput{
@ -259,14 +262,17 @@ func TestT8n(t *testing.T) {
output: t8nOutput{alloc: true, result: true}, output: t8nOutput{alloc: true, result: true},
expOut: "exp.json", expOut: "exp.json",
}, },
{ // Cancun tests // TODO: Cancun not ready
base: "./testdata/28", /*
input: t8nInput{ { // Cancun tests
"alloc.json", "txs.rlp", "env.json", "Cancun", "", base: "./testdata/28",
input: t8nInput{
"alloc.json", "txs.rlp", "env.json", "Cancun", "",
},
output: t8nOutput{alloc: true, result: true},
expOut: "exp.json",
}, },
output: t8nOutput{alloc: true, result: true}, */
expOut: "exp.json",
},
} { } {
args := []string{"t8n"} args := []string{"t8n"}
args = append(args, tc.output.get()...) args = append(args, tc.output.get()...)