Skip to content

Commit

Permalink
[FAB-2581] Fix if-else statements in deliver tests
Browse files Browse the repository at this point in the history
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 <kostas@christidis.io>
  • Loading branch information
kchristidis committed Mar 2, 2017
1 parent 4d5b760 commit 6509afd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
2 changes: 1 addition & 1 deletion orderer/common/deliver/deliver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
21 changes: 9 additions & 12 deletions orderer/common/deliver/deliver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 6509afd

Please sign in to comment.