Skip to content

Commit

Permalink
change all label to v2.5.9;modify postman test.json;print command in …
Browse files Browse the repository at this point in the history
…cryptogen

Signed-off-by: YoungHypo <[email protected]>
  • Loading branch information
YoungHypo committed Sep 19, 2024
1 parent d68c9f6 commit 43178c9
Show file tree
Hide file tree
Showing 11 changed files with 175 additions and 518 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -252,3 +252,7 @@ src/dashboard/lambda/mock/index.js
# Local Netlify folder
.netlify
deno.lock

# test postman
tests/postman/env.json
tests/postman/junitResult.xml
2 changes: 1 addition & 1 deletion src/api-engine/api/lib/configtxgen/configtxgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class ConfigTxGen:
"""Class represents cryptotxgen."""

def __init__(self, network, filepath=CELLO_HOME, configtxgen=FABRIC_TOOL, version="2.2.0"):
def __init__(self, network, filepath=CELLO_HOME, configtxgen=FABRIC_TOOL, version="2.5.9"):
"""init CryptoGen
param:
network: network's name
Expand Down
2 changes: 1 addition & 1 deletion src/api-engine/api/lib/configtxlator/configtxlator.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ConfigTxLator:
Class represents configtxlator CLI.
"""

def __init__(self, configtxlator=FABRIC_TOOL, version="2.2.0"):
def __init__(self, configtxlator=FABRIC_TOOL, version="2.5.9"):
self.configtxlator = configtxlator + "/configtxlator"
self.version = version

Expand Down
2 changes: 1 addition & 1 deletion src/api-engine/api/lib/peer/chaincode.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


class ChainCode(Command):
def __init__(self, version="2.2.0", peer=FABRIC_TOOL, **kwargs):
def __init__(self, version="2.5.9", peer=FABRIC_TOOL, **kwargs):
self.peer = peer + "/peer"
super(ChainCode, self).__init__(version, **kwargs)

Expand Down
2 changes: 1 addition & 1 deletion src/api-engine/api/lib/peer/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class Channel(Command):
"""Call CMD to perform channel create, join and other related operations"""

def __init__(self, version="2.2.0", peer=FABRIC_TOOL, **kwargs):
def __init__(self, version="2.5.9", peer=FABRIC_TOOL, **kwargs):
self.peer = peer + "/peer"
super(Channel, self).__init__(version, **kwargs)

Expand Down
31 changes: 26 additions & 5 deletions src/api-engine/api/lib/pki/cryptogen/cryptogen.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
from subprocess import call
from api.config import CELLO_HOME, FABRIC_TOOL

import logging
LOG = logging.getLogger(__name__)


class CryptoGen:
"""Class represents crypto-config tool."""

def __init__(self, name, filepath=CELLO_HOME, cryptogen=FABRIC_TOOL, version="2.2.0"):
def __init__(self, name, filepath=CELLO_HOME, cryptogen=FABRIC_TOOL, version="2.5.9"):
"""init CryptoGen
param:
name: organization's name
Expand All @@ -30,8 +33,17 @@ def generate(self, output="crypto-config", config="crypto-config.yaml"):
return:
"""
try:
call([self.cryptogen, "generate", "--output={}/{}/{}".format(self.filepath, self.name, output),
"--config={}/{}/{}".format(self.filepath, self.name, config)])
command = [
self.cryptogen,
"generate",
"--output={}/{}/{}".format(self.filepath, self.name, output),
"--config={}/{}/{}".format(self.filepath, self.name, config)
]

LOG.info("Running command: " + " ".join(command))

call(command)

except Exception as e:
err_msg = "cryptogen generate fail for {}!".format(e)
raise Exception(err_msg)
Expand All @@ -44,8 +56,17 @@ def extend(self, input="crypto-config", config="crypto-config.yaml"):
return:
"""
try:
call([self.cryptogen, "extend", "--input={}/{}/{}".format(self.filepath, self.name, input),
"--config={}/{}/{}".format(self.filepath, self.name, config)])
command = [
self.cryptogen,
"extend",
"--input={}/{}/{}".format(self.filepath, self.name, input),
"--config={}/{}/{}".format(self.filepath, self.name, config)
]

LOG.info("Running command: " + " ".join(command))

call(command)

except Exception as e:
err_msg = "cryptogen extend fail for {}!".format(e)
raise Exception(err_msg)
18 changes: 9 additions & 9 deletions src/api-engine/api/routes/chaincode/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def package(self, request):
# )
# peer_node = qs.first()
# envs = init_env_vars(peer_node, org)
# peer_channel_cli = PeerChainCode("v2.2.0", **envs)
# peer_channel_cli = PeerChainCode("v2.5.9", **envs)
# return_code, content = peer_channel_cli.lifecycle_calculatepackageid(temp_cc_path)
# if (return_code != 0):
# return Response(
Expand Down Expand Up @@ -241,7 +241,7 @@ def install(self, request):
peer_node = qs.first()
envs = init_env_vars(peer_node, org)

peer_channel_cli = PeerChainCode("v2.2.0", **envs)
peer_channel_cli = PeerChainCode("v2.5.9", **envs)
res = peer_channel_cli.lifecycle_install(cc_targz)
if res != 0:
return Response(err("install chaincode failed."), status=status.HTTP_400_BAD_REQUEST)
Expand Down Expand Up @@ -270,7 +270,7 @@ def query_installed(self, request):
envs = init_env_vars(peer_node, org)

timeout = "5s"
peer_channel_cli = PeerChainCode("v2.2.0", **envs)
peer_channel_cli = PeerChainCode("v2.5.9", **envs)
res, installed_chaincodes = peer_channel_cli.lifecycle_query_installed(
timeout)
if res != 0:
Expand Down Expand Up @@ -300,7 +300,7 @@ def get_installed_package(self, request):
envs = init_env_vars(peer_node, org)

timeout = "5s"
peer_channel_cli = PeerChainCode("v2.2.0", **envs)
peer_channel_cli = PeerChainCode("v2.5.9", **envs)
res = peer_channel_cli.lifecycle_get_installed_package(timeout)
if res != 0:
return Response(err("get installed package failed."), status=status.HTTP_400_BAD_REQUEST)
Expand Down Expand Up @@ -352,7 +352,7 @@ def approve_for_my_org(self, request):
peer_node = qs.first()
envs = init_env_vars(peer_node, org)

peer_channel_cli = PeerChainCode("v2.2.0", **envs)
peer_channel_cli = PeerChainCode("v2.5.9", **envs)
code, content = peer_channel_cli.lifecycle_approve_for_my_org(orderer_url, orderer_tls_root_cert, channel_name,
chaincode_name, chaincode_version, policy, sequence)
if code != 0:
Expand Down Expand Up @@ -384,7 +384,7 @@ def query_approved(self, request):
channel_name = request.data.get("channel_name")
cc_name = request.data.get("chaincode_name")

peer_channel_cli = PeerChainCode("v2.2.0", **envs)
peer_channel_cli = PeerChainCode("v2.5.9", **envs)
code, content = peer_channel_cli.lifecycle_query_approved(
channel_name, cc_name)
if code != 0:
Expand Down Expand Up @@ -438,7 +438,7 @@ def check_commit_readiness(self, request):
peer_node = qs.first()
envs = init_env_vars(peer_node, org)

peer_channel_cli = PeerChainCode("v2.2.0", **envs)
peer_channel_cli = PeerChainCode("v2.5.9", **envs)
code, content = peer_channel_cli.lifecycle_check_commit_readiness(orderer_url, orderer_tls_root_cert,
channel_name, chaincode_name,
chaincode_version, policy, sequence)
Expand Down Expand Up @@ -507,7 +507,7 @@ def commit(self, request):
peer_address_list.append(peer_address)
peer_root_certs.append(peer_tls_cert)

peer_channel_cli = PeerChainCode("v2.2.0", **envs)
peer_channel_cli = PeerChainCode("v2.5.9", **envs)
code = peer_channel_cli.lifecycle_commit(orderer_url, orderer_tls_root_cert, channel_name,
chaincode_name, chaincode_version, policy,
peer_address_list, peer_root_certs, sequence)
Expand Down Expand Up @@ -539,7 +539,7 @@ def query_committed(self, request):
raise ResourceNotFound
peer_node = qs.first()
envs = init_env_vars(peer_node, org)
peer_channel_cli = PeerChainCode("v2.2.0", **envs)
peer_channel_cli = PeerChainCode("v2.5.9", **envs)
code, chaincodes_commited = peer_channel_cli.lifecycle_query_committed(
channel_name, chaincode_name)
if code != 0:
Expand Down
8 changes: 4 additions & 4 deletions src/api-engine/api/routes/channel/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def create(self, request):
ordering_node = Node.objects.get(id=orderers[0])
peer_node = Node.objects.get(id=peers[0])
envs = init_env_vars(peer_node, org)
peer_channel_cli = PeerChannel("v2.2.0", **envs)
peer_channel_cli = PeerChannel("v2.5.9", **envs)
peer_channel_cli.create(
channel=name,
orderer_url="{}.{}:{}".format(
Expand Down Expand Up @@ -312,7 +312,7 @@ def update(self, request, pk=None):
env = {
"FABRIC_CFG_PATH": "{}/{}/peers/{}/".format(dir_node, org.name, node.name + "." + org.name),
}
cli = PeerChannel("v2.2.0", **env)
cli = PeerChannel("v2.5.9", **env)
cli.signconfigtx(
channel.get_channel_artifacts_path(CFG_DELTA_ENV_PB))
LOG.info("Peers to send the update transaction success")
Expand Down Expand Up @@ -343,7 +343,7 @@ def get_channel_org_config(self, request, pk=None):
env = {
"FABRIC_CFG_PATH": "{}/{}/peers/{}/".format(dir_node, org.name, node.name + "." + org.name),
}
peer_channel_cli = PeerChannel("v2.2.0", **env)
peer_channel_cli = PeerChannel("v2.5.9", **env)
peer_channel_cli.fetch(option="config", channel=channel.name)

# Decode latest config block into json
Expand Down Expand Up @@ -407,7 +407,7 @@ def join_peers(envs, block_path):
:param block_path: Path to file containing genesis block
"""
# Join the peers to the channel.
peer_channel_cli = PeerChannel("v2.2.0", **envs)
peer_channel_cli = PeerChannel("v2.5.9", **envs)
peer_channel_cli.join(
block_file=block_path
)
2 changes: 1 addition & 1 deletion tests/postman/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ initial-json:

test-api:
@$(MAKE) initial-json
bash ${ROOT_PATH}/tests/postman/test.sh || (echo "test api failed $$?"; exit 1)
bash test.sh || (echo "test api failed $$?"; exit 1)
16 changes: 14 additions & 2 deletions tests/postman/env.json.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"values": [
{
"key": "apiServer",
"value": "http://127.0.0.1:$API_ENGINE_SERVICE_PORT",
"value": "http://localhost",
"description": "",
"enabled": true
},
{
"key": "webRoot",
"value": "$API_ENGINE_WEBROOT",
"value": "8080",
"description": "",
"enabled": true
},
Expand Down Expand Up @@ -86,6 +86,18 @@
"description": "",
"enabled": true
},
{
"key": "ordererID",
"value": "",
"description": "",
"enabled": true
},
{
"key": "peerID",
"value": "",
"description": "",
"enabled": true
},
{
"key": "nodeCapacity",
"value": "40",
Expand Down
Loading

0 comments on commit 43178c9

Please sign in to comment.