def setUp(self): self.store = Store(stamp=0.0) self.timer = StoreTimer(store=self.store, duration=1.0) self.baseDirpath = tempfile.mkdtemp(prefix="raet", suffix="base", dir=TEMPDIR) self.stack = None # This has to be set to True in the only one process that would perform tearDown steps self.engine = True stacking.RoadStack.BurstSize = 100
def setUp(self): self.store = Store(stamp=0.0) self.timer = StoreTimer(store=self.store, duration=1.0) self.baseDirpath=tempfile.mkdtemp(prefix="raet", suffix="base", dir=TEMPDIR) stacking.RoadStack.Bk = raeting.BodyKind.json.value #main stack mainName = "main" mainDirpath = os.path.join(self.baseDirpath, 'road', 'keep', mainName) signer = nacling.Signer() mainSignKeyHex = signer.keyhex privateer = nacling.Privateer() mainPriKeyHex = privateer.keyhex #other stack otherName = "other" otherDirpath = os.path.join(self.baseDirpath, 'road', 'keep', otherName) signer = nacling.Signer() otherSignKeyHex = signer.keyhex privateer = nacling.Privateer() otherPriKeyHex = privateer.keyhex keeping.clearAllKeep(mainDirpath) keeping.clearAllKeep(otherDirpath) self.main = stacking.RoadStack(store=self.store, name=mainName, main=True, auto=raeting.AutoMode.once.value, sigkey=mainSignKeyHex, prikey=mainPriKeyHex, dirpath=mainDirpath, ) self.other = stacking.RoadStack(store=self.store, name=otherName, auto=raeting.AutoMode.once.value, ha=("", raeting.RAET_TEST_PORT), sigkey=otherSignKeyHex, prikey=otherPriKeyHex, dirpath=otherDirpath, )
def setUp(self): self.store = Store(stamp=0.0) self.timer = StoreTimer(store=self.store, duration=1.0) if sys.platform == 'win32': self.tempDirpath = tempfile.mktemp(prefix="raet", suffix="base", dir=TEMPDIR) else: self.tempDirpath = tempfile.mkdtemp(prefix="raet", suffix="base", dir=TEMPDIR) self.baseDirpath = os.path.join(self.tempDirpath, 'lane', 'keep') # main stack self.main = stacking.LaneStack(name='main', uid=1, lanename='cherry', sockdirpath=self.baseDirpath) #other stack self.other = stacking.LaneStack(name='other', uid=1, lanename='cherry', sockdirpath=self.baseDirpath)
def setUp(self): self.store = Store(stamp=0.0) self.timer = StoreTimer(store=self.store, duration=1.0)
def setUp(self): self.store = Store(stamp=0.0) self.timer = StoreTimer(store=self.store, duration=1.0) self.dirpathBase = tempfile.mkdtemp(prefix="raet", suffix="base", dir=TEMPDIR) stacking.RoadStack.Bk = raeting.BodyKind.json.value #main stack mainName = "main" mainDirpath = os.path.join(self.dirpathBase, 'road', 'keep', mainName) signer = nacling.Signer() mainSignKeyHex = signer.keyhex mainVerKeyHex = signer.verhex privateer = nacling.Privateer() mainPriKeyHex = privateer.keyhex mainPubKeyHex = privateer.pubhex #other stack otherName = "other" otherDirpath = os.path.join(self.dirpathBase, 'road', 'keep', otherName) signer = nacling.Signer() otherSignKeyHex = signer.keyhex otherVerKeyHex = signer.verhex privateer = nacling.Privateer() otherPriKeyHex = privateer.keyhex otherPubKeyHex = privateer.pubhex keeping.clearAllKeep(mainDirpath) keeping.clearAllKeep(otherDirpath) self.main = stacking.RoadStack(name=mainName, uid=1, sigkey=mainSignKeyHex, prikey=mainPriKeyHex, auto=raeting.AutoMode.once.value, main=True, dirpath=mainDirpath, store=self.store) remote1 = estating.RemoteEstate( stack=self.main, uid=2, name=otherName, ha=("127.0.0.1", raeting.RAET_TEST_PORT), verkey=otherVerKeyHex, pubkey=otherPubKeyHex, ) self.main.addRemote(remote1) self.other = stacking.RoadStack(name=otherName, uid=2, auto=raeting.AutoMode.once.value, ha=("", raeting.RAET_TEST_PORT), sigkey=otherSignKeyHex, prikey=otherPriKeyHex, dirpath=otherDirpath, store=self.store) remote0 = estating.RemoteEstate( stack=self.other, uid=3, name=mainName, ha=('127.0.0.1', raeting.RAET_PORT), verkey=mainVerKeyHex, pubkey=mainPubKeyHex, ) self.other.addRemote(remote0) remote0.publee = nacling.Publican(key=remote1.privee.pubhex) remote1.publee = nacling.Publican(key=remote0.privee.pubhex) stuff = [] for i in range(300): stuff.append(str(i).rjust(4, " ")) self.stuff = ns2b("".join(stuff)) self.data = odict(hk=raeting.HeadKind.raet.value)
def __init__( self, store=None, version=raeting.VERSION, main=None, puid=None, local=None, #passed up from subclass name='', uid=None, server=None, ha=None, bufcnt=2, rxMsgs=None, txMsgs=None, rxes=None, txes=None, stats=None, ): ''' Setup Stack instance ''' self.store = store or Store(stamp=0.0) self.version = version self.main = main if getattr(self, 'puid', None) is None: self.puid = puid if puid is not None else self.Uid self.local = local or lotting.Lot( stack=self, name=name, uid=uid, ha=ha, ) self.local.stack = self self.remotes = self.uidRemotes = odict() # remotes indexed by uid self.nameRemotes = odict() # remotes indexed by name self.bufcnt = bufcnt if not server: server = self.serverFromLocal() self.server = server if self.server: if not self.server.reopen(): # open socket raise raeting.StackError( "Stack '{0}': Failed opening server at" " '{1}'\n".format(self.name, self.server.ha)) self.ha = self.server.ha # update local host address after open console.verbose("Stack '{0}': Opened server at '{1}'\n".format( self.name, self.ha)) self.rxMsgs = rxMsgs if rxMsgs is not None else deque( ) # messages received self.txMsgs = txMsgs if txMsgs is not None else deque( ) # messages to transmit self.rxes = rxes if rxes is not None else deque( ) # udp packets received self.txes = txes if txes is not None else deque( ) # udp packet to transmit self.stats = stats if stats is not None else odict() # udp statistics self.statTimer = StoreTimer(self.store)