Skip to content

Commit

Permalink
eth_getTransactionByBlockHashAndIndex tests and fix on parallel tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lucca30 committed Jan 12, 2025
1 parent 5646ee6 commit 3582958
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 10 deletions.
22 changes: 12 additions & 10 deletions internal/ethapi/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2085,8 +2085,6 @@ func mockStateSyncTxOnCurrentBlock(t *testing.T, backend *testBackend) common.Ha
}

func TestRPCGetTransactionReceipt(t *testing.T) {
t.Parallel()

var (
api, _, testSuite = setupTransactionsToApiTest(t)
)
Expand All @@ -2105,8 +2103,6 @@ func TestRPCGetTransactionReceipt(t *testing.T) {
}
}
func TestRPCGetTransactionByHash(t *testing.T) {
t.Parallel()

var (
api, _, testSuite = setupTransactionsToApiTest(t)
)
Expand All @@ -2126,8 +2122,6 @@ func TestRPCGetTransactionByHash(t *testing.T) {
}

func TestRPCGetBlockTransactionCountByHash(t *testing.T) {
t.Parallel()

var (
api, _, _ = setupTransactionsToApiTest(t)
)
Expand All @@ -2139,6 +2133,18 @@ func TestRPCGetBlockTransactionCountByHash(t *testing.T) {
require.Equal(t, expected, *cnt)
}

func TestRPCGetTransactionByBlockHashAndIndex(t *testing.T) {
var (
api, _, _ = setupTransactionsToApiTest(t)
)

blobTx := api.GetTransactionByBlockHashAndIndex(context.Background(), api.b.CurrentBlock().Hash(), 0)
stateSyncTx := api.GetTransactionByBlockHashAndIndex(context.Background(), api.b.CurrentBlock().Hash(), 1)

testRPCResponseWithFile(t, 0, blobTx, "eth_getTransactionByBlockHashAndIndex", "blob-tx")
testRPCResponseWithFile(t, 1, stateSyncTx, "eth_getTransactionByBlockHashAndIndex", "state-sync-tx")
}

func testRPCResponseWithFile(t *testing.T, testid int, result interface{}, rpc string, file string) {
data, err := json.MarshalIndent(result, "", " ")
if err != nil {
Expand All @@ -2157,8 +2163,6 @@ func testRPCResponseWithFile(t *testing.T, testid int, result interface{}, rpc s
}

func TestRPCGetTransactionReceiptsByBlock(t *testing.T) {
t.Parallel()

api, blockNrOrHash, testSuite := setupBlocksToApiTest(t)

receipts, err := api.GetTransactionReceiptsByBlock(context.Background(), blockNrOrHash)
Expand All @@ -2178,8 +2182,6 @@ func TestRPCGetTransactionReceiptsByBlock(t *testing.T) {
}

func TestRPCGetBlockReceipts(t *testing.T) {
t.Parallel()

api, blockNrOrHash, testSuite := setupBlocksToApiTest(t)

receipts, err := api.GetBlockReceipts(context.Background(), blockNrOrHash)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"blockHash": "0x4446b1498499cab37cfec330097fadf285c703444d431756940528d32fe0e97b",
"blockNumber": "0x6",
"from": "0x703c4b2bd70c169f5717101caee543299fc946c7",
"gas": "0x5208",
"gasPrice": "0x1b09d63b",
"maxFeePerGas": "0x1b09d82e",
"maxPriorityFeePerGas": "0x1",
"maxFeePerBlobGas": "0x1",
"hash": "0xb51ee3d2a89ba5d5623c73133c8d7a6ba9fb41194c17f4302c21b30994a1180f",
"input": "0x",
"nonce": "0x5",
"to": "0x0d3ab14bbad3d99f4203bd7a11acb94882050e7e",
"transactionIndex": "0x0",
"value": "0x0",
"type": "0x3",
"accessList": [],
"chainId": "0x1",
"blobVersionedHashes": [
"0x0100000000000000000000000000000000000000000000000000000000000000"
],
"v": "0x1",
"r": "0x38bb9fd000a5c38eab56c1b8ae96556fd58b417d2c8e175d22aadacbdea85d69",
"s": "0x2d50cc6ec19ce8d0736554e740ed7d451ac5e72488c186f87402d28bf301f0a3",
"yParity": "0x1"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"blockHash": "0x4446b1498499cab37cfec330097fadf285c703444d431756940528d32fe0e97b",
"blockNumber": "0x6",
"from": "0x0000000000000000000000000000000000000000",
"gas": "0x0",
"gasPrice": "0x0",
"hash": "0xfff9ab54386f3f5c5817e27cf1c8249968c13578c027389c021172d0568ebe12",
"input": "0x",
"nonce": "0x0",
"to": "0x0000000000000000000000000000000000000000",
"transactionIndex": "0x1",
"value": "0x0",
"type": "0x0",
"v": "0x0",
"r": "0x0",
"s": "0x0"
}

0 comments on commit 3582958

Please sign in to comment.