Skip to content

Commit 702f52f

Browse files
matthalpkaralabe
authored andcommitted
les: prefer nil slices over zero-length slices (#19081)
1 parent 6069b1a commit 702f52f

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

‎les/handler_test.go‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ func testGetBlockHeaders(t *testing.T, protocol int) {
159159
var reqID uint64
160160
for i, tt := range tests {
161161
// Collect the headers to expect in the response
162-
headers := []*types.Header{}
162+
var headers []*types.Header
163163
for _, hash := range tt.expect {
164164
headers = append(headers, bc.GetHeaderByHash(hash))
165165
}
@@ -212,8 +212,9 @@ func testGetBlockBodies(t *testing.T, protocol int) {
212212
var reqID uint64
213213
for i, tt := range tests {
214214
// Collect the hashes to request, and the response to expect
215-
hashes, seen := []common.Hash{}, make(map[int64]bool)
216-
bodies := []*types.Body{}
215+
var hashes []common.Hash
216+
seen := make(map[int64]bool)
217+
var bodies []*types.Body
217218

218219
for j := 0; j < tt.random; j++ {
219220
for {
@@ -313,7 +314,8 @@ func testGetReceipt(t *testing.T, protocol int) {
313314
bc := server.pm.blockchain.(*core.BlockChain)
314315

315316
// Collect the hashes to request, and the response to expect
316-
hashes, receipts := []common.Hash{}, []types.Receipts{}
317+
var receipts []types.Receipts
318+
var hashes []common.Hash
317319
for i := uint64(0); i <= bc.CurrentBlock().NumberU64(); i++ {
318320
block := bc.GetBlockByNumber(i)
319321

0 commit comments

Comments
 (0)