def sdk_send_alternating_ledgers_requests(looper, pool_h, sdk_wallet_trustee,
                                          sdk_wallet_new_steward, count: int):
    node_alias = random_string(7)
    node_did = SimpleSigner(seed=random_string(32).encode()).identifier

    ReqFactory = namedtuple('ReqFactory', 'wallet create')
    req_factories = [
        ReqFactory(wallet=sdk_wallet_new_steward,
                   create=lambda: sdk_gen_pool_request(
                       looper, sdk_wallet_new_steward, node_alias, node_did)),
        ReqFactory(
            wallet=sdk_wallet_trustee,
            create=lambda: sdk_gen_domain_request(looper, sdk_wallet_trustee)),
        ReqFactory(
            wallet=sdk_wallet_trustee,
            create=lambda: sdk_gen_config_request(looper, sdk_wallet_trustee))
    ]

    res = []
    for i in range(count):
        factory = req_factories[i % len(req_factories)]

        req = factory.create()
        res.append(
            sdk_sign_and_submit_req_obj(looper, pool_h, factory.wallet, req))
        looper.runFor(
            0.1
        )  # Give nodes some time to start ordering, so that requests are really alternating
    return res
Exemplo n.º 2
0
    def sdk_build_nym(self, identifier=None, sdk_wallet=None):
        sdk_wallet = sdk_wallet or self._wallet_steward
        identifier = identifier or sdk_wallet[1]
        ident, verk = self._looper.loop.run_until_complete(
            did.create_and_store_my_did(self._wallet_steward[0],
                                        json.dumps({'seed': plenum_helper.random_string(32)})))

        request = self._looper.loop.run_until_complete(build_nym_request(identifier, ident, verk, None, None))
        return request
def sdk_gen_domain_request(looper, sdk_wallet):
    _, did = sdk_wallet
    target_did = SimpleSigner(seed=random_string(32).encode()).identifier
    req = looper.loop.run_until_complete(build_nym_request(did, target_did, None, None, None))
    return Request(**json.loads(req))