def test_wirelog_doer(): """ Test WireLogDoer class """ tock = 0.03125 ticks = 4 limit = ticks * tock doist = doing.Doist(tock=tock, real=True, limit=limit) assert doist.tyme == 0.0 # on next cycle assert doist.tock == tock == 0.03125 assert doist.real == True assert doist.limit == limit == 0.125 assert doist.doers == [] wl = wiring.WireLog(samed=True, temp=True) wiredoer = wiring.WireLogDoer(tymth=doist.tymen(), wl=wl) assert wiredoer.wl == wl assert wiredoer.tock == 0.0 # ASAP doers = [wiredoer] doist.do(doers=doers) assert doist.tyme == limit assert wiredoer.wl.opened == False """End Test """
def setupController(name="who", sith=None, count=1, temp=False, remotePort=5621, localPort=5620): """ Setup and return doers list to run controller """ # setup habitat hab = habbing.Habitat(name=name, isith=sith, icount=count, temp=temp) logger.info("\nDirect Mode controller %s:\nNamed %s on TCP port %s to port %s.\n\n", hab.pre, hab.name, localPort, remotePort) # setup doers ksDoer = keeping.KeeperDoer(keeper=hab.ks) # doer do reopens if not opened and closes dbDoer = basing.BaserDoer(baser=hab.db) # doer do reopens if not opened and closes # setup wirelog to create test vectors path = os.path.dirname(__file__) path = os.path.join(path, 'logs') wl = wiring.WireLog(samed=True, filed=True, name=name, prefix='keri', reopen=True, headDirPath=path) wireDoer = wiring.WireLogDoer(wl=wl) client = clienting.Client(host='127.0.0.1', port=remotePort, wl=wl) clientDoer = doing.ClientDoer(client=client) director = Director(hab=hab, client=client, tock=0.125) reactor = Reactor(hab=hab, client=client) server = serving.Server(host="", port=localPort, wl=wl) serverDoer = doing.ServerDoer(server=server) directant = Directant(hab=hab, server=server) # Reactants created on demand by directant return [ksDoer, dbDoer, wireDoer, clientDoer, director, reactor, serverDoer, directant]
def setupDemoController(secrets, name="who", remotePort=5621, localPort=5620, indirect=False, remotePre=""): """ Setup and return doers list to run controller """ secrecies = [] for secret in secrets: # convert secrets to secrecies secrecies.append([secret]) # setup habitat hab = habbing.Habitat(name=name, secrecies=secrecies, temp=True) logger.info( "\nDirect Mode demo of %s:\nNamed %s on TCP port %s to port %s.\n\n", hab.pre, hab.name, localPort, remotePort) # setup doers ksDoer = keeping.KeeperDoer( keeper=hab.ks) # doer do reopens if not opened and closes dbDoer = basing.BaserDoer( baser=hab.db) # doer do reopens if not opened and closes # setup wirelog to create test vectors path = os.path.dirname(__file__) path = os.path.join(path, 'logs') wl = wiring.WireLog(samed=True, filed=True, name=name, prefix='demo', reopen=True, headDirPath=path) wireDoer = wiring.WireLogDoer(wl=wl) client = clienting.Client(host='127.0.0.1', port=remotePort, wl=wl) clientDoer = doing.ClientDoer(client=client) if name == 'bob': director = BobDirector(hab=hab, client=client, tock=0.125) elif name == "sam": director = SamDirector(hab=hab, client=client, tock=0.125) elif name == 'eve': director = EveDirector(hab=hab, client=client, tock=0.125) else: raise ValueError("Invalid director name={}.".format(name)) reactor = directing.Reactor(hab=hab, client=client, indirect=indirect) server = serving.Server(host="", port=localPort, wl=wl) serverDoer = doing.ServerDoer(server=server) directant = directing.Directant(hab=hab, server=server) # Reactants created on demand by directant return [ ksDoer, dbDoer, wireDoer, clientDoer, director, reactor, serverDoer, directant ]
def setupController(secrets, did, lei, witnessPort=5621, peerPort=5629, indirect=False): """ Setup and return doers list to run controller """ name = "ian" secrecies = [] for secret in secrets: # convert secrets to secrecies secrecies.append([secret]) # setup databases for dependency injection ks = keeping.Keeper(name=name, temp=True) # not opened by default, doer opens ksDoer = keeping.KeeperDoer(keeper=ks) # doer do reopens if not opened and closes db = basing.Baser(name=name, temp=True) # not opened by default, doer opens dbDoer = basing.BaserDoer(baser=db) # doer do reopens if not opened and closes # setup habitat hab = habbing.Habitat(name=name, ks=ks, db=db, temp=True, secrecies=secrecies) habDoer = habbing.HabitatDoer(habitat=hab) # setup doer iss = issuing.Issuer(hab=hab, name=name, noBackers=True) issDoer = issuing.IssuerDoer(issuer=iss) # setup doers regDoer = basing.BaserDoer(baser=iss.reger) path = os.path.dirname(__file__) path = os.path.join(path, 'logs') wl = wiring.WireLog(samed=True, filed=True, name=name, prefix='demo', reopen=True, headDirPath=path) wireDoer = wiring.WireLogDoer(wl=wl) witnessClient = clienting.Client(host='127.0.0.1', port=witnessPort, wl=wl) witnessClientDoer = clienting.ClientDoer(client=witnessClient) peerClient = clienting.Client(host='127.0.0.1', port=peerPort, wl=wl) peerClientDoer = clienting.ClientDoer(client=peerClient) director = IanDirector(hab=hab, issuer=iss, witnessClient=witnessClient, peerClient=peerClient, tock=0.125, recipientIdentifier=did, lei=lei) reactor = directing.Reactor(hab=hab, client=witnessClient, indirect=indirect) peerReactor = directing.Reactor(hab=hab, client=peerClient, indirect=indirect) logger.info("\nDirect Mode demo of %s:\nNamed %s to TCP port %s.\n\n", hab.pre, hab.name, witnessPort) return [ksDoer, dbDoer, habDoer, issDoer, regDoer, wireDoer, witnessClientDoer, director, reactor, peerClientDoer, peerReactor]
def setupController(secrets, vcfile, did, lei, remotePort=5621, indirect=False): """ Setup and return doers list to run controller """ secrecies = [] for secret in secrets: # convert secrets to secrecies secrecies.append([secret]) # setup habitat hab = habbing.Habitat(name="ian", secrecies=secrecies, temp=True) logger.info("\nDirect Mode demo of %s:\nNamed %s to TCP port %s.\n\n", hab.pre, hab.name, remotePort) iss = issuing.Issuer(hab=hab, name="ian", noBackers=True) # setup doers ksDoer = keeping.KeeperDoer( keeper=hab.ks) # doer do reopens if not opened and closes dbDoer = basing.BaserDoer( baser=hab.db) # doer do reopens if not opened and closes regDoer = basing.BaserDoer(baser=iss.reger) path = os.path.dirname(__file__) path = os.path.join(path, 'logs') wl = wiring.WireLog(samed=True, filed=True, name="ian", prefix='demo', reopen=True, headDirPath=path) wireDoer = wiring.WireLogDoer(wl=wl) client = clienting.Client(host='127.0.0.1', port=remotePort, wl=wl) clientDoer = doing.ClientDoer(client=client) director = IanDirector(hab=hab, issuer=iss, client=client, tock=0.125, vcfile=vcfile, recipientIdentifier=did, lei=lei) reactor = directing.Reactor(hab=hab, client=client, indirect=indirect) return [ksDoer, dbDoer, regDoer, wireDoer, clientDoer, director, reactor]
def setupController(secrets, witnessPort=5631, localPort=5629, indirect=False): """ Setup and return doers list to run controller """ secrecies = [] for secret in secrets: # convert secrets to secrecies secrecies.append([secret]) # setup habitat hab = habbing.Habitat(name="han", secrecies=secrecies, temp=True) logger.info( "\nDirect Mode demo of %s:\nNamed %s listening on TCP port %s, witness on TCP Port %s.\n\n", hab.pre, hab.name, localPort, witnessPort) wallet = walleting.Wallet(hab=hab, name="han") # setup doers ksDoer = keeping.KeeperDoer( keeper=hab.ks) # doer do reopens if not opened and closes dbDoer = basing.BaserDoer( baser=hab.db) # doer do reopens if not opened and closes pdbDoer = basing.BaserDoer( baser=wallet.db) # doer do reopens if not opened and closes path = os.path.dirname(__file__) path = os.path.join(path, 'logs') wl = wiring.WireLog(samed=True, filed=True, name="han", prefix='demo', reopen=True, headDirPath=path) wireDoer = wiring.WireLogDoer(wl=wl) jsonSchema = scheming.JSONSchema(resolver=scheming.jsonSchemaCache) issueHandler = handling.IssueHandler(wallet=wallet, typ=jsonSchema) requestHandler = handling.RequestHandler(wallet=wallet, typ=jsonSchema) witnessClient = clienting.Client(host='127.0.0.1', port=witnessPort, wl=wl) witnessClientDoer = clienting.ClientDoer(client=witnessClient) excDoer = exchanging.Exchanger(hab=hab, handlers=[issueHandler, requestHandler]) director = HanDirector(hab=hab, client=witnessClient, exchanger=excDoer, tock=0.125, wallet=wallet) reactor = directing.Reactor(hab=hab, client=witnessClient, indirect=indirect) server = serving.Server(host="", port=localPort) serverDoer = serving.ServerDoer(server=server) directant = directing.Directant(hab=hab, server=server, exchanger=excDoer) return [ ksDoer, dbDoer, pdbDoer, excDoer, wireDoer, witnessClientDoer, director, reactor, serverDoer, directant ]
def setupController(secrets, witnessPort=5621, peerPort=5629, indirect=False): """ Setup and return doers list to run controller """ name = "vic" secrecies = [] for secret in secrets: # convert secrets to secrecies secrecies.append([secret]) # setup databases for dependency injection ks = keeping.Keeper(name=name, temp=True) # not opened by default, doer opens ksDoer = keeping.KeeperDoer( keeper=ks) # doer do reopens if not opened and closes db = basing.Baser(name=name, temp=True) # not opened by default, doer opens dbDoer = basing.BaserDoer( baser=db) # doer do reopens if not opened and closes # setup habitat hab = habbing.Habitat(name=name, ks=ks, db=db, temp=True, secrecies=secrecies) habDoer = habbing.HabitatDoer(habitat=hab) # setup doer verifier = verifying.Verifier(name=name, hab=hab) regDoer = basing.BaserDoer(baser=verifier.reger) # setup wirelog to create test vectors path = os.path.dirname(__file__) path = os.path.join(path, 'logs') wl = wiring.WireLog(samed=True, filed=True, name=name, prefix='demo', reopen=True, headDirPath=path) wireDoer = wiring.WireLogDoer(wl=wl) witnessClient = clienting.Client(host='127.0.0.1', port=witnessPort, wl=wl) witnessClientDoer = clienting.ClientDoer(client=witnessClient) peerClient = clienting.Client(host='127.0.0.1', port=peerPort, wl=wl) peerClientDoer = clienting.ClientDoer(client=peerClient) jsonSchema = scheming.JSONSchema(resolver=scheming.jsonSchemaCache) proofs = decking.Deck() proofHandler = handling.ProofHandler(typ=jsonSchema, proofs=proofs) excDoer = exchanging.Exchanger(hab=hab, handlers=[proofHandler]) director = VicDirector(hab=hab, verifier=verifier, witnessClient=witnessClient, peerClient=peerClient, exchanger=excDoer, jsonSchema=jsonSchema, proofs=proofs, tock=0.125) witnessReactor = directing.Reactor(hab=hab, client=witnessClient, verifier=verifier, indirect=indirect) peerReactor = directing.Reactor(hab=hab, client=peerClient, verifier=verifier, indirect=indirect, exchanger=excDoer) logger.info("\nDirect Mode demo of %s:\nNamed %s to TCP port %s.\n\n", hab.pre, hab.name, witnessPort) return [ ksDoer, dbDoer, habDoer, regDoer, excDoer, wireDoer, witnessClientDoer, director, witnessReactor, peerClientDoer, peerReactor ]