當前位置: 首頁>>代碼示例>>Python>>正文


Python proto_helpers.FakeDatagramTransport方法代碼示例

本文整理匯總了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 
開發者ID:UCL-InfoSec,項目名稱:loopix,代碼行數:18,代碼來源:test_all.py

示例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 
開發者ID:UCL-InfoSec,項目名稱:loopix,代碼行數:18,代碼來源:test_all.py

示例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 
開發者ID:UCL-InfoSec,項目名稱:loopix,代碼行數:23,代碼來源:test_all.py

示例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 
開發者ID:kuri65536,項目名稱:python-for-android,代碼行數:18,代碼來源:test_sip.py

示例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 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:12,代碼來源:test_dns.py

示例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 
開發者ID:kenorb-contrib,項目名稱:BitTorrent,代碼行數:17,代碼來源:test_sip.py


注:本文中的twisted.test.proto_helpers.FakeDatagramTransport方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。