Skip to content

Commit

Permalink
Adds a few comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Kourin1996 committed Jan 14, 2025
1 parent de170a0 commit 244f5f9
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions internal/ethapi/celo_block_receipt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,29 @@ func TestGetBlockReceipt(t *testing.T) {
api = NewBlockChainAPI(backend)
)

// seedData stores Block and Receipts for specific hash and height into DB
seedData := func(t *testing.T, blockHash common.Hash, height uint64, headerBytes []byte, bodyBytes []byte, receiptsBytes []byte) {
t.Helper()

blockHeader := new(types.Header)
// Decode Header, Body, and Receipts
blockHeader := &types.Header{}
err := rlp.DecodeBytes(headerBytes, blockHeader)
require.NoError(t, err)

blockBody := new(types.Body)
blockBody := &types.Body{}
err = rlp.DecodeBytes(bodyBytes, blockBody)
require.NoError(t, err)

receipts := types.Receipts{}
err = rlp.DecodeBytes(receiptsBytes, &receipts)
receipts := &types.Receipts{}
err = rlp.DecodeBytes(receiptsBytes, receipts)
require.NoError(t, err)

block := types.NewBlockWithHeader(blockHeader).WithBody(*blockBody)

// Store data into DB
rawdb.WriteHeaderNumber(backend.ChainDb(), blockHash, height)
rawdb.WriteBlock(backend.ChainDb(), block)
rawdb.WriteReceipts(backend.ChainDb(), blockHash, height, receipts)
rawdb.WriteReceipts(backend.ChainDb(), blockHash, height, *receipts)

t.Cleanup(func() {
rawdb.DeleteReceipts(backend.ChainDb(), blockHash, height)
Expand All @@ -63,6 +66,7 @@ func TestGetBlockReceipt(t *testing.T) {
})
}

// createBlockReceiptBloom creates a Bloom for block receipt
createBlockReceiptBloom := func(logs []*types.Log) types.Bloom {
receipt := &types.Receipt{
Type: types.LegacyTxType,
Expand All @@ -74,6 +78,7 @@ func TestGetBlockReceipt(t *testing.T) {
return types.CreateBloom(types.Receipts{receipt})
}

// createExpectedResponse creates expected JSON-RPC response data
createExpectedResponse := func(blockHash common.Hash, blockNumber uint64, receiptIndex int, logs []*types.Log) map[string]interface{} {
return map[string]interface{}{
"blockHash": blockHash,
Expand Down

0 comments on commit 244f5f9

Please sign in to comment.