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) {
|
||||
var raw json.RawMessage
|
||||
|
||||
err := ec.c.CallContext(ctx, &raw, method, args...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if len(raw) == 0 {
|
||||
return nil, ethereum.NotFound
|
||||
}
|
||||
|
||||
// Decode header and transactions.
|
||||
var head *types.Header
|
||||
|
||||
var body rpcBlock
|
||||
|
||||
if err := json.Unmarshal(raw, &head); err != nil {
|
||||
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 {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Quick-verify transaction and uncle lists. This mostly helps with debugging the server.
|
||||
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")
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ func newTx(sim *Backend, key *ecdsa.PrivateKey) (*types.Transaction, error) {
|
|||
|
||||
// create a signed transaction to send
|
||||
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)
|
||||
chainid, _ := client.ChainID(context.Background())
|
||||
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{
|
||||
ChainID: chainid,
|
||||
Nonce: nonce,
|
||||
GasTipCap: big.NewInt(params.GWei),
|
||||
GasTipCap: big.NewInt(25 * params.GWei),
|
||||
GasFeeCap: gasPrice,
|
||||
Gas: 21000,
|
||||
To: &addr,
|
||||
|
|
@ -114,6 +114,7 @@ func TestAdjustTime(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestSendTransaction(t *testing.T) {
|
||||
t.Skip("not relevant to bor")
|
||||
sim := simTestBackend(testAddr)
|
||||
defer sim.Close()
|
||||
|
||||
|
|
|
|||
|
|
@ -179,11 +179,11 @@ func BlockchainCreator(t *testing.T, chaindbPath, AncientPath string, blockRemai
|
|||
|
||||
// Force run a freeze cycle
|
||||
type freezer interface {
|
||||
Freeze(threshold uint64) error
|
||||
Freeze() error
|
||||
Ancients() (uint64, error)
|
||||
}
|
||||
|
||||
err = db.(freezer).Freeze(10)
|
||||
err = db.(freezer).Freeze()
|
||||
require.NoError(t, err, "failed to perform freeze operation")
|
||||
|
||||
// make sure there're frozen items
|
||||
|
|
|
|||
|
|
@ -1007,22 +1007,23 @@ func TestCall(t *testing.T) {
|
|||
},
|
||||
expectErr: core.ErrBlobTxCreate,
|
||||
},
|
||||
// BOR Doens't support blob tx
|
||||
// BLOBHASH opcode
|
||||
{
|
||||
blockNumber: rpc.LatestBlockNumber,
|
||||
call: TransactionArgs{
|
||||
From: &accounts[1].addr,
|
||||
To: &randomAccounts[2].addr,
|
||||
BlobHashes: []common.Hash{{0x01, 0x22}},
|
||||
BlobFeeCap: (*hexutil.Big)(big.NewInt(1)),
|
||||
},
|
||||
overrides: StateOverride{
|
||||
randomAccounts[2].addr: {
|
||||
Code: hex2Bytes("60004960005260206000f3"),
|
||||
},
|
||||
},
|
||||
want: "0x0122000000000000000000000000000000000000000000000000000000000000",
|
||||
},
|
||||
// {
|
||||
// blockNumber: rpc.LatestBlockNumber,
|
||||
// call: TransactionArgs{
|
||||
// From: &accounts[1].addr,
|
||||
// To: &randomAccounts[2].addr,
|
||||
// BlobHashes: []common.Hash{{0x01, 0x22}},
|
||||
// BlobFeeCap: (*hexutil.Big)(big.NewInt(1)),
|
||||
// },
|
||||
// overrides: StateOverride{
|
||||
// randomAccounts[2].addr: {
|
||||
// Code: hex2Bytes("60004960005260206000f3"),
|
||||
// },
|
||||
// },
|
||||
// want: "0x0122000000000000000000000000000000000000000000000000000000000000",
|
||||
// },
|
||||
}
|
||||
for i, tc := range testSuite {
|
||||
result, err := api.Call(context.Background(), tc.call, &rpc.BlockNumberOrHash{BlockNumber: &tc.blockNumber}, &tc.overrides, &tc.blockOverrides)
|
||||
|
|
|
|||
Loading…
Reference in a new issue