Example #1
0
def step_impl(context, enrollId, tagName, recipientEnrollId):
	assert 'users' in context, "users not found in context. Did you register a user?"
	# Retrieve the userRegistration from the context
	userRegistration = bdd_test_util.getUserRegistration(context, enrollId)
	recipientUserRegistration = bdd_test_util.getUserRegistration(context, recipientEnrollId)
	# Copy value from target to recipient
	recipientUserRegistration.tags[tagName] = userRegistration.tags[tagName]
def step_impl(context, enrollId, tagName, recipientEnrollId):
    assert 'users' in context, "users not found in context. Did you register a user?"
    # Retrieve the userRegistration from the context
    userRegistration = bdd_test_util.getUserRegistration(context, enrollId)
    recipientUserRegistration = bdd_test_util.getUserRegistration(
        context, recipientEnrollId)
    # Copy value from target to recipient
    recipientUserRegistration.tags[tagName] = userRegistration.tags[tagName]
Example #3
0
def step_impl(context, enrollId, proposalAlias, ccDeploymentSpecAlias):
	userRegistration = bdd_test_util.getUserRegistration(context, enrollId)
	assert ccDeploymentSpecAlias in userRegistration.tags, "ChaincodeDeploymentSpec alias '{0}' not found for user '{1}'".format(ccDeploymentSpecAlias, enrollId)
	ccDeploymentSpec = userRegistration.tags[ccDeploymentSpecAlias]
	proposal = endorser_util.createDeploymentProposalForBDD(ccDeploymentSpec)
	assert not proposalAlias in userRegistration.tags, "Proposal alias '{0}' already exists for '{1}'".format(proposalAlias, enrollId)
	userRegistration.tags[proposalAlias] = proposal
def step_impl(context, enrollId, ccAlias, tagName):
    # Retrieve the userRegistration from the context
    userRegistration = bdd_test_util.getUserRegistration(context, enrollId)
    deployedCcSpec = bdd_grpc_util.getDeployment(context, ccAlias)
    assert deployedCcSpec != None, "Deployment NOT found for chaincode alias '{0}'".format(
        ccAlias)
    userRegistration.tags[tagName] = deployedCcSpec.chaincodeID.name
def step_impl(context, enrollId, tagName):
    assert 'users' in context, "users not found in context. Did you register a user?"
    # Retrieve the userRegistration from the context
    userRegistration = bdd_test_util.getUserRegistration(context, enrollId)
    assert tagName in userRegistration.tags, 'Tag "{0}" not found in user "{1}" tags'.format(
        tagName, enrollId)
    context.metadata = userRegistration.tags[tagName]
def step_impl(context, enrollId, ccType, chaincodePath, ccSpecAlias):
    userRegistration = bdd_test_util.getUserRegistration(context, enrollId)
    args = bdd_grpc_util.getArgsFromContextForUser(context, enrollId)
    ccSpec = endorser_util.getChaincodeSpec(ccType, chaincodePath,
                                            bdd_grpc_util.toStringArray(args))
    print("ccSpec = {0}".format(ccSpec))
    userRegistration.tags[ccSpecAlias] = ccSpec
Example #7
0
def step_impl(context, enrollId, ccDeploymentSpecAlias, ccSpecAlias, devopsComposeService):
	userRegistration = bdd_test_util.getUserRegistration(context, enrollId)
	assert ccSpecAlias in userRegistration.tags, "ChaincodeSpec alias '{0}' not found for user '{1}'".format(ccSpecAlias, enrollId)

	ipAddress = bdd_test_util.ipFromContainerNamePart(devopsComposeService, context.compose_containers)
	channel = bdd_grpc_util.getGRPCChannel(ipAddress)
	devopsStub = devops_pb2.beta_create_Devops_stub(channel)
	deploymentSpec = devopsStub.Build(userRegistration.tags[ccSpecAlias],20)
	userRegistration.tags[ccDeploymentSpecAlias] = deploymentSpec
def step_impl(context, enrollId, proposalAlias, ccDeploymentSpecAlias):
    userRegistration = bdd_test_util.getUserRegistration(context, enrollId)
    assert ccDeploymentSpecAlias in userRegistration.tags, "ChaincodeDeploymentSpec alias '{0}' not found for user '{1}'".format(
        ccDeploymentSpecAlias, enrollId)
    ccDeploymentSpec = userRegistration.tags[ccDeploymentSpecAlias]
    proposal = endorser_util.createDeploymentProposalForBDD(ccDeploymentSpec)
    assert not proposalAlias in userRegistration.tags, "Proposal alias '{0}' already exists for '{1}'".format(
        proposalAlias, enrollId)
    userRegistration.tags[proposalAlias] = proposal
Example #9
0
def getGRPCChannelAndUser(context, enrollId):
    '''Returns a tuple of GRPC channel and UserRegistration instance.  The channel is open to the composeService that the user registered with.'''
    userRegistration = bdd_test_util.getUserRegistration(context, enrollId)

    # Get the IP address of the server that the user registered on
    ipAddress = bdd_test_util.ipFromContainerNamePart(userRegistration.composeService, context.compose_containers)

    channel = getGRPCChannel(ipAddress)

    return (channel, userRegistration)
Example #10
0
def getGRPCChannelAndUser(context, enrollId):
    '''Returns a tuple of GRPC channel and UserRegistration instance.  The channel is open to the composeService that the user registered with.'''
    userRegistration = bdd_test_util.getUserRegistration(context, enrollId)

    # Get the IP address of the server that the user registered on
    ipAddress = bdd_test_util.ipFromContainerNamePart(userRegistration.composeService, context.compose_containers)

    channel = getGRPCChannel(ipAddress)

    return (channel, userRegistration)
Example #11
0
def step_impl(context, enrollId, proposalAlias, timeout):
	assert 'table' in context, "Expected table of endorsers"
	userRegistration = bdd_test_util.getUserRegistration(context, enrollId)
	assert proposalAlias in userRegistration.tags, "Proposal alias '{0}' not found for user '{1}'".format(proposalAlias, enrollId)
	proposal = userRegistration.tags[proposalAlias]

	# Send proposal to each specified endorser, waiting 'timeout' seconds for response/error
	endorsers = context.table.headings
	proposalResponseFutures = [endorserStub.ProcessProposal.future(proposal, int(timeout)) for endorserStub in endorser_util.getEndorserStubs(context, endorsers)]
	resultsDict =  dict(zip(endorsers, [respFuture.result() for respFuture in proposalResponseFutures]))
	userRegistration.lastResult = resultsDict
Example #12
0
def step_impl(context, enrollId, proposalResponsesAlias, statusCode):
	assert 'table' in context, "Expected table of endorsers"
	userRegistration = bdd_test_util.getUserRegistration(context, enrollId)
	# Make sure proposalResponseAlias not already defined
	assert proposalResponsesAlias in userRegistration.tags, "Expected proposal responses at tag '{0}', for user '{1}'".format(proposalResponsesAlias, enrollId)
	proposalRespDict = userRegistration.tags[proposalResponsesAlias]

	# Loop through endorser proposal Responses
	endorsers = context.table.headings
	for respSatusCode in [proposalRespDict[endorser].response.status for endorser in endorsers]:
		assert int(statusCode) == respSatusCode, "Expected proposal response status code of {0} from {1}, received {2}".format(statusCode, endorser, respSatusCode)
def step_impl(context, enrollId, ccDeploymentSpecAlias, ccSpecAlias,
              devopsComposeService):
    userRegistration = bdd_test_util.getUserRegistration(context, enrollId)
    assert ccSpecAlias in userRegistration.tags, "ChaincodeSpec alias '{0}' not found for user '{1}'".format(
        ccSpecAlias, enrollId)

    ipAddress = bdd_test_util.ipFromContainerNamePart(
        devopsComposeService, context.compose_containers)
    channel = bdd_grpc_util.getGRPCChannel(ipAddress)
    devopsStub = devops_pb2.beta_create_Devops_stub(channel)
    deploymentSpec = devopsStub.Build(userRegistration.tags[ccSpecAlias], 20)
    userRegistration.tags[ccDeploymentSpecAlias] = deploymentSpec
def step_impl(context, enrollId, proposalAlias, timeout):
    assert 'table' in context, "Expected table of endorsers"
    userRegistration = bdd_test_util.getUserRegistration(context, enrollId)
    assert proposalAlias in userRegistration.tags, "Proposal alias '{0}' not found for user '{1}'".format(
        proposalAlias, enrollId)
    proposal = userRegistration.tags[proposalAlias]

    # Send proposal to each specified endorser, waiting 'timeout' seconds for response/error
    endorsers = context.table.headings
    proposalResponseFutures = [
        endorserStub.ProcessProposal.future(proposal, int(timeout))
        for endorserStub in endorser_util.getEndorserStubs(context, endorsers)
    ]
    resultsDict = dict(
        zip(endorsers,
            [respFuture.result() for respFuture in proposalResponseFutures]))
    userRegistration.lastResult = resultsDict
def step_impl(context, enrollId, proposalResponsesAlias, statusCode):
    assert 'table' in context, "Expected table of endorsers"
    userRegistration = bdd_test_util.getUserRegistration(context, enrollId)
    # Make sure proposalResponseAlias not already defined
    assert proposalResponsesAlias in userRegistration.tags, "Expected proposal responses at tag '{0}', for user '{1}'".format(
        proposalResponsesAlias, enrollId)
    proposalRespDict = userRegistration.tags[proposalResponsesAlias]

    # Loop through endorser proposal Responses
    endorsers = context.table.headings
    for respSatusCode in [
            proposalRespDict[endorser].response.status
            for endorser in endorsers
    ]:
        assert int(
            statusCode
        ) == respSatusCode, "Expected proposal response status code of {0} from {1}, received {2}".format(
            statusCode, endorser, respSatusCode)
Example #16
0
def getArgsFromContextForUser(context, enrollId):
    # Update the chaincodeSpec ctorMsg for invoke
    args = []
    if 'table' in context:
       # There are function arguments
       userRegistration = bdd_test_util.getUserRegistration(context, enrollId)
       # Allow the user to specify expressions referencing tags in the args list
       pattern = re.compile('\{(.*)\}$')
       for arg in context.table[0].cells:
          m = pattern.match(arg)
          if m:
              # tagName reference found in args list
              tagName = m.groups()[0]
              # make sure the tagName is found in the users tags
              assert tagName in userRegistration.tags, "TagName '{0}' not found for user '{1}'".format(tagName, userRegistration.getUserName())
              args.append(userRegistration.tags[tagName])
          else:
              #No tag referenced, pass the arg
              args.append(arg)
    return args
Example #17
0
def getArgsFromContextForUser(context, enrollId):
    # Update the chaincodeSpec ctorMsg for invoke
    args = []
    if 'table' in context:
       # There are function arguments
       userRegistration = bdd_test_util.getUserRegistration(context, enrollId)
       # Allow the user to specify expressions referencing tags in the args list
       pattern = re.compile('\{(.*)\}$')
       for arg in context.table[0].cells:
          m = pattern.match(arg)
          if m:
              # tagName reference found in args list
              tagName = m.groups()[0]
              # make sure the tagName is found in the users tags
              assert tagName in userRegistration.tags, "TagName '{0}' not found for user '{1}'".format(tagName, userRegistration.getUserName())
              args.append(userRegistration.tags[tagName])
          else:
              #No tag referenced, pass the arg
              args.append(arg)
    return args
def step_impl(context, enrollId, tagName):
    assert 'users' in context, "users not found in context. Did you register a user?"
    # Retrieve the userRegistration from the context
    userRegistration = bdd_test_util.getUserRegistration(context, enrollId)
    userRegistration.tags[tagName] = userRegistration.lastResult
Example #19
0
def step_impl(context, enrollId, ccType, chaincodePath, ccSpecAlias):
	userRegistration = bdd_test_util.getUserRegistration(context, enrollId)
	args =  bdd_grpc_util.getArgsFromContextForUser(context, enrollId)
	ccSpec = endorser_util.getChaincodeSpec(ccType, chaincodePath, bdd_grpc_util.toStringArray(args))
	print("ccSpec = {0}".format(ccSpec))
	userRegistration.tags[ccSpecAlias] = ccSpec
Example #20
0
def step_impl(context, enrollId, tagName):
	assert 'users' in context, "users not found in context. Did you register a user?"
	# Retrieve the userRegistration from the context
	userRegistration = bdd_test_util.getUserRegistration(context, enrollId)
	assert tagName in userRegistration.tags, 'Tag "{0}" not found in user "{1}" tags'.format(tagName, enrollId)
	context.metadata = userRegistration.tags[tagName] 
Example #21
0
def step_impl(context, enrollId, tagName):
	assert 'users' in context, "users not found in context. Did you register a user?"
	# Retrieve the userRegistration from the context
	userRegistration = bdd_test_util.getUserRegistration(context, enrollId)
	userRegistration.tags[tagName] = userRegistration.lastResult
Example #22
0
def step_impl(context, enrollId, ccAlias, tagName):
	# Retrieve the userRegistration from the context
	userRegistration = bdd_test_util.getUserRegistration(context, enrollId)
	deployedCcSpec = bdd_test_util.getDeployment(context, ccAlias)
	assert deployedCcSpec != None, "Deployment NOT found for chaincode alias '{0}'".format(ccAlias)
	userRegistration.tags[tagName] = deployedCcSpec.chaincodeID.name