Skip to content

Commit

Permalink
added receipts assertion (#11486)
Browse files Browse the repository at this point in the history
closes #11453

Co-authored-by: JkLondon <[email protected]>
  • Loading branch information
JkLondon and JkLondon authored Aug 5, 2024
1 parent faa564e commit ba32ef3
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions eth/protocols/eth/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package eth_test

import (
"github.com/erigontech/erigon/turbo/jsonrpc/receipts"
"math/big"
"testing"

Expand Down Expand Up @@ -87,7 +88,7 @@ func TestGetBlockReceipts(t *testing.T) {
}
// Assemble the test environment
m := mockWithGenerator(t, 4, generator)

receiptsGetter := receipts.NewGenerator(32, m.BlockReader, m.Engine)
// Collect the hashes to request, and the response to expect
var (
hashes []libcommon.Hash
Expand All @@ -100,13 +101,16 @@ func TestGetBlockReceipts(t *testing.T) {

hashes = append(hashes, block.Hash())
// If known, encode and queue for response packet
r := rawdb.ReadReceipts(tx, block, nil)

r, err := receiptsGetter.GetReceipts(m.Ctx, m.ChainConfig, tx, block)
require.NoError(t, err)
encoded, err := rlp.EncodeToBytes(r)
require.NoError(t, err)
receipts = append(receipts, encoded)
}
return nil
})

require.NoError(t, err)
b, err := rlp.EncodeToBytes(eth.GetReceiptsPacket66{RequestId: 1, GetReceiptsPacket: hashes})
require.NoError(t, err)
Expand All @@ -121,14 +125,10 @@ func TestGetBlockReceipts(t *testing.T) {

expect, err := rlp.EncodeToBytes(eth.ReceiptsRLPPacket66{RequestId: 1, ReceiptsRLPPacket: receipts})
require.NoError(t, err)
if m.HistoryV3 {
// GetReceiptsMsg disabled for historyV3
} else {
m.ReceiveWg.Wait()
sent := m.SentMessage(0)
require.Equal(t, eth.ToProto[m.SentryClient.Protocol()][eth.ReceiptsMsg], sent.Id)
require.Equal(t, expect, sent.Data)
}
m.ReceiveWg.Wait()
sent := m.SentMessage(0)
require.Equal(t, eth.ToProto[m.SentryClient.Protocol()][eth.ReceiptsMsg], sent.Id)
require.Equal(t, expect, sent.Data)
}

// newTestBackend creates a chain with a number of explicitly defined blocks and
Expand Down

0 comments on commit ba32ef3

Please sign in to comment.