mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-17 12:21:38 +00:00
test: make LargeReceiptBlock as a pointer
This commit is contained in:
parent
abf7f7366e
commit
cd9483648e
2 changed files with 10 additions and 11 deletions
|
|
@ -56,7 +56,7 @@ type Chain struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type txInfo struct {
|
type txInfo struct {
|
||||||
LargeReceiptBlock uint64 `json:"tx-largereceipt"`
|
LargeReceiptBlock *uint64 `json:"tx-largereceipt"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewChain takes the given chain.rlp file, and decodes and returns
|
// NewChain takes the given chain.rlp file, and decodes and returns
|
||||||
|
|
|
||||||
|
|
@ -426,7 +426,7 @@ func (s *Suite) TestGetReceipts(t *utesting.T) {
|
||||||
// Find some blocks containing receipts.
|
// Find some blocks containing receipts.
|
||||||
var hashes = make([]common.Hash, 0, 3)
|
var hashes = make([]common.Hash, 0, 3)
|
||||||
for i := range s.chain.Len() {
|
for i := range s.chain.Len() {
|
||||||
if uint64(i) == s.chain.txInfo.LargeReceiptBlock && conn.negotiatedProtoVersion < eth.ETH70 {
|
if s.chain.txInfo.LargeReceiptBlock != nil && uint64(i) == *s.chain.txInfo.LargeReceiptBlock {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
block := s.chain.GetBlock(i)
|
block := s.chain.GetBlock(i)
|
||||||
|
|
@ -484,37 +484,36 @@ func (s *Suite) TestGetReceipts(t *utesting.T) {
|
||||||
|
|
||||||
func (s *Suite) TestGetLargeReceipts(t *utesting.T) {
|
func (s *Suite) TestGetLargeReceipts(t *utesting.T) {
|
||||||
t.Log(`This test sends GetReceipts requests to the node for large receipt (>10MiB) in the test chain.
|
t.Log(`This test sends GetReceipts requests to the node for large receipt (>10MiB) in the test chain.
|
||||||
This test is meaningful only if the client supports protocol version greater than or equal to ETH70.`)
|
This test is meaningful only if the client supports protocol version ETH70 or higher
|
||||||
|
and LargeReceiptBlock is configured in txInfo.json.`)
|
||||||
conn, err := s.dialAndPeer(nil)
|
conn, err := s.dialAndPeer(nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("peering failed: %v", err)
|
t.Fatalf("peering failed: %v", err)
|
||||||
}
|
}
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
|
|
||||||
if conn.negotiatedProtoVersion < eth.ETH70 {
|
if conn.negotiatedProtoVersion < eth.ETH70 || s.chain.txInfo.LargeReceiptBlock == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find block with large receipt.
|
// Find block with large receipt.
|
||||||
// Place the large receipt block hash in the middle of the query
|
// Place the large receipt block hash in the middle of the query
|
||||||
start := max(s.chain.txInfo.LargeReceiptBlock-2, 0)
|
start := max(int(*s.chain.txInfo.LargeReceiptBlock)-2, 0)
|
||||||
end := min(s.chain.txInfo.LargeReceiptBlock+2, uint64(len(s.chain.blocks)))
|
end := min(*s.chain.txInfo.LargeReceiptBlock+2, uint64(len(s.chain.blocks)))
|
||||||
|
|
||||||
var blocks []common.Hash
|
var blocks []common.Hash
|
||||||
var receiptHashes []common.Hash
|
var receiptHashes []common.Hash
|
||||||
|
var receipts []*eth.ReceiptList69
|
||||||
|
|
||||||
for i := start; i < end; i++ {
|
for i := uint64(start); i < end; i++ {
|
||||||
block := s.chain.GetBlock(int(i))
|
block := s.chain.GetBlock(int(i))
|
||||||
blocks = append(blocks, block.Hash())
|
blocks = append(blocks, block.Hash())
|
||||||
receiptHashes = append(receiptHashes, block.Header().ReceiptHash)
|
receiptHashes = append(receiptHashes, block.Header().ReceiptHash)
|
||||||
|
receipts = append(receipts, ð.ReceiptList69{})
|
||||||
}
|
}
|
||||||
|
|
||||||
incomplete := false
|
incomplete := false
|
||||||
lastBlock := 0
|
lastBlock := 0
|
||||||
receipts := make([]*eth.ReceiptList69, len(blocks))
|
|
||||||
for i := range receipts {
|
|
||||||
receipts[i] = ð.ReceiptList69{}
|
|
||||||
}
|
|
||||||
|
|
||||||
for incomplete || lastBlock != len(blocks)-1 {
|
for incomplete || lastBlock != len(blocks)-1 {
|
||||||
// Create get receipt request.
|
// Create get receipt request.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue