本文整理汇总了Python中twisted.test.proto_helpers.FakeDatagramTransport方法的典型用法代码示例。如果您正苦于以下问题:Python proto_helpers.FakeDatagramTransport方法的具体用法?Python proto_helpers.FakeDatagramTransport怎么用?Python proto_helpers.FakeDatagramTransport使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.test.proto_helpers
的用法示例。
在下文中一共展示了proto_helpers.FakeDatagramTransport方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: loopix_mixes
# 需要导入模块: from twisted.test import proto_helpers [as 别名]
# 或者: from twisted.test.proto_helpers import FakeDatagramTransport [as 别名]
def loopix_mixes():
sec_params = SphinxParams(header_len=1024)
dbManager.create_mixnodes_table('Mixnodes')
mixes = []
pubs_mixes = []
for i in range(3):
mix = LoopixMixNode(sec_params, 'Mix%d'%(i+1), 9999-i, '1.2.3.%d'%i, i)
mix.transport = proto_helpers.FakeDatagramTransport()
mix.config_params = mix.config_params._replace(DATABASE_NAME = 'test.db')
mixes.append(mix)
dbManager.insert_row_into_table('Mixnodes',
[None, mix.name, mix.port, mix.host,
sqlite3.Binary(petlib.pack.encode(mix.pubk)), mix.group])
pubs_mixes = [Mix(m.name, m.port, m.host, m.pubk, m.group) for m in mixes]
return mixes, pubs_mixes
示例2: loopix_providers
# 需要导入模块: from twisted.test import proto_helpers [as 别名]
# 或者: from twisted.test.proto_helpers import FakeDatagramTransport [as 别名]
def loopix_providers():
sec_params = SphinxParams(header_len=1024)
dbManager.create_providers_table('Providers')
providers = []
pubs_providers = []
for i in range(3):
p = LoopixProvider(sec_params, 'Provider%d'%(i+1), 9995-i, '1.2.%d.4'%i)
p.transport = proto_helpers.FakeDatagramTransport()
p.config_params = p.config_params._replace(DATABASE_NAME = 'test.db')
providers.append(p)
dbManager.insert_row_into_table('Providers',
[None, p.name, p.port, p.host,
sqlite3.Binary(petlib.pack.encode(p.pubk))])
pubs_providers = [Provider(p.name, p.port, p.host, p.pubk) for p in providers]
return providers, pubs_providers
示例3: loopix_clients
# 需要导入模块: from twisted.test import proto_helpers [as 别名]
# 或者: from twisted.test.proto_helpers import FakeDatagramTransport [as 别名]
def loopix_clients(pubs_providers, pubs_mixes):
sec_params = SphinxParams(header_len=1024)
dbManager.create_users_table('Users')
clients = []
pubs_clients = []
for i in range(3):
provider = pubs_providers[i]
c = LoopixClient(sec_params, 'Client%d'%(i+1), 9993 - i, '1.%d.3.4'%i, provider.name)
c.register_mixes(pubs_mixes)
c.transport = proto_helpers.FakeDatagramTransport()
c.config_params = c.config_params._replace(DATABASE_NAME = 'test.db')
c.provider = dbManager.select_provider_by_name(provider.name)
clients.append(c)
dbManager.insert_row_into_table('Users',
[None, c.name, c.port, c.host,
sqlite3.Binary(petlib.pack.encode(c.pubk)),
c.provider.name])
pubs_clients = [User(c.name, c.port, c.host, c.pubk, c.provider) for c in clients]
return clients, pubs_clients
示例4: setUp
# 需要导入模块: from twisted.test import proto_helpers [as 别名]
# 或者: from twisted.test.proto_helpers import FakeDatagramTransport [as 别名]
def setUp(self):
self.proxy = sip.RegisterProxy(host="intarweb.us")
self.proxy.authorizers = self.proxy.authorizers.copy()
self.proxy.authorizers['digest'] = FakeDigestAuthorizer()
self.registry = FakeRegistry("intarweb.us")
self.proxy.registry = self.proxy.locator = self.registry
self.transport = proto_helpers.FakeDatagramTransport()
self.proxy.transport = self.transport
r = TestRealm()
p = cred.portal.Portal(r)
c = cred.checkers.InMemoryUsernamePasswordDatabaseDontUse()
c.addUser('exarkun@intarweb.us', 'password')
p.registerChecker(c)
self.proxy.portal = p
示例5: setUp
# 需要导入模块: from twisted.test import proto_helpers [as 别名]
# 或者: from twisted.test.proto_helpers import FakeDatagramTransport [as 别名]
def setUp(self):
"""
Create a L{dns.DNSDatagramProtocol} with a deterministic clock.
"""
self.clock = task.Clock()
self.controller = TestController()
self.proto = dns.DNSDatagramProtocol(self.controller)
transport = proto_helpers.FakeDatagramTransport()
self.proto.makeConnection(transport)
self.proto.callLater = self.clock.callLater
示例6: setUp
# 需要导入模块: from twisted.test import proto_helpers [as 别名]
# 或者: from twisted.test.proto_helpers import FakeDatagramTransport [as 别名]
def setUp(self):
self.proxy = sip.RegisterProxy(host="intarweb.us")
self.proxy.authorizers = self.proxy.authorizers.copy()
self.proxy.authorizers['digest'] = FakeDigestAuthorizer()
self.registry = FakeRegistry("intarweb.us")
self.proxy.registry = self.proxy.locator = self.registry
self.transport = proto_helpers.FakeDatagramTransport()
self.proxy.transport = self.transport
r = TestRealm()
p = cred.portal.Portal(r)
c = cred.checkers.InMemoryUsernamePasswordDatabaseDontUse()
c.addUser('exarkun@intarweb.us', 'password')
p.registerChecker(c)
self.proxy.portal = p