Commit 1cecb57a authored by Matthew Sykes's avatar Matthew Sykes
Browse files

[FAB-9299] Use base image with go 1.10



Linting after the update resulted in a number of vet issues that needed
to be addressed as well.

Change-Id: I229ed24d6670bbc8fdb24f559903f839b37d2cf3
Signed-off-by: default avatarMatthew Sykes <sykesmat@us.ibm.com>
parent 0466a5ea
......@@ -44,7 +44,7 @@
BASE_VERSION = 1.2.0
PREV_VERSION = 1.1.0
CHAINTOOL_RELEASE=1.1.0
BASEIMAGE_RELEASE=0.4.6
BASEIMAGE_RELEASE=0.4.7
# Allow to build as a submodule setting the main project to
# the PROJECT_NAME env variable, for example,
......
......@@ -165,12 +165,11 @@ func TestRaceCondition(t *testing.T) {
it, _ := fl.Iterator(&ab.SeekPosition{Type: &ab.SeekPosition_Specified{Specified: &ab.SeekSpecified{Number: 1}}})
defer it.Close()
var block *cb.Block
var status cb.Status
complete := make(chan struct{})
go func() {
block, status = it.Next()
_, status = it.Next()
close(complete)
}()
......
......@@ -8,7 +8,7 @@ package metadata
// Variables defined by the Makefile and passed in with ldflags
var Version string = "latest"
var BaseVersion string = "0.4.6"
var BaseVersion string = "0.4.7"
var BaseDockerLabel string = "org.hyperledger.fabric"
var DockerNamespace string = "hyperledger"
var BaseDockerNamespace string = "hyperledger"
......
......@@ -555,14 +555,11 @@ func TestInvoke(t *testing.T) {
streamGetter = mockChaincodeStreamGetter
cc := &shimTestCC{}
//viper.Set("chaincode.logging.shim", "debug")
var err error
ccname := "shimTestCC"
peerSide := setupcc(ccname, cc)
defer mockPeerCCSupport.RemoveCC(ccname)
//start the shim+chaincode
go func() {
err = Start(cc)
}()
go Start(cc)
done := setuperror()
......@@ -576,7 +573,8 @@ func TestInvoke(t *testing.T) {
{&pb.ChaincodeMessage{Type: pb.ChaincodeMessage_REGISTER}, &pb.ChaincodeMessage{Type: pb.ChaincodeMessage_REGISTERED}}}}
peerSide.SetResponses(respSet)
peerSide.SetKeepAlive(&pb.ChaincodeMessage{Type: pb.ChaincodeMessage_KEEPALIVE})
err = peerSide.Run()
err := peerSide.Run()
assert.NoError(t, err, "peer side run failed")
}()
//wait for init
......@@ -841,7 +839,6 @@ func TestInvoke(t *testing.T) {
func TestStartInProc(t *testing.T) {
streamGetter = mockChaincodeStreamGetter
cc := &shimTestCC{}
var err error
ccname := "shimTestCC"
peerSide := setupcc(ccname, cc)
defer mockPeerCCSupport.RemoveCC(ccname)
......@@ -858,13 +855,12 @@ func TestStartInProc(t *testing.T) {
{&pb.ChaincodeMessage{Type: pb.ChaincodeMessage_REGISTER}, &pb.ChaincodeMessage{Type: pb.ChaincodeMessage_REGISTERED}}}}
peerSide.SetResponses(respSet)
peerSide.SetKeepAlive(&pb.ChaincodeMessage{Type: pb.ChaincodeMessage_KEEPALIVE})
err = peerSide.Run()
err := peerSide.Run()
assert.NoError(t, err, "peer side run failed")
}()
//start the shim+chaincode
go func() {
err = StartInProc([]string{"CORE_CHAINCODE_ID_NAME=shimTestCC", "CORE_CHAINCODE_LOGGING_SHIM=debug"}, nil, cc, peerSide.GetSendStream(), peerSide.GetRecvStream())
}()
go StartInProc([]string{"CORE_CHAINCODE_ID_NAME=shimTestCC", "CORE_CHAINCODE_LOGGING_SHIM=debug"}, nil, cc, peerSide.GetSendStream(), peerSide.GetRecvStream())
//wait for init
processDone(t, done, false)
......@@ -880,14 +876,11 @@ func TestCC2CC(t *testing.T) {
streamGetter = mockChaincodeStreamGetter
cc := &shimTestCC{}
//viper.Set("chaincode.logging.shim", "debug")
var err error
ccname := "shimTestCC"
peerSide := setupcc(ccname, cc)
defer mockPeerCCSupport.RemoveCC(ccname)
//start the shim+chaincode
go func() {
err = Start(cc)
}()
go Start(cc)
done := setuperror()
......@@ -901,7 +894,8 @@ func TestCC2CC(t *testing.T) {
{&pb.ChaincodeMessage{Type: pb.ChaincodeMessage_REGISTER}, &pb.ChaincodeMessage{Type: pb.ChaincodeMessage_REGISTERED}}}}
peerSide.SetResponses(respSet)
peerSide.SetKeepAlive(&pb.ChaincodeMessage{Type: pb.ChaincodeMessage_KEEPALIVE})
err = peerSide.Run()
err := peerSide.Run()
assert.NoError(t, err, "peer side run failed")
}()
//wait for init
......
......@@ -517,7 +517,7 @@ type ccMetadataFetcher struct {
mock.Mock
}
func (mdf ccMetadataFetcher) ChaincodeMetadata(channel string, cc string) *chaincode.InstantiatedChaincode {
func (mdf *ccMetadataFetcher) ChaincodeMetadata(channel string, cc string) *chaincode.InstantiatedChaincode {
return mdf.Called().Get(0).(*chaincode.InstantiatedChaincode)
}
......
......@@ -6,7 +6,6 @@ SPDX-License-Identifier: Apache-2.0
package main
import (
"C"
"hash"
"github.com/hyperledger/fabric/bccsp"
......
......@@ -108,7 +108,7 @@ func (*gossipMock) Stop() {
panic("implement me")
}
func (gossipMock) SendByCriteria(*proto.SignedGossipMessage, gossip.SendCriteria) error {
func (*gossipMock) SendByCriteria(*proto.SignedGossipMessage, gossip.SendCriteria) error {
panic("implement me")
}
......
......@@ -188,7 +188,7 @@ func (*mockTransientStore) PurgeByTxids(txids []string) error {
}
type mockCommitter struct {
mock.Mock
*mock.Mock
sync.Mutex
}
......@@ -374,7 +374,7 @@ func newPeerNode(config *gossip.Config, committer committer.Committer, acceptor
func TestNilDirectMsg(t *testing.T) {
t.Parallel()
mc := &mockCommitter{}
mc := &mockCommitter{Mock: &mock.Mock{}}
mc.On("LedgerHeight", mock.Anything).Return(uint64(1), nil)
g := &mocks.GossipMock{}
g.On("Accept", mock.Anything, false).Return(make(<-chan *proto.GossipMessage), nil)
......@@ -393,7 +393,7 @@ func TestNilDirectMsg(t *testing.T) {
func TestNilAddPayload(t *testing.T) {
t.Parallel()
mc := &mockCommitter{}
mc := &mockCommitter{Mock: &mock.Mock{}}
mc.On("LedgerHeight", mock.Anything).Return(uint64(1), nil)
g := &mocks.GossipMock{}
g.On("Accept", mock.Anything, false).Return(make(<-chan *proto.GossipMessage), nil)
......@@ -408,7 +408,7 @@ func TestNilAddPayload(t *testing.T) {
func TestAddPayloadLedgerUnavailable(t *testing.T) {
t.Parallel()
mc := &mockCommitter{}
mc := &mockCommitter{Mock: &mock.Mock{}}
mc.On("LedgerHeight", mock.Anything).Return(uint64(1), nil)
g := &mocks.GossipMock{}
g.On("Accept", mock.Anything, false).Return(make(<-chan *proto.GossipMessage), nil)
......@@ -420,7 +420,7 @@ func TestAddPayloadLedgerUnavailable(t *testing.T) {
failedLedger := mock.Mock{}
failedLedger.On("LedgerHeight", mock.Anything).Return(uint64(0), errors.New("cannot query ledger"))
mc.Lock()
mc.Mock = failedLedger
mc.Mock = &failedLedger
mc.Unlock()
rawblock := pcomm.NewBlock(uint64(1), []byte{})
......@@ -440,7 +440,7 @@ func TestLargeBlockGap(t *testing.T) {
// The peer needs to ask blocks in a way such that the size of the payload buffer
// never rises above a certain threshold.
t.Parallel()
mc := &mockCommitter{}
mc := &mockCommitter{Mock: &mock.Mock{}}
blocksPassedToLedger := make(chan uint64, 200)
mc.On("CommitWithPvtData", mock.Anything).Run(func(arg mock.Arguments) {
blocksPassedToLedger <- arg.Get(0).(*pcomm.Block).Header.Number
......@@ -512,7 +512,7 @@ func TestOverPopulation(t *testing.T) {
// rejects blocks starting if the distance between the ledger height to the latest
// block it contains is bigger than defMaxBlockDistance.
t.Parallel()
mc := &mockCommitter{}
mc := &mockCommitter{Mock: &mock.Mock{}}
blocksPassedToLedger := make(chan uint64, 10)
mc.On("CommitWithPvtData", mock.Anything).Run(func(arg mock.Arguments) {
blocksPassedToLedger <- arg.Get(0).(*pcomm.Block).Header.Number
......@@ -576,7 +576,7 @@ func TestBlockingEnqueue(t *testing.T) {
// The blocks from the orderer we get are X2 times the amount of blocks from gossip.
// The blocks we get from gossip are random indices, to maximize disruption.
t.Parallel()
mc := &mockCommitter{}
mc := &mockCommitter{Mock: &mock.Mock{}}
blocksPassedToLedger := make(chan uint64, 10)
mc.On("CommitWithPvtData", mock.Anything).Run(func(arg mock.Arguments) {
blocksPassedToLedger <- arg.Get(0).(*pcomm.Block).Header.Number
......@@ -624,7 +624,7 @@ func TestBlockingEnqueue(t *testing.T) {
for {
receivedBlock := <-blocksPassedToLedger
receivedBlockCount++
m := mock.Mock{}
m := &mock.Mock{}
m.On("LedgerHeight", mock.Anything).Return(receivedBlock, nil)
m.On("CommitWithPvtData", mock.Anything).Run(func(arg mock.Arguments) {
blocksPassedToLedger <- arg.Get(0).(*pcomm.Block).Header.Number
......@@ -684,7 +684,7 @@ func TestHaltChainProcessing(t *testing.T) {
logger.SetBackend(defaultBackend())
}()
mc := &mockCommitter{}
mc := &mockCommitter{Mock: &mock.Mock{}}
mc.On("CommitWithPvtData", mock.Anything)
mc.On("LedgerHeight", mock.Anything).Return(uint64(1), nil)
g := &mocks.GossipMock{}
......@@ -708,7 +708,7 @@ func TestHaltChainProcessing(t *testing.T) {
func TestFailures(t *testing.T) {
t.Parallel()
portPrefix := portStartRange + 400
mc := &mockCommitter{}
mc := &mockCommitter{Mock: &mock.Mock{}}
mc.On("LedgerHeight", mock.Anything).Return(uint64(0), nil)
g := &mocks.GossipMock{}
g.On("Accept", mock.Anything, false).Return(make(<-chan *proto.GossipMessage), nil)
......@@ -718,7 +718,7 @@ func TestFailures(t *testing.T) {
newPeerNodeWithGossip(newGossipConfig(portPrefix, 0), mc, noopPeerIdentityAcceptor, g)
})
// Reprogram mock
mc.Mock = mock.Mock{}
mc.Mock = &mock.Mock{}
mc.On("LedgerHeight", mock.Anything).Return(uint64(1), errors.New("Failed accessing ledger"))
assert.Nil(t, newPeerNodeWithGossip(newGossipConfig(portPrefix, 0), mc, noopPeerIdentityAcceptor, g))
}
......@@ -773,7 +773,7 @@ func TestGossipReception(t *testing.T) {
})
g.On("Accept", mock.Anything, true).Return(nil, make(chan proto.ReceivedMessage))
g.On("PeersOfChannel", mock.Anything).Return([]discovery.NetworkMember{})
mc := &mockCommitter{}
mc := &mockCommitter{Mock: &mock.Mock{}}
receivedChan := make(chan struct{})
mc.On("CommitWithPvtData", mock.Anything).Run(func(arguments mock.Arguments) {
block := arguments.Get(0).(*pcomm.Block)
......@@ -826,7 +826,7 @@ func TestLedgerHeightFromProperties(t *testing.T) {
defaultPeer,
networkMember,
})
mc := &mockCommitter{}
mc := &mockCommitter{Mock: &mock.Mock{}}
mc.On("LedgerHeight", mock.Anything).Return(uint64(1), nil)
portPrefix := portStartRange + 500
p := newPeerNodeWithGossip(newGossipConfig(portPrefix, 0), mc, noopPeerIdentityAcceptor, g)
......
......@@ -135,7 +135,7 @@ func TestDeserializeIdentity(t *testing.T) {
var wg sync.WaitGroup
wg.Add(10000)
for i := 0; i < 10000; i++ {
go func(m msp.MSP) {
go func(m msp.MSP, i int) {
sIdentity := serializedIdentity
expectedIdentity := mockIdentity
defer wg.Done()
......@@ -146,7 +146,7 @@ func TestDeserializeIdentity(t *testing.T) {
id, err := wrappedMSP.DeserializeIdentity(sIdentity)
assert.NoError(t, err)
assert.Equal(t, expectedIdentity, id)
}(wrappedMSP)
}(wrappedMSP, i)
}
wg.Wait()
......
......@@ -2121,11 +2121,10 @@ func TestProcessMessagesToBlocks(t *testing.T) {
doneProcessingMessagesToBlocks: make(chan struct{}),
}
var counts []uint64
done := make(chan struct{})
go func() {
counts, err = bareMinimumChain.processMessagesToBlocks()
_, err = bareMinimumChain.processMessagesToBlocks()
done <- struct{}{}
}()
......
#!/bin/bash
#
#!/bin/bash -e
# Copyright Greg Haskins All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
set -e
declare -a arr=(
"./bccsp"
"./common"
"./core"
"./discovery"
"./events"
"./examples"
"./gossip"
......@@ -45,7 +42,7 @@ do
fi
echo "Checking with go vet"
OUTPUT="$(go vet $i/...)"
OUTPUT="$(go vet -composites=false $i/...)"
if [[ $OUTPUT ]]; then
echo "The following files contain go vet errors"
echo $OUTPUT
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment