예제 #1
0
def step_impl(context):
    # Temporarily sleep for 2 sec. This delay should be able to be removed once we start using the python sdk
    time.sleep(2)

    # Grab the key/value pair from the deploy
    key = value = None
    print(context.chaincode['args'])
    print(json.loads(context.chaincode['args']))
    args = json.loads(context.chaincode['args'])
    for arg in args:
        if arg == 'init':
            keyIndex = args.index(arg)+1
            valueIndex = args.index(arg)+2
            key = args[keyIndex]
            value = args[valueIndex]
    assert key is not None, "The last message was not a deploy: {0}".format(context.chaincode['args'])

    chaincode = {
        "path": context.chaincode['path'],
        "language": context.chaincode['language'],
        "name": context.chaincode['name'],
        "args": r'["query","{0}"]'.format(key),
    }
    orderers = endorser_util.get_orderers(context)
    peers = endorser_util.get_peers(context)
    result = endorser_util.query_chaincode(context, chaincode, peers[0], endorser_util.TEST_CHANNEL_ID)
    print(result)
    assert result[peers[0]] == "Query Result: {0}\n".format(value), "Expect {0} = {1}, received from the deploy: {2}".format(key, value, result[peers[0]])
예제 #2
0
def step_impl(context):
    # Temporarily sleep for 2 sec. This delay should be able to be removed once we start using the python sdk
    time.sleep(2)

    # Grab the key/value pair from the deploy
    key = value = None
    print(context.chaincode['args'])
    print(json.loads(context.chaincode['args']))
    args = json.loads(context.chaincode['args'])
    for arg in args:
        if arg == 'init':
            keyIndex = args.index(arg) + 1
            valueIndex = args.index(arg) + 2
            key = args[keyIndex]
            value = args[valueIndex]
    assert key is not None, "The last message was not a deploy: {0}".format(
        context.chaincode['args'])

    chaincode = {
        "path": context.chaincode['path'],
        "language": context.chaincode['language'],
        "name": context.chaincode['name'],
        "args": r'["query","{0}"]'.format(key),
    }
    orderers = endorser_util.get_orderers(context)
    peers = endorser_util.get_peers(context)
    result = endorser_util.query_chaincode(context, chaincode, peers[0],
                                           endorser_util.TEST_CHANNEL_ID)
    print(result)
    assert result[peers[0]] == "Query Result: {0}\n".format(
        value), "Expect {0} = {1}, received from the deploy: {2}".format(
            key, value, result[peers[0]])
예제 #3
0
def step_impl(context):
    # Temporarily sleep for 2 sec. This delay should be able to be removed once we start using the python sdk
    time.sleep(2)

    peers = endorser_util.get_peers(context)

    # Verify that a chaincode container has started
    containers = subprocess.check_output(["docker ps -a"], shell=True)
    chaincode_container = "{0}-{1}-{2}-0".format(
        context.composition.projectName, peers[0], context.chaincode['name'])
    assert chaincode_container in containers, "The chaincode container is not running"