Skip to content

Commit

Permalink
fix: testcases
Browse files Browse the repository at this point in the history
  • Loading branch information
anshalshukla committed Aug 26, 2024
1 parent 68d8614 commit 3c48fca
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 25 deletions.
13 changes: 7 additions & 6 deletions ethclient/ethclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
5 changes: 3 additions & 2 deletions ethclient/simulated/backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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,
Expand Down Expand Up @@ -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()

Expand Down
4 changes: 2 additions & 2 deletions internal/cli/snapshot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 16 additions & 15 deletions internal/ethapi/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3c48fca

Please sign in to comment.