mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 07:06:42 +00:00
fix: testcases
This commit is contained in:
parent
68d8614b72
commit
3c48fca257
4 changed files with 28 additions and 25 deletions
|
|
@ -134,25 +134,26 @@ type rpcBlock struct {
|
||||||
|
|
||||||
func (ec *Client) getBlock(ctx context.Context, method string, args ...interface{}) (*types.Block, error) {
|
func (ec *Client) getBlock(ctx context.Context, method string, args ...interface{}) (*types.Block, error) {
|
||||||
var raw json.RawMessage
|
var raw json.RawMessage
|
||||||
|
|
||||||
err := ec.c.CallContext(ctx, &raw, method, args...)
|
err := ec.c.CallContext(ctx, &raw, method, args...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if len(raw) == 0 {
|
|
||||||
return nil, ethereum.NotFound
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decode header and transactions.
|
// Decode header and transactions.
|
||||||
var head *types.Header
|
var head *types.Header
|
||||||
|
|
||||||
var body rpcBlock
|
|
||||||
|
|
||||||
if err := json.Unmarshal(raw, &head); err != nil {
|
if err := json.Unmarshal(raw, &head); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
// When the block is not found, the API returns JSON null.
|
||||||
|
if head == nil {
|
||||||
|
return nil, ethereum.NotFound
|
||||||
|
}
|
||||||
|
|
||||||
|
var body rpcBlock
|
||||||
if err := json.Unmarshal(raw, &body); err != nil {
|
if err := json.Unmarshal(raw, &body); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Quick-verify transaction and uncle lists. This mostly helps with debugging the server.
|
// Quick-verify transaction and uncle lists. This mostly helps with debugging the server.
|
||||||
if head.UncleHash == types.EmptyUncleHash && len(body.UncleHashes) > 0 {
|
if head.UncleHash == types.EmptyUncleHash && len(body.UncleHashes) > 0 {
|
||||||
return nil, errors.New("server returned non-empty uncle list but block header indicates no uncles")
|
return nil, errors.New("server returned non-empty uncle list but block header indicates no uncles")
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ func newTx(sim *Backend, key *ecdsa.PrivateKey) (*types.Transaction, error) {
|
||||||
|
|
||||||
// create a signed transaction to send
|
// create a signed transaction to send
|
||||||
head, _ := client.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
|
head, _ := client.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
|
||||||
gasPrice := new(big.Int).Add(head.BaseFee, big.NewInt(params.GWei))
|
gasPrice := new(big.Int).Add(head.BaseFee, big.NewInt(25*params.GWei))
|
||||||
addr := crypto.PubkeyToAddress(key.PublicKey)
|
addr := crypto.PubkeyToAddress(key.PublicKey)
|
||||||
chainid, _ := client.ChainID(context.Background())
|
chainid, _ := client.ChainID(context.Background())
|
||||||
nonce, err := client.PendingNonceAt(context.Background(), addr)
|
nonce, err := client.PendingNonceAt(context.Background(), addr)
|
||||||
|
|
@ -61,7 +61,7 @@ func newTx(sim *Backend, key *ecdsa.PrivateKey) (*types.Transaction, error) {
|
||||||
tx := types.NewTx(&types.DynamicFeeTx{
|
tx := types.NewTx(&types.DynamicFeeTx{
|
||||||
ChainID: chainid,
|
ChainID: chainid,
|
||||||
Nonce: nonce,
|
Nonce: nonce,
|
||||||
GasTipCap: big.NewInt(params.GWei),
|
GasTipCap: big.NewInt(25 * params.GWei),
|
||||||
GasFeeCap: gasPrice,
|
GasFeeCap: gasPrice,
|
||||||
Gas: 21000,
|
Gas: 21000,
|
||||||
To: &addr,
|
To: &addr,
|
||||||
|
|
@ -114,6 +114,7 @@ func TestAdjustTime(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSendTransaction(t *testing.T) {
|
func TestSendTransaction(t *testing.T) {
|
||||||
|
t.Skip("not relevant to bor")
|
||||||
sim := simTestBackend(testAddr)
|
sim := simTestBackend(testAddr)
|
||||||
defer sim.Close()
|
defer sim.Close()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -179,11 +179,11 @@ func BlockchainCreator(t *testing.T, chaindbPath, AncientPath string, blockRemai
|
||||||
|
|
||||||
// Force run a freeze cycle
|
// Force run a freeze cycle
|
||||||
type freezer interface {
|
type freezer interface {
|
||||||
Freeze(threshold uint64) error
|
Freeze() error
|
||||||
Ancients() (uint64, error)
|
Ancients() (uint64, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = db.(freezer).Freeze(10)
|
err = db.(freezer).Freeze()
|
||||||
require.NoError(t, err, "failed to perform freeze operation")
|
require.NoError(t, err, "failed to perform freeze operation")
|
||||||
|
|
||||||
// make sure there're frozen items
|
// make sure there're frozen items
|
||||||
|
|
|
||||||
|
|
@ -1007,22 +1007,23 @@ func TestCall(t *testing.T) {
|
||||||
},
|
},
|
||||||
expectErr: core.ErrBlobTxCreate,
|
expectErr: core.ErrBlobTxCreate,
|
||||||
},
|
},
|
||||||
|
// BOR Doens't support blob tx
|
||||||
// BLOBHASH opcode
|
// BLOBHASH opcode
|
||||||
{
|
// {
|
||||||
blockNumber: rpc.LatestBlockNumber,
|
// blockNumber: rpc.LatestBlockNumber,
|
||||||
call: TransactionArgs{
|
// call: TransactionArgs{
|
||||||
From: &accounts[1].addr,
|
// From: &accounts[1].addr,
|
||||||
To: &randomAccounts[2].addr,
|
// To: &randomAccounts[2].addr,
|
||||||
BlobHashes: []common.Hash{{0x01, 0x22}},
|
// BlobHashes: []common.Hash{{0x01, 0x22}},
|
||||||
BlobFeeCap: (*hexutil.Big)(big.NewInt(1)),
|
// BlobFeeCap: (*hexutil.Big)(big.NewInt(1)),
|
||||||
},
|
// },
|
||||||
overrides: StateOverride{
|
// overrides: StateOverride{
|
||||||
randomAccounts[2].addr: {
|
// randomAccounts[2].addr: {
|
||||||
Code: hex2Bytes("60004960005260206000f3"),
|
// Code: hex2Bytes("60004960005260206000f3"),
|
||||||
},
|
// },
|
||||||
},
|
// },
|
||||||
want: "0x0122000000000000000000000000000000000000000000000000000000000000",
|
// want: "0x0122000000000000000000000000000000000000000000000000000000000000",
|
||||||
},
|
// },
|
||||||
}
|
}
|
||||||
for i, tc := range testSuite {
|
for i, tc := range testSuite {
|
||||||
result, err := api.Call(context.Background(), tc.call, &rpc.BlockNumberOrHash{BlockNumber: &tc.blockNumber}, &tc.overrides, &tc.blockOverrides)
|
result, err := api.Call(context.Background(), tc.call, &rpc.BlockNumberOrHash{BlockNumber: &tc.blockNumber}, &tc.overrides, &tc.blockOverrides)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue