def createSpecificServer(self, certData, negotiationClass=negotiate.Negotiation): tub = Tub(certData=certData) tub.negotiationClass = negotiationClass tub.startService() self.services.append(tub) l = tub.listenOn("tcp:0") tub.setLocation("127.0.0.1:%d" % l.getPortnum()) target = Target() return tub, target, tub.registerReference(target), l.getPortnum()
def createSpecificServer(self, certData, negotiationClass=negotiate.Negotiation): tub = Tub(certData=certData) tub.negotiationClass = negotiationClass tub.startService() self.services.append(tub) portnum = allocate_tcp_port() tub.listenOn("tcp:%d:interface=127.0.0.1" % portnum) tub.setLocation("127.0.0.1:%d" % portnum) target = Target() return tub, target, tub.registerReference(target), portnum
def testTooFarInFuture2(self): # same as before, but the connecting Tub will have the higher tubID, # and thus make the negotiation decision url, portnum = self.makeSpecificServer(certData_low) client = Tub(certData=certData_high) client.negotiationClass = NegotiationVbigOnly client.startService() self.services.append(client) d = client.getReference(url) def _oops_succeeded(rref): self.fail("hey! this is supposed to fail") def _check_failure(f): f.trap(tokens.NegotiationError, tokens.RemoteNegotiationError) d.addCallbacks(_oops_succeeded, _check_failure) return d
def testFuture2(self): # same as before, but the connecting Tub will have the higher tubID, # and thus make the negotiation decision url, portnum = self.makeSpecificServer(certData_low) # the client client = Tub(certData=certData_high) client.negotiationClass = NegotiationVbig client.startService() self.services.append(client) d = client.getReference(url) def _check_version(rref): ver = rref.tracker.broker._banana_decision_version self.failUnlessEqual(ver, MAX_HANDLED_VERSION) d.addCallback(_check_version) return d
def testFuture1(self): # when a peer that understands version=[1] that connects to a peer # that understands version=[1,2], they should pick version=1 # the listening Tub will have the higher tubID, and thus make the # negotiation decision url, portnum = self.makeSpecificServer(certData_high) # the client client = Tub(certData=certData_low) client.negotiationClass = NegotiationVbig client.startService() self.services.append(client) d = client.getReference(url) def _check_version(rref): ver = rref.tracker.broker._banana_decision_version self.failUnlessEqual(ver, MAX_HANDLED_VERSION) d.addCallback(_check_version) return d
def testTooFarInFuture1(self): # when a peer that understands version=[1] that connects to a peer # that only understands version=[2], they should fail to negotiate # the listening Tub will have the higher tubID, and thus make the # negotiation decision url, portnum = self.makeSpecificServer(certData_high) # the client client = Tub(certData=certData_low) client.negotiationClass = NegotiationVbigOnly client.startService() self.services.append(client) d = client.getReference(url) def _oops_succeeded(rref): self.fail("hey! this is supposed to fail") def _check_failure(f): f.trap(tokens.NegotiationError, tokens.RemoteNegotiationError) d.addCallbacks(_oops_succeeded, _check_failure) return d