Ejemplo n.º 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]])
Ejemplo n.º 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]])
Ejemplo n.º 3
0
def query_impl(context, channel, name, args, component):
    # Temporarily sleep for 2 sec. This delay should be able to be removed once we start using the python sdk
    time.sleep(2)
    chaincode = {"args": args, "name": name}
    context.result = endorser_util.query_chaincode(context, chaincode,
                                                   component, channel)
Ejemplo n.º 4
0
def query_impl(context, channel, name, args, component):
    # Temporarily sleep for 2 sec. This delay should be able to be removed once we start using the python sdk
    time.sleep(2)
    chaincode = {"args": args,
                 "name": name}
    context.result = endorser_util.query_chaincode(context, chaincode, component, channel)