def testSendAttribSucceedsForExistingDidDest(be, do, poolNodesStarted,
                                             localTrusteeCli):

    seed = randomSeed()
    idr, verkey = createHalfKeyIdentifierAndAbbrevVerkey(seed=seed)

    userCli = localTrusteeCli
    addNym(be, do, userCli, idr=idr, verkey=verkey)
    newKey(be, do, userCli, seed=seed.decode())

    sendAttribParameters = {'dest': idr, 'raw': json.dumps({'name': 'Alice'})}

    be(userCli)
    do('send ATTRIB dest={dest} raw={raw}',
       mapper=sendAttribParameters,
       expect=ATTRIBUTE_ADDED,
       within=2)
def testSendAttribFailsForNotExistingCryptonymDest(be, do, poolNodesStarted,
                                                   localTrusteeCli):

    seed = randomSeed()
    cryptonym = createCryptonym(seed=seed)

    userCli = localTrusteeCli
    newKey(be, do, userCli, seed=seed.decode())

    sendAttribParameters = {
        'dest': cryptonym,
        'raw': json.dumps({'name': 'Alice'})
    }

    be(userCli)
    do('send ATTRIB dest={dest} raw={raw}',
       mapper=sendAttribParameters,
       expect=ERROR,
       within=2)
def thriftCli(be, do, thriftCLI, newKeyringOut, thriftMap):
    be(thriftCLI)
    setPromptAndKeyring(do, "Thrift", newKeyringOut, thriftMap)
    newKey(be, do, thriftCLI, seed=thriftMap['seed'])

    return thriftCLI
def acmeCli(be, do, acmeCLI, newKeyringOut, acmeMap):
    be(acmeCLI)
    setPromptAndKeyring(do, "Acme", newKeyringOut, acmeMap)
    newKey(be, do, acmeCLI, seed=acmeMap['seed'])

    return acmeCLI
def faberCli(be, do, faberCLI, newKeyringOut, faberMap):
    be(faberCLI)
    setPromptAndKeyring(do, "Faber", newKeyringOut, faberMap)
    newKey(be, do, faberCLI, seed=faberMap['seed'])

    return faberCLI
def thriftCli(be, do, thriftCLI, newKeyringOut, thriftMap):
    be(thriftCLI)
    setPromptAndKeyring(do, "Thrift", newKeyringOut, thriftMap)
    newKey(be, do, thriftCLI, seed=thriftMap['seed'])

    return thriftCLI
def acmeCli(be, do, acmeCLI, newKeyringOut, acmeMap):
    be(acmeCLI)
    setPromptAndKeyring(do, "Acme", newKeyringOut, acmeMap)
    newKey(be, do, acmeCLI, seed=acmeMap['seed'])

    return acmeCLI
def faberCli(be, do, faberCLI, newKeyringOut, faberMap):
    be(faberCLI)
    setPromptAndKeyring(do, "Faber", newKeyringOut, faberMap)
    newKey(be, do, faberCLI, seed=faberMap['seed'])

    return faberCLI