def verkeyAddedToCID(be, do, philCli, cidAdded, trustAnchorWallet): newSigner = SimpleSigner() addNym(be, do, philCli, trustAnchorWallet.defaultId, newSigner.identifier) # Updating the identifier of the new signer to match the one in wallet newSigner._identifier = trustAnchorWallet.defaultId trustAnchorWallet.updateSigner(trustAnchorWallet.defaultId, newSigner) return newSigner
def createAgent(agentClass, name, wallet=None, basedirpath=None, port=None, loop=None, clientClass=Client): config = getConfig() if not wallet: wallet = Wallet(name) wallet.addIdentifier(signer=SimpleSigner( seed=randomString(32).encode('utf-8'))) if not basedirpath: basedirpath = config.baseDir if not port: _, port = genHa() _, clientPort = genHa() client = clientClass(randomString(6), ha=("0.0.0.0", clientPort), basedirpath=basedirpath) return agentClass(basedirpath=basedirpath, client=client, wallet=wallet, port=port, loop=loop)
def send_new_node_txn(sigseed, nodeIp, nodePort, clientIp, clientPort, bls_key, newNodeName, stewardClient, stewardWallet, transformOpFunc=None): nodeSigner = SimpleSigner(seed=sigseed) op = { TXN_TYPE: NODE, TARGET_NYM: nodeSigner.identifier, DATA: { NODE_IP: nodeIp, NODE_PORT: nodePort, CLIENT_IP: clientIp, CLIENT_PORT: clientPort, ALIAS: newNodeName, SERVICES: [ VALIDATOR, ], BLS_KEY: bls_key } } if transformOpFunc is not None: transformOpFunc(op) req = stewardWallet.signOp(op) stewardClient.submitReqs(req) return req, \ op[DATA].get(NODE_IP), op[DATA].get(NODE_PORT), \ op[DATA].get(CLIENT_IP), op[DATA].get(CLIENT_PORT), \ sigseed
def generateNymsData(count): signers = [SimpleSigner(seed=randomSeed()) for i in range(count)] Nym = namedtuple("Nym", ["seed", "identifier", "verkey"]) return [ Nym(signer.seed, signer.identifier, signer.verkey) for signer in signers ]
def changeHA(looper, config, nodeName, nodeSeed, newNodeHA, stewardName, stewardsSeed, newClientHA=None, basedir=None): if not newClientHA: newClientHA = HA(newNodeHA.host, newNodeHA.port + 1) assert basedir is not None # prepare steward wallet stewardSigner = DidSigner(seed=stewardsSeed) stewardWallet = Wallet(stewardName) stewardWallet.addIdentifier(signer=stewardSigner) # prepare client to submit change ha request _, randomClientPort = genHa() client = Client(stewardName, ha=('0.0.0.0', randomClientPort), config=config, basedirpath=basedir) looper.add(client) timeout = waits.expectedClientToPoolConnectionTimeout(4) looper.run(eventually(__checkClientConnected, client, retryWait=1, timeout=timeout)) nodeVerKey = SimpleSigner(seed=nodeSeed).verkey # send request req = submitNodeIpChange(client, stewardWallet, nodeName, nodeVerKey, newNodeHA, newClientHA) return client, req
def testNodeKeysChanged(looper, txnPoolNodeSet, tdirWithPoolTxns, tconf, steward1, nodeThetaAdded, allPluginsPath=None): newSteward, newStewardWallet, newNode = nodeThetaAdded newNode.stop() looper.removeProdable(name=newNode.name) nodeHa, nodeCHa = HA(*newNode.nodestack.ha), HA(*newNode.clientstack.ha) sigseed = randomString(32).encode() verkey = base58.b58encode(SimpleSigner(seed=sigseed).naclSigner.verraw) changeNodeKeys(looper, newSteward, newStewardWallet, newNode, verkey) initNodeKeysForBothStacks(newNode.name, tdirWithPoolTxns, sigseed, override=True) logger.debug("{} starting with HAs {} {}".format(newNode, nodeHa, nodeCHa)) node = TestNode(newNode.name, basedirpath=tdirWithPoolTxns, config=tconf, ha=nodeHa, cliha=nodeCHa, pluginPaths=allPluginsPath) looper.add(node) # The last element of `txnPoolNodeSet` is the node Theta that was just # stopped txnPoolNodeSet[-1] = node looper.run(checkNodesConnected(stacks=txnPoolNodeSet)) waitNodeDataEquality(looper, node, *txnPoolNodeSet[:-1]) ensureClientConnectedToNodesAndPoolLedgerSame(looper, steward1, *txnPoolNodeSet) ensureClientConnectedToNodesAndPoolLedgerSame(looper, newSteward, *txnPoolNodeSet)
def nymsAddedInQuickSuccession(nodeSet, addedTrustAnchor, looper, trustAnchor, trustAnchorWallet): usigner = SimpleSigner() nym = usigner.verkey idy = Identity(identifier=nym) trustAnchorWallet.addTrustAnchoredIdentity(idy) # Creating a NYM request with same nym again req = idy.ledgerRequest() trustAnchorWallet._pending.appendleft((req, idy.identifier)) reqs = trustAnchorWallet.preparePending() trustAnchor.submitReqs(*reqs) def check(): assert trustAnchorWallet._trustAnchored[nym].seqNo timeout = waits.expectedTransactionExecutionTime(len(nodeSet)) looper.run(eventually(check, timeout=timeout)) timeout = waits.expectedReqNAckQuorumTime() looper.run( eventually(checkNacks, trustAnchor, req.reqId, "is already added", retryWait=1, timeout=timeout)) count = 0 for node in nodeSet: txns = node.domainLedger.getAllTxn() for seq, txn in txns.items(): if txn[TXN_TYPE] == NYM and txn[TARGET_NYM] == usigner.identifier: count += 1 assert (count == len(nodeSet))
def load(): port = genHa()[1] ha = HA('0.0.0.0', port) name = "hello" wallet = Wallet(name) wallet.addIdentifier(signer=SimpleSigner( seed=b'000000000000000000000000Steward1')) client = Client(name, ha=ha) with Looper(debug=True) as looper: looper.add(client) print('Will send {} reqs in all'.format(numReqs)) requests = sendRandomRequests(wallet, client, numReqs) start = perf_counter() for i in range(0, numReqs, numReqs // splits): print('Will wait for {} now'.format(numReqs // splits)) s = perf_counter() reqs = requests[i:i + numReqs // splits + 1] waitForSufficientRepliesForRequests(looper, client, requests=reqs, fVal=2, customTimeoutPerReq=3) print('>>> Got replies for {} requests << in {}'.format( numReqs // splits, perf_counter() - s)) end = perf_counter() print('>>>{}<<<'.format(end - start)) exit(0)
def testNodeKeysChanged(looper, txnPoolNodeSet, tdir, tconf, sdk_node_theta_added, sdk_pool_handle, allPluginsPath=None): new_steward_wallet, new_node = sdk_node_theta_added new_node.stop() looper.removeProdable(name=new_node.name) nodeHa, nodeCHa = HA(*new_node.nodestack.ha), HA(*new_node.clientstack.ha) sigseed = randomString(32).encode() verkey = base58.b58encode(SimpleSigner(seed=sigseed).naclSigner.verraw).decode("utf-8") sdk_change_node_keys(looper, new_node, new_steward_wallet, sdk_pool_handle, verkey) config_helper = PNodeConfigHelper(new_node.name, tconf, chroot=tdir) initNodeKeysForBothStacks(new_node.name, config_helper.keys_dir, sigseed, override=True) logger.debug("{} starting with HAs {} {}".format(new_node, nodeHa, nodeCHa)) node = TestNode(new_node.name, config_helper=config_helper, config=tconf, ha=nodeHa, cliha=nodeCHa, pluginPaths=allPluginsPath) looper.add(node) # The last element of `txnPoolNodeSet` is the node Theta that was just # stopped txnPoolNodeSet[-1] = node looper.run(checkNodesConnected(txnPoolNodeSet)) waitNodeDataEquality(looper, node, *txnPoolNodeSet[:-1]) sdk_ensure_pool_functional(looper, txnPoolNodeSet, new_steward_wallet, sdk_pool_handle)
def sendAddNewNode(newNodeName, stewardClient, stewardWallet, transformOpFunc=None): sigseed = randomString(32).encode() nodeSigner = SimpleSigner(seed=sigseed) (nodeIp, nodePort), (clientIp, clientPort) = genHa(2) op = { TXN_TYPE: NODE, TARGET_NYM: nodeSigner.identifier, DATA: { NODE_IP: nodeIp, NODE_PORT: nodePort, CLIENT_IP: clientIp, CLIENT_PORT: clientPort, ALIAS: newNodeName, SERVICES: [ VALIDATOR, ] } } if transformOpFunc is not None: transformOpFunc(op) req = stewardWallet.signOp(op) stewardClient.submitReqs(req) return req, \ op[DATA].get(NODE_IP), op[DATA].get(NODE_PORT), \ op[DATA].get(CLIENT_IP), op[DATA].get(CLIENT_PORT), \ sigseed
def testStewardCannotAddNodeWithNonBase58VerKey(looper, tdir, txnPoolNodeSet, newAdHocSteward): """ The Case: Steward accidentally sends the NODE txn with a non base58 verkey. The expected result: Steward gets NAck response from the pool. """ # create a new steward newSteward, newStewardWallet = newAdHocSteward newNodeName = "Epsilon" # get hex VerKey sigseed = randomString(32).encode() nodeSigner = SimpleSigner(seed=sigseed) b = base58.b58decode(nodeSigner.identifier) hexVerKey = bytearray(b).hex() def _setHexVerkey(op): op[TARGET_NYM] = hexVerKey return op sendAddNewNode(newNodeName, newSteward, newStewardWallet, transformOpFunc=_setHexVerkey) waitReqNackFromPoolWithReason(looper, txnPoolNodeSet, newSteward, 'should not contain the following chars')
def newStewardVals(): newStewardSeed = randomSeed() return { 'newStewardSeed': newStewardSeed.decode(), 'newStewardIdr': SimpleSigner(seed=newStewardSeed).identifier, }
def test_authenticate_raises_correct_exception(): msg = dict(myMsg=msg_str) simple_signer = SimpleSigner() identifier = simple_signer.identifier verkey = simple_signer.verkey dummyAr = DummyAuthenticator() dummyAr.addIdr(identifier, verkey) pytest.raises(MissingSignature, dummyAr.authenticate, msg, identifier)
def addUser(looper, creatorClient, creatorWallet, name, useDid=True, addVerkey=True): wallet = Wallet(name) signer = DidSigner() if useDid else SimpleSigner() idr, _ = wallet.addIdentifier(signer=signer) verkey = wallet.getVerkey(idr) if addVerkey else None createNym(looper, idr, creatorClient, creatorWallet, verkey=verkey) return wallet
def getPoolTxnData(nodeAndClientInfoFilePath, poolId, newPoolTxnNodeNames): data = {} data["seeds"] = {} data["txns"] = [] for index, n in enumerate(newPoolTxnNodeNames, start=1): newStewardAlias = poolId + "Steward" + str(index) stewardSeed = (newStewardAlias + "0" * (32 - len(newStewardAlias))).encode() data["seeds"][newStewardAlias] = stewardSeed stewardSigner = SimpleSigner(seed=stewardSeed) data["txns"].append({ TARGET_NYM: stewardSigner.verkey, ROLE: STEWARD, TXN_TYPE: NYM, ALIAS: poolId + "Steward" + str(index), TXN_ID: sha256("{}".format(stewardSigner.verkey).encode()).hexdigest() }) newNodeAlias = n nodeSeed = (newNodeAlias + "0" * (32 - len(newNodeAlias))).encode() data["seeds"][newNodeAlias] = nodeSeed nodeSigner = SimpleSigner(seed=nodeSeed) data["txns"].append({ TARGET_NYM: nodeSigner.verkey, TXN_TYPE: NODE, f.IDENTIFIER.nm: stewardSigner.verkey, DATA: { CLIENT_IP: "127.0.0.1", ALIAS: newNodeAlias, NODE_IP: "127.0.0.1", NODE_PORT: genHa()[1], CLIENT_PORT: genHa()[1], SERVICES: [VALIDATOR], }, TXN_ID: sha256("{}".format(nodeSigner.verkey).encode()).hexdigest() }) return data
def testNewverkeyAddedToCID(be, do, philCli, trustAnchorSigner, verkeyRemovedFromExistingCID): newSigner = SimpleSigner() addNym(be, do, philCli, trustAnchorSigner.identifier, newSigner.verkey) getNym( be, do, philCli, trustAnchorSigner.identifier, getCurrentVerkeyIsgMsgs(trustAnchorSigner.identifier, newSigner.verkey))
def poolTxnData(request): nodeCount = getValueFromModule(request, "nodeCount", 4) nodes_with_bls = getValueFromModule(request, "nodes_wth_bls", nodeCount) data = {'txns': [], 'seeds': {}, 'nodesWithBls': {}} for i, node_name in zip(range(1, nodeCount + 1), genNodeNames(nodeCount)): data['seeds'][node_name] = node_name + '0' * (32 - len(node_name)) steward_name = 'Steward' + str(i) data['seeds'][steward_name] = steward_name + \ '0' * (32 - len(steward_name)) n_idr = SimpleSigner(seed=data['seeds'][node_name].encode()).identifier s_idr = DidSigner(seed=data['seeds'][steward_name].encode()) data['txns'].append({ TXN_TYPE: NYM, ROLE: STEWARD, ALIAS: steward_name, TARGET_NYM: s_idr.identifier, VERKEY: s_idr.verkey, }) node_txn = { TXN_TYPE: NODE, f.IDENTIFIER.nm: s_idr.identifier, TARGET_NYM: n_idr, DATA: { ALIAS: node_name, SERVICES: [VALIDATOR], NODE_IP: '127.0.0.1', NODE_PORT: genHa()[1], CLIENT_IP: '127.0.0.1', CLIENT_PORT: genHa()[1], } } if i <= nodes_with_bls: _, bls_key = create_default_bls_crypto_factory().generate_bls_keys( seed=data['seeds'][node_name]) node_txn[DATA][BLS_KEY] = bls_key data['nodesWithBls'][node_name] = True data['txns'].append(node_txn) more_data_seeds = \ { "Alice": "99999999999999999999999999999999", "Jason": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", "John": "dddddddddddddddddddddddddddddddd", "Les": "ffffffffffffffffffffffffffffffff" } more_data_users = [] for more_name, more_seed in more_data_seeds.items(): signer = DidSigner(seed=more_seed.encode()) more_data_users.append({TXN_TYPE: NYM, ALIAS: more_name, TARGET_NYM: signer.identifier, VERKEY: signer.verkey, f.IDENTIFIER.nm: "5rArie7XKukPCaEwq5XGQJnM9Fc5aZE3M9HAPVfMU2xC"}) data['txns'].extend(more_data_users) data['seeds'].update(more_data_seeds) return data
def getPoolTxnData(poolId, newPoolTxnNodeNames): data = {} data["seeds"] = {} data["txns"] = [] data['nodesWithBls'] = {} for index, n in enumerate(newPoolTxnNodeNames, start=1): newStewardAlias = poolId + "Steward" + str(index) stewardSeed = (newStewardAlias + "0" * (32 - len(newStewardAlias))).encode() data["seeds"][newStewardAlias] = stewardSeed stewardSigner = SimpleSigner(seed=stewardSeed) data["txns"].append( Member.nym_txn(nym=stewardSigner.identifier, verkey=stewardSigner.verkey, role=STEWARD, name=poolId + "Steward" + str(index), seq_no=index, txn_id=sha256("{}".format( stewardSigner.verkey).encode()).hexdigest())) newNodeAlias = n nodeSeed = (newNodeAlias + "0" * (32 - len(newNodeAlias))).encode() data["seeds"][newNodeAlias] = nodeSeed nodeSigner = SimpleSigner(seed=nodeSeed) _, bls_key, key_proof = create_default_bls_crypto_factory( ).generate_bls_keys(seed=data['seeds'][n]) data['nodesWithBls'][n] = True node_txn = Steward.node_txn( steward_nym=stewardSigner.verkey, node_name=newNodeAlias, nym=nodeSigner.verkey, ip="127.0.0.1", node_port=genHa()[1], client_port=genHa()[1], client_ip="127.0.0.1", blskey=bls_key, bls_key_proof=key_proof, services=[VALIDATOR], txn_id=sha256("{}".format(nodeSigner.verkey).encode()).hexdigest()) data["txns"].append(node_txn) return data
def getPoolTxnData(poolId, newPoolTxnNodeNames): data = {} data["seeds"] = {} data["txns"] = [] data['nodesWithBls'] = {} for index, n in enumerate(newPoolTxnNodeNames, start=1): newStewardAlias = poolId + "Steward" + str(index) stewardSeed = (newStewardAlias + "0" * (32 - len(newStewardAlias))).encode() data["seeds"][newStewardAlias] = stewardSeed stewardSigner = SimpleSigner(seed=stewardSeed) data["txns"].append({ TARGET_NYM: stewardSigner.verkey, ROLE: STEWARD, TXN_TYPE: NYM, ALIAS: poolId + "Steward" + str(index), TXN_ID: sha256("{}".format(stewardSigner.verkey).encode()).hexdigest() }) newNodeAlias = n nodeSeed = (newNodeAlias + "0" * (32 - len(newNodeAlias))).encode() data["seeds"][newNodeAlias] = nodeSeed nodeSigner = SimpleSigner(seed=nodeSeed) node_txn = { TARGET_NYM: nodeSigner.verkey, TXN_TYPE: NODE, f.IDENTIFIER.nm: stewardSigner.verkey, DATA: { CLIENT_IP: "127.0.0.1", ALIAS: newNodeAlias, NODE_IP: "127.0.0.1", NODE_PORT: genHa()[1], CLIENT_PORT: genHa()[1], SERVICES: [VALIDATOR], }, TXN_ID: sha256("{}".format(nodeSigner.verkey).encode()).hexdigest() } _, bls_key = create_default_bls_crypto_factory().generate_bls_keys( seed=data['seeds'][n]) node_txn[DATA][BLS_KEY] = bls_key data['nodesWithBls'][n] = True data["txns"].append(node_txn) return data
def changeNodeHa(looper, txnPoolNodeSet, tdirWithPoolTxns, poolTxnData, poolTxnStewardNames, tconf, shouldBePrimary): # prepare new ha for node and client stack subjectedNode = None stewardName = None stewardsSeed = None for nodeIndex, n in enumerate(txnPoolNodeSet): if shouldBePrimary == (n.primaryReplicaNo == 0): subjectedNode = n stewardName = poolTxnStewardNames[nodeIndex] stewardsSeed = poolTxnData["seeds"][stewardName].encode() break nodeStackNewHA, clientStackNewHA = genHa(2) logger.debug("change HA for node: {} to {}".format( subjectedNode.name, (nodeStackNewHA, clientStackNewHA))) nodeSeed = poolTxnData["seeds"][subjectedNode.name].encode() # change HA stewardClient, req = changeHA(looper, tconf, subjectedNode.name, nodeSeed, nodeStackNewHA, stewardName, stewardsSeed) waitForSufficientRepliesForRequests(looper, stewardClient, requests=[req]) # stop node for which HA will be changed subjectedNode.stop() looper.removeProdable(subjectedNode) # start node with new HA restartedNode = TestNode(subjectedNode.name, basedirpath=tdirWithPoolTxns, config=tconf, ha=nodeStackNewHA, cliha=clientStackNewHA) looper.add(restartedNode) txnPoolNodeSet[nodeIndex] = restartedNode looper.run(checkNodesConnected(txnPoolNodeSet, customTimeout=70)) electionTimeout = waits.expectedPoolElectionTimeout( nodeCount=len(txnPoolNodeSet), numOfReelections=3) ensureElectionsDone(looper, txnPoolNodeSet, retryWait=1, customTimeout=electionTimeout) # start client and check the node HA anotherClient, _ = genTestClient(tmpdir=tdirWithPoolTxns, usePoolLedger=True) looper.add(anotherClient) looper.run(eventually(anotherClient.ensureConnectedToNodes)) stewardWallet = Wallet(stewardName) stewardWallet.addIdentifier(signer=SimpleSigner(seed=stewardsSeed)) sendReqsToNodesAndVerifySuffReplies(looper, stewardWallet, stewardClient, 8)
def test_address_to_verkey_and_vice_versa(): for _ in range(100): signer = SimpleSigner() assert len(signer.naclSigner.verraw) == 32 address = verkey_to_address(signer.verkey) assert len(b58decode(address)) == 36 verkey = address_to_verkey(address) assert len(b58decode(verkey)) == 32 assert signer.naclSigner.verraw == b58decode(verkey) assert signer.verkey == verkey
def startAgent(name, seed, loop=None): agentWallet = Wallet(name) agentWallet.addIdentifier(signer=SimpleSigner(seed=bytes(seed, 'utf-8'))) agent = createAgent(WalletedAgent, name, wallet=agentWallet, loop=loop) agentPort = agent.endpoint.stackParams['ha'].port with Looper(debug=True) as looper: looper.add(agent) log.debug("Running {} now (port: {})".format(name, agentPort)) return agent
def nonSponsor(looper, nodeSet, tdir): sseed = b'this is a secret sponsor seed...' signer = SimpleSigner(seed=sseed) c, _ = genTestClient(nodeSet, tmpdir=tdir, usePoolLedger=True) w = Wallet(c.name) w.addIdentifier(signer=signer) c.registerObserver(w.handleIncomingReply) looper.add(c) looper.run(c.ensureConnectedToNodes()) return c, w
def buildPoolClientAndWallet(clientData, tempDir, clientClass=None, walletClass=None): walletClass = walletClass or Wallet clientClass = clientClass or TestClient name, sigseed = clientData w = walletClass(name) w.addIdentifier(signer=SimpleSigner(seed=sigseed)) client, _ = genTestClient(name=name, identifier=w.defaultId, tmpdir=tempDir, usePoolLedger=True, testClientClass=clientClass) return client, w
def changeNodeHa(looper, txnPoolNodeSet, tdirWithPoolTxns, poolTxnData, poolTxnStewardNames, tconf, shouldBePrimary): # prepare new ha for node and client stack subjectedNode = None stewardName = None stewardsSeed = None for nodeIndex, n in enumerate(txnPoolNodeSet): if (shouldBePrimary and n.primaryReplicaNo == 0) or \ (not shouldBePrimary and n.primaryReplicaNo != 0): subjectedNode = n stewardName = poolTxnStewardNames[nodeIndex] stewardsSeed = poolTxnData["seeds"][stewardName].encode() break nodeStackNewHA, clientStackNewHA = genHa(2) logger.debug("change HA for node: {} to {}". format(subjectedNode.name, (nodeStackNewHA, clientStackNewHA))) nodeSeed = poolTxnData["seeds"][subjectedNode.name].encode() # change HA stewardClient, req = changeHA(looper, tconf, subjectedNode.name, nodeSeed, nodeStackNewHA, stewardName, stewardsSeed) f = getMaxFailures(len(stewardClient.nodeReg)) looper.run(eventually(checkSufficientRepliesRecvd, stewardClient.inBox, req.reqId, f, retryWait=1, timeout=20)) # stop node for which HA will be changed subjectedNode.stop() looper.removeProdable(subjectedNode) # start node with new HA restartedNode = TestNode(subjectedNode.name, basedirpath=tdirWithPoolTxns, config=tconf, ha=nodeStackNewHA, cliha=clientStackNewHA) looper.add(restartedNode) txnPoolNodeSet[nodeIndex] = restartedNode looper.run(checkNodesConnected(txnPoolNodeSet, overrideTimeout=70)) ensureElectionsDone(looper, txnPoolNodeSet, retryWait=1, timeout=10) # start client and check the node HA anotherClient, _ = genTestClient(tmpdir=tdirWithPoolTxns, usePoolLedger=True) looper.add(anotherClient) looper.run(eventually(anotherClient.ensureConnectedToNodes)) stewardWallet = Wallet(stewardName) stewardWallet.addIdentifier(signer=SimpleSigner(seed=stewardsSeed)) sendReqsToNodesAndVerifySuffReplies(looper, stewardWallet, stewardClient, 8) looper.run(eventually(checkIfGenesisPoolTxnFileUpdated, *txnPoolNodeSet, stewardClient, anotherClient, retryWait=1, timeout=10))
def testNonSponsoredNymCanDoGetNym(nodeSet, addedSponsor, sponsorWallet, tdir, looper): signer = SimpleSigner() someClient, _ = genTestClient(nodeSet, tmpdir=tdir, usePoolLedger=True) wallet = Wallet(someClient.name) wallet.addIdentifier(signer=signer) someClient.registerObserver(wallet.handleIncomingReply) looper.add(someClient) looper.run(someClient.ensureConnectedToNodes()) needle = sponsorWallet.defaultId makeGetNymRequest(someClient, wallet, needle) looper.run(eventually(someClient.hasNym, needle, retryWait=1, timeout=5))
def anotherSponsor(nodeSet, steward, stewardWallet, tdir, looper): sseed = b'this is 1 secret sponsor seed...' signer = SimpleSigner(seed=sseed) c, _ = genTestClient(nodeSet, tmpdir=tdir, usePoolLedger=True) w = Wallet(c.name) w.addIdentifier(signer=signer) c.registerObserver(w.handleIncomingReply) looper.add(c) looper.run(c.ensureConnectedToNodes()) createNym(looper, signer.identifier, steward, stewardWallet, role=SPONSOR, verkey=signer.verkey) return c, w
def _createClientAndWallet(self): signer = SimpleSigner(seed=self._seed) port = genHa()[1] ha = HA('0.0.0.0', port) self._client = Client(name=signer.identifier, ha=ha) self._wallet = Wallet(name=signer.identifier) self._wallet.addIdentifier(signer=signer) logger.info("Identifier: {}".format(self.identifier)) logger.info("Signer's verkey: {}".format(self.verkey))
def getNewNodeData(): newStewardSeed = randomSeed() newNodeSeed = randomSeed() nodeIp, nodePort = genHa() clientIp, clientPort = genHa() newNodeData = { NODE_IP: nodeIp, NODE_PORT: nodePort, CLIENT_IP: clientIp, CLIENT_PORT: clientPort, ALIAS: randomString(6) } return { 'newStewardSeed': newStewardSeed, 'newStewardIdr': SimpleSigner(seed=newStewardSeed).identifier, 'newNodeSeed': newNodeSeed, 'newNodeIdr': SimpleSigner(seed=newNodeSeed).identifier, 'newNodeData': newNodeData }
def add_ne_node(looper, sdk_pool_handle, steward_wallet_handle): new_node_name = randomString(7) nodeSigner = SimpleSigner() dest = nodeSigner.identifier (nodeIp, nodePort), (clientIp, clientPort) = genHa(2) _, steward_did = steward_wallet_handle node_request = looper.loop.run_until_complete( prepare_node_request(steward_did, new_node_name=new_node_name, destination=dest, clientIp=clientIp, clientPort=clientPort, nodeIp=nodeIp, nodePort=nodePort, services=[VALIDATOR])) request_couple = sdk_sign_and_send_prepared_request(looper, steward_wallet_handle, sdk_pool_handle, node_request) sdk_get_and_check_replies(looper, [request_couple]) return dest, new_node_name
def testTrusteeSuspendingTrustAnchor(be, do, trusteeCli, trustAnchorAdded, nymAddedOut, trustAnchorCli): be(trusteeCli) do('send NYM dest={remote} role=', within=5, expect=nymAddedOut, mapper=trustAnchorAdded) s = SimpleSigner().identifier be(trustAnchorCli) errorMsg = 'UnauthorizedClientRequest' do('send NYM dest={remote}', within=5, expect=[errorMsg], mapper={'remote': s})
def testReconstitutedClientCreatesTheSameSig(cli, sig, msg): cli2 = SimpleSigner(idr, seed=cli.seed) sig2 = cli2.sign(msg) assert sig == sig2