diff --git a/common/configtx/test/helper.go b/common/configtx/test/helper.go index 598487f8f3c..36e2b4af4c8 100644 --- a/common/configtx/test/helper.go +++ b/common/configtx/test/helper.go @@ -22,12 +22,10 @@ import ( "github.com/hyperledger/fabric/common/configtx" "github.com/hyperledger/fabric/common/genesis" - peersharedconfig "github.com/hyperledger/fabric/peer/sharedconfig" cb "github.com/hyperledger/fabric/protos/common" "github.com/hyperledger/fabric/protos/utils" "github.com/golang/protobuf/proto" - "github.com/hyperledger/fabric/protos/peer" logging "github.com/op/go-logging" ) @@ -41,10 +39,12 @@ const ( const ( OrdererTemplateName = "orderer.template" MSPTemplateName = "msp.template" + PeerTemplateName = "peer.template" ) var ordererTemplate configtx.Template var mspTemplate configtx.Template +var peerTemplate configtx.Template var genesisFactory genesis.Factory @@ -71,9 +71,8 @@ func readTemplate(name string) configtx.Template { func init() { ordererTemplate = readTemplate(OrdererTemplateName) mspTemplate = readTemplate(MSPTemplateName) - anchorPeers := []*peer.AnchorPeer{{Host: "fakehost", Port: 2000, Cert: []byte{}}} - gossTemplate := configtx.NewSimpleTemplate(peersharedconfig.TemplateAnchorPeers(anchorPeers)) - genesisFactory = genesis.NewFactoryImpl(configtx.NewCompositeTemplate(mspTemplate, ordererTemplate, gossTemplate)) + peerTemplate = readTemplate(PeerTemplateName) + genesisFactory = genesis.NewFactoryImpl(configtx.NewCompositeTemplate(mspTemplate, ordererTemplate, peerTemplate)) } // WriteTemplate takes an output file and set of config items and writes them to that file as a marshaled ConfigurationTemplate @@ -100,3 +99,8 @@ func GetOrdererTemplate() configtx.Template { func GetMSPTemplate() configtx.Template { return mspTemplate } + +// GetMSPerTemplate returns the test peer template +func GetPeerTemplate() configtx.Template { + return peerTemplate +} diff --git a/common/configtx/test/peer.template b/common/configtx/test/peer.template new file mode 100644 index 00000000000..e4ec4eafd9c --- /dev/null +++ b/common/configtx/test/peer.template @@ -0,0 +1,2 @@ + +" AnchorPeers \ No newline at end of file diff --git a/peer/sharedconfig/template_test.go b/peer/sharedconfig/template_test.go new file mode 100644 index 00000000000..92c15cf3a81 --- /dev/null +++ b/peer/sharedconfig/template_test.go @@ -0,0 +1,30 @@ +/* +Copyright IBM Corp. 2017 All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package sharedconfig + +import ( + "testing" + + configtxtest "github.com/hyperledger/fabric/common/configtx/test" +) + +func TestTemplate(t *testing.T) { + configtxtest.WriteTemplate( + "../../common/configtx/test/"+configtxtest.PeerTemplateName, + DefaultAnchorPeers(), + ) +}