Skip to content

Commit

Permalink
[FAB-1661] Remove shadow variable declarations
Browse files Browse the repository at this point in the history
https://jira.hyperledger.org/browse/FAB-1661

This changeset removes a few shadow variable declarations that have crept
in the `kafka` package.

Change-Id: Ie3a763917b4d6e33320dd2ba037f92fbae8ae078
Signed-off-by: Kostas Christidis <[email protected]>
  • Loading branch information
kchristidis committed Jan 15, 2017
1 parent 2c6dbcc commit 28d6bd0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
11 changes: 5 additions & 6 deletions orderer/kafka/producer_mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,18 @@ func mockNewProducer(t *testing.T, cp ChainPartition, offset int64, disk chan *a
func (mp *mockProducerImpl) Send(cp ChainPartition, payload []byte) error {
mp.producer.ExpectSendMessageWithCheckerFunctionAndSucceed(mp.checker)
mp.producedOffset++ // This is the offset that will be assigned to the sent message
_, ofs, err := mp.producer.SendMessage(newProducerMessage(cp, payload))
// We do NOT check the assigned partition because the mock
// producer always posts to partition 0 no matter what.
// This is a deficiency of the Kafka library that we use.
if err != nil || ofs != mp.producedOffset {
if _, ofs, err := mp.producer.SendMessage(newProducerMessage(cp, payload)); err != nil || ofs != mp.producedOffset {
// We do NOT check the assigned partition because the mock
// producer always posts to partition 0 no matter what.
// This is a deficiency of the Kafka library that we use.
mp.t.Fatal("Mock producer not functioning as expected")
}
msg := new(ab.KafkaMessage)
if err := proto.Unmarshal(payload, msg); err != nil {
mp.t.Fatalf("Failed to unmarshal message that reached producer's disk: %s", err)
}
mp.disk <- msg // Reaches the cluster's disk for that chain partition
return err
return nil
}

func (mp *mockProducerImpl) Close() error {
Expand Down
2 changes: 0 additions & 2 deletions orderer/kafka/producer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ package kafka
import (
"testing"

"github.com/hyperledger/fabric/orderer/common/bootstrap/provisional"
ab "github.com/hyperledger/fabric/protos/orderer"
"github.com/hyperledger/fabric/protos/utils"
)

func TestProducerSend(t *testing.T) {
cp := newChainPartition(provisional.TestChainID, rawPartition)
mp := mockNewProducer(t, cp, testMiddleOffset, make(chan *ab.KafkaMessage))
defer testClose(t, mp)

Expand Down
2 changes: 0 additions & 2 deletions orderer/kafka/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ import (
)

func TestProducerConfigMessageMaxBytes(t *testing.T) {
cp := newChainPartition(provisional.TestChainID, rawPartition)

broker := sarama.NewMockBroker(t, 1)
defer func() {
broker.Close()
Expand Down

0 comments on commit 28d6bd0

Please sign in to comment.