From 3c48fca25752c38459c8dc354c1c6da44cb6ab69 Mon Sep 17 00:00:00 2001 From: anshalshukla Date: Tue, 27 Aug 2024 00:51:36 +0530 Subject: [PATCH] fix: testcases --- ethclient/ethclient.go | 13 ++++++------ ethclient/simulated/backend_test.go | 5 +++-- internal/cli/snapshot_test.go | 4 ++-- internal/ethapi/api_test.go | 31 +++++++++++++++-------------- 4 files changed, 28 insertions(+), 25 deletions(-) diff --git a/ethclient/ethclient.go b/ethclient/ethclient.go index 3be5bb720c..24356d0fd5 100644 --- a/ethclient/ethclient.go +++ b/ethclient/ethclient.go @@ -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") diff --git a/ethclient/simulated/backend_test.go b/ethclient/simulated/backend_test.go index f0c20539f8..04c03fb2cc 100644 --- a/ethclient/simulated/backend_test.go +++ b/ethclient/simulated/backend_test.go @@ -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() diff --git a/internal/cli/snapshot_test.go b/internal/cli/snapshot_test.go index 1a70d9c5af..6347608330 100644 --- a/internal/cli/snapshot_test.go +++ b/internal/cli/snapshot_test.go @@ -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 diff --git a/internal/ethapi/api_test.go b/internal/ethapi/api_test.go index a292d6a6e0..92262822ab 100644 --- a/internal/ethapi/api_test.go +++ b/internal/ethapi/api_test.go @@ -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)