test(ethclient): port ethclient tests from upstream (#2060)

This commit is contained in:
Daniel Liu 2026-03-02 02:45:01 +08:00 committed by GitHub
parent 2611f1dd9a
commit b991bd8aa7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 1138 additions and 2 deletions

1089
ethclient/ethclient_test.go Normal file

File diff suppressed because it is too large Load diff

35
ethclient/example_test.go Normal file
View file

@ -0,0 +1,35 @@
// Copyright 2024 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
// The go-ethereum library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// The go-ethereum library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
package ethclient_test
import (
"github.com/XinFinOrg/XDPoSChain/node"
)
var exampleNode *node.Node
// launch example server
func init() {
config := &node.Config{
HTTPHost: "127.0.0.1",
}
n, _, err := newTestBackend(config)
if err != nil {
panic("can't launch node: " + err.Error())
}
exampleNode = n
}

View file

@ -346,7 +346,7 @@ var (
// This configuration is intentionally not using keyed fields to force anyone
// adding flags to the config to also have to set these fields.
AllXDPoSProtocolChanges = &ChainConfig{
ChainID: big.NewInt(89),
ChainID: big.NewInt(1337),
HomesteadBlock: big.NewInt(0),
DAOForkBlock: nil,
DAOForkSupport: false,
@ -366,7 +366,19 @@ var (
OsakaBlock: big.NewInt(0),
Ethash: nil,
Clique: nil,
XDPoS: &XDPoSConfig{Period: 0, Epoch: 900},
XDPoS: &XDPoSConfig{
Epoch: 900,
Gap: 450,
SkipV1Validation: true,
FoundationWalletAddr: common.HexToAddress("0x0000000000000000000000000000000000000068"),
Reward: 250,
V2: &V2{
SwitchEpoch: 1,
SwitchBlock: big.NewInt(900),
CurrentConfig: UnitTestV2Configs[0],
AllConfigs: UnitTestV2Configs,
},
},
}
// AllCliqueProtocolChanges contains every protocol change (EIPs) introduced