From 6509afdcf8e90f5763ab9d4b2918b7c11a94f50e Mon Sep 17 00:00:00 2001 From: Kostas Christidis Date: Wed, 1 Mar 2017 19:19:39 -0500 Subject: [PATCH] [FAB-2581] Fix if-else statements in deliver tests https://jira.hyperledger.org/browse/FAB-2581 A set of if blocks end with return statements, meaning there's no reason for a corresponding else block. This changeset addresses that. Change-Id: I8a97bb3c232f6c174241bcc206e070fd5a9c2697 Signed-off-by: Kostas Christidis --- orderer/common/deliver/deliver.go | 2 +- orderer/common/deliver/deliver_test.go | 21 +++++++++------------ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/orderer/common/deliver/deliver.go b/orderer/common/deliver/deliver.go index 631be82530c..d2af6a135f9 100644 --- a/orderer/common/deliver/deliver.go +++ b/orderer/common/deliver/deliver.go @@ -83,7 +83,7 @@ func (ds *deliverServer) Handle(srv ab.AtomicBroadcast_DeliverServer) error { } if payload.Header == nil /* || payload.Header.ChannelHeader == nil */ { - err := fmt.Errorf("Malformed envelope recieved with bad header") + err = fmt.Errorf("Malformed envelope received with bad header") logger.Error(err) return err } diff --git a/orderer/common/deliver/deliver_test.go b/orderer/common/deliver/deliver_test.go index 5301dccef78..0dc19f02373 100644 --- a/orderer/common/deliver/deliver_test.go +++ b/orderer/common/deliver/deliver_test.go @@ -166,10 +166,9 @@ func TestOldestSeek(t *testing.T) { t.Fatalf("Expected %d blocks but got %d", ledgerSize, count) } return - } else { - if deliverReply.GetBlock().Header.Number != count { - t.Fatalf("Expected block %d but got block %d", count, deliverReply.GetBlock().Header.Number) - } + } + if deliverReply.GetBlock().Header.Number != count { + t.Fatalf("Expected block %d but got block %d", count, deliverReply.GetBlock().Header.Number) } case <-time.After(time.Second): t.Fatalf("Timed out waiting to get all blocks") @@ -200,10 +199,9 @@ func TestNewestSeek(t *testing.T) { t.Fatalf("Received an error on the reply channel") } return - } else { - if deliverReply.GetBlock().Header.Number != uint64(ledgerSize-1) { - t.Fatalf("Expected only the most recent block") - } + } + if deliverReply.GetBlock().Header.Number != uint64(ledgerSize-1) { + t.Fatalf("Expected only the most recent block") } case <-time.After(time.Second): t.Fatalf("Timed out waiting to get all blocks") @@ -236,10 +234,9 @@ func TestSpecificSeek(t *testing.T) { t.Fatalf("Received an error on the reply channel") } return - } else { - if expected := specifiedStart + count; deliverReply.GetBlock().Header.Number != expected { - t.Fatalf("Expected block %d but got block %d", expected, deliverReply.GetBlock().Header.Number) - } + } + if expected := specifiedStart + count; deliverReply.GetBlock().Header.Number != expected { + t.Fatalf("Expected block %d but got block %d", expected, deliverReply.GetBlock().Header.Number) } case <-time.After(time.Second): t.Fatalf("Timed out waiting to get all blocks")