Skip to content

Commit

Permalink
[FAB-6214] Make target to generate channel artifacts
Browse files Browse the repository at this point in the history
Change-Id: I9da52a99b2e4a124dde7335f13df663caafda297
Signed-off-by: Divyank Katira <[email protected]>
  • Loading branch information
d1vyank committed Sep 19, 2017
1 parent 4bfb47e commit ff494fa
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 8 deletions.
21 changes: 13 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,12 @@
# checks: runs all check conditions (license, spelling, linting)
# clean: stops docker conatainers used for integration testing
# mock-gen: generate mocks needed for testing (using mockgen)
# channel-artifacts: generates the channel configuration transactions and blocks used by tests
# populate: populates generated files (not included in git) - currently only vendor
# populate-vendor: populate the vendor directory based on the lock
# populate-clean: cleans up populated files (might become part of clean eventually)
# populate-clean: cleans up populated files (might become part of clean eventually)
# thirdparty-pin: pulls (and patches) pinned dependencies into the project under internal
#
#
# Instructions to generate .tx files used for creating channels:
# Download the configtxgen binary for your OS from (it is located in the .tar.gz file):
# https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric/hyperledger-fabric
# Sample command: $ path/to/configtxgen -profile TwoOrgsChannel -outputCreateChannelTx testchannel.tx -channelID testchannel
# More Docs: http://hyperledger-fabric.readthedocs.io/en/latest/configtxgen.html
#


export ARCH=$(shell uname -m)
Expand All @@ -39,6 +33,10 @@ THIRDPARTY_FABRIC_CA_COMMIT=v1.0.1
THIRDPARTY_FABRIC_BRANCH=master
THIRDPARTY_FABRIC_COMMIT=a657db28a0ff53ed512bd6f4ac4786a0f4ca709c

# Local variables used by makefile
PACKAGE_NAME=github.com/hyperledger/fabric-sdk-go
FABRIC_TOOLS_RELEASE=1.0.1

# Detect CI
ifdef JENKINS_URL
export FABRIC_SDKGO_DEPEND_INSTALL=true
Expand Down Expand Up @@ -97,6 +95,13 @@ mock-gen:
mockgen -build_flags '$(LDFLAGS)' github.com/hyperledger/fabric-sdk-go/api/apiconfig Config | sed "s/github.com\/hyperledger\/fabric-sdk-go\/vendor\///g" > api/apiconfig/mocks/mockconfig.gen.go
mockgen -build_flags '$(LDFLAGS)' github.com/hyperledger/fabric-sdk-go/api/apifabca FabricCAClient | sed "s/github.com\/hyperledger\/fabric-sdk-go\/vendor\///g" > api/apifabca/mocks/mockfabriccaclient.gen.go

channel-artifacts:
@echo "Generating test channel configuration transactions and blocks"
@docker run -i \
-v $(abspath .):/opt/gopath/src/$(PACKAGE_NAME) \
hyperledger/fabric-tools:$(ARCH)-$(FABRIC_TOOLS_RELEASE) \
/bin/bash -c "/opt/gopath/src/${PACKAGE_NAME}/test/scripts/generate_channeltx.sh"

thirdparty-pin:
UPSTREAM_COMMIT=$(THIRDPARTY_FABRIC_COMMIT) UPSTREAM_BRANCH=$(THIRDPARTY_FABRIC_BRANCH) scripts/third_party_pins/fabric/apply_upstream.sh
UPSTREAM_COMMIT=$(THIRDPARTY_FABRIC_CA_COMMIT) UPSTREAM_BRANCH=$(THIRDPARTY_FABRIC_CA_BRANCH) scripts/third_party_pins/fabric-ca/apply_upstream.sh
Expand Down
Binary file modified test/fixtures/channel/mychannel.tx
Binary file not shown.
Binary file added test/fixtures/channel/mychannelOrg1MSPanchors.tx
Binary file not shown.
Binary file added test/fixtures/channel/mychannelOrg2MSPanchors.tx
Binary file not shown.
Binary file modified test/fixtures/channel/orgchannel.tx
Binary file not shown.
Binary file added test/fixtures/channel/orgchannelOrg1MSPanchors.tx
Binary file not shown.
Binary file added test/fixtures/channel/orgchannelOrg2MSPanchors.tx
Binary file not shown.
Binary file modified test/fixtures/channel/testchannel.tx
Binary file not shown.
Binary file added test/fixtures/channel/testchannelOrg1MSPanchors.tx
Binary file not shown.
Binary file added test/fixtures/channel/testchannelOrg2MSPanchors.tx
Binary file not shown.
Binary file modified test/fixtures/channel/twoorgs.genesis.block
Binary file not shown.
29 changes: 29 additions & 0 deletions test/scripts/generate_channeltx.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash
#
# Copyright SecureKey Technologies Inc. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#

declare -a channels=("mychannel" "orgchannel" "testchannel")
declare -a orgs=("Org1MSP" "Org2MSP")

export CHANNEL_DIR="/opt/gopath/src/github.com/hyperledger/fabric-sdk-go/test/fixtures/channel"
export FABRIC_CFG_PATH=${CHANNEL_DIR}

echo "Generating Orderer Genesis block"
configtxgen -profile TwoOrgsOrdererGenesis -outputBlock ${CHANNEL_DIR}/twoorgs.genesis.block

for i in "${channels[@]}"
do
echo "Generating artifacts for channel: $i"

echo "Generating channel configuration transaction"
configtxgen -profile TwoOrgsChannel -outputCreateChannelTx .${CHANNEL_DIR}/${i}.tx -channelID $i

for j in "${orgs[@]}"
do
echo "Generating anchor peer update for org $j"
configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ${CHANNEL_DIR}/${i}${j}anchors.tx -channelID $i -asOrg $j
done
done

0 comments on commit ff494fa

Please sign in to comment.