les: prefer nil slices over zero-length slices (#19081)

This commit is contained in:
Matthew Halpern 2019-06-27 02:03:57 -07:00 committed by Péter Szilágyi
parent 6069b1a5f5
commit 702f52fb99
1 changed files with 6 additions and 4 deletions

View File

@ -159,7 +159,7 @@ func testGetBlockHeaders(t *testing.T, protocol int) {
var reqID uint64 var reqID uint64
for i, tt := range tests { for i, tt := range tests {
// Collect the headers to expect in the response // Collect the headers to expect in the response
headers := []*types.Header{} var headers []*types.Header
for _, hash := range tt.expect { for _, hash := range tt.expect {
headers = append(headers, bc.GetHeaderByHash(hash)) headers = append(headers, bc.GetHeaderByHash(hash))
} }
@ -212,8 +212,9 @@ func testGetBlockBodies(t *testing.T, protocol int) {
var reqID uint64 var reqID uint64
for i, tt := range tests { for i, tt := range tests {
// Collect the hashes to request, and the response to expect // Collect the hashes to request, and the response to expect
hashes, seen := []common.Hash{}, make(map[int64]bool) var hashes []common.Hash
bodies := []*types.Body{} seen := make(map[int64]bool)
var bodies []*types.Body
for j := 0; j < tt.random; j++ { for j := 0; j < tt.random; j++ {
for { for {
@ -313,7 +314,8 @@ func testGetReceipt(t *testing.T, protocol int) {
bc := server.pm.blockchain.(*core.BlockChain) bc := server.pm.blockchain.(*core.BlockChain)
// Collect the hashes to request, and the response to expect // Collect the hashes to request, and the response to expect
hashes, receipts := []common.Hash{}, []types.Receipts{} var receipts []types.Receipts
var hashes []common.Hash
for i := uint64(0); i <= bc.CurrentBlock().NumberU64(); i++ { for i := uint64(0); i <= bc.CurrentBlock().NumberU64(); i++ {
block := bc.GetBlockByNumber(i) block := bc.GetBlockByNumber(i)