Skip to content

Commit 28d6bd0

Browse files
committed
[FAB-1661] Remove shadow variable declarations
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]>
1 parent 2c6dbcc commit 28d6bd0

File tree

3 files changed

+5
-10
lines changed

3 files changed

+5
-10
lines changed

orderer/kafka/producer_mock_test.go

+5-6
Original file line numberDiff line numberDiff line change
@@ -62,19 +62,18 @@ func mockNewProducer(t *testing.T, cp ChainPartition, offset int64, disk chan *a
6262
func (mp *mockProducerImpl) Send(cp ChainPartition, payload []byte) error {
6363
mp.producer.ExpectSendMessageWithCheckerFunctionAndSucceed(mp.checker)
6464
mp.producedOffset++ // This is the offset that will be assigned to the sent message
65-
_, ofs, err := mp.producer.SendMessage(newProducerMessage(cp, payload))
66-
// We do NOT check the assigned partition because the mock
67-
// producer always posts to partition 0 no matter what.
68-
// This is a deficiency of the Kafka library that we use.
69-
if err != nil || ofs != mp.producedOffset {
65+
if _, ofs, err := mp.producer.SendMessage(newProducerMessage(cp, payload)); err != nil || ofs != mp.producedOffset {
66+
// We do NOT check the assigned partition because the mock
67+
// producer always posts to partition 0 no matter what.
68+
// This is a deficiency of the Kafka library that we use.
7069
mp.t.Fatal("Mock producer not functioning as expected")
7170
}
7271
msg := new(ab.KafkaMessage)
7372
if err := proto.Unmarshal(payload, msg); err != nil {
7473
mp.t.Fatalf("Failed to unmarshal message that reached producer's disk: %s", err)
7574
}
7675
mp.disk <- msg // Reaches the cluster's disk for that chain partition
77-
return err
76+
return nil
7877
}
7978

8079
func (mp *mockProducerImpl) Close() error {

orderer/kafka/producer_test.go

-2
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,11 @@ package kafka
1919
import (
2020
"testing"
2121

22-
"github.com/hyperledger/fabric/orderer/common/bootstrap/provisional"
2322
ab "github.com/hyperledger/fabric/protos/orderer"
2423
"github.com/hyperledger/fabric/protos/utils"
2524
)
2625

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

orderer/kafka/util_test.go

-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ import (
2424
)
2525

2626
func TestProducerConfigMessageMaxBytes(t *testing.T) {
27-
cp := newChainPartition(provisional.TestChainID, rawPartition)
28-
2927
broker := sarama.NewMockBroker(t, 1)
3028
defer func() {
3129
broker.Close()

0 commit comments

Comments
 (0)