[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[minion-cvs] Fix pinger logic to use identity digests instead of nic...
Update of /home/minion/cvsroot/src/minion/lib/mixminion
In directory moria:/tmp/cvs-serv17697/lib/mixminion
Modified Files:
BuildMessage.py ClientDirectory.py ServerInfo.py test.py
Log Message:
Fix pinger logic to use identity digests instead of nicknames. Why didnt I think of this in the first place?
Index: BuildMessage.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/BuildMessage.py,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -d -r1.76 -r1.77
--- BuildMessage.py 7 Aug 2004 14:08:23 -0000 1.76
+++ BuildMessage.py 9 Aug 2005 15:51:32 -0000 1.77
@@ -1,4 +1,4 @@
-# Copyright 2002-2004 Nick Mathewson. See LICENSE for licensing information.
+# Copyright 2002-2005 Nick Mathewson. See LICENSE for licensing information.
# $Id$
"""mixminion.BuildMessage
Index: ClientDirectory.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/ClientDirectory.py,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -d -r1.49 -r1.50
--- ClientDirectory.py 4 Jun 2005 13:51:35 -0000 1.49
+++ ClientDirectory.py 9 Aug 2005 15:51:32 -0000 1.50
@@ -889,6 +889,10 @@
self._diskLock.release()
self.__scanAsNeeded()
+ def getServerList(self):
+ """Return a list of all known ServerInfo."""
+ return self.allServers
+
def getAllServers(self):
"""Return a list of all known ServerInfo."""
return self.allServers
Index: ServerInfo.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/ServerInfo.py,v
retrieving revision 1.93
retrieving revision 1.94
diff -u -d -r1.93 -r1.94
--- ServerInfo.py 4 Jun 2005 13:53:25 -0000 1.93
+++ ServerInfo.py 9 Aug 2005 15:51:32 -0000 1.94
@@ -345,17 +345,19 @@
def getIdentityDigest(self):
"""Return the digest of this server's public identity key.
- (SHA-1 digest of ASN.1-encodd key).
+ (SHA-1 digest of ASN.1-encoded key).
"""
return sha1(pk_encode_public_key(self.getIdentity()))
- def getIdentityFingerprint(self):
+ def getIdentityFingerprint(self, space=1):
"""Return the digest of this server's public identity key, encoded in
hexadecimal, with every 4 characters separated by spaces.
"""
d = getIdentityDigest(self)
assert (len(d) % 2) == 0
b = binascii.b2a_hex(d)
+ if not space:
+ return b
r = []
for i in xrange(0, len(b), 4):
r.append(b[i:i+4])
Index: test.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/test.py,v
retrieving revision 1.217
retrieving revision 1.218
diff -u -d -r1.217 -r1.218
--- test.py 4 Jun 2005 13:55:04 -0000 1.217
+++ test.py 9 Aug 2005 15:51:32 -0000 1.218
@@ -6545,7 +6545,8 @@
class ServerMainTests(TestCase):
def testScheduler(self):
- _Scheduler = mixminion.server.ServerMain._Scheduler
+ #XXXX008 move this test. it isn'tr a server test any more.
+ _Scheduler = mixminion.ScheduleUtils.Scheduler
lst=[]
def a(lst=lst): lst.append('a')
def b(lst=lst): lst.append('b')
@@ -7918,6 +7919,12 @@
print "[Skipping ping tests; old python or missing pysqlite]",
return
+ id0 = "Premature optimizati" #bar
+ id1 = "on is the root of al" #barbaz
+ id2 = "l evil in programmin" #bart
+ id3 = "g. -- Prof Don Knuth"
+ assert len(id0)==len(id1)==len(id2)==len(id3)==20
+
d = mix_mktemp()
os.mkdir(d,0700)
loc = os.path.join(d, "db")
@@ -7926,20 +7933,20 @@
log.startup(now=t)
log.heartbeat(now=t+1)
log.heartbeat(now=t+20)
- log.connected("Foobar",now=t+20)
- log.connectFailed("Foobarbaz",now=t+20.2)
- log.connected("Foobar",now=t+30)
- log.connected("Foobarbaz",now=t+30.2)
- log.connected("Foobart",now=t+31)
- log.queuedPing("\x00Z"*10, "Foobar", now=t+31)
- log.queuedPing("BN"*10, "Foobarbaz", now=t+31)
- log.queuedPing("!!"*10, "Foobar,Foobarbaz", now=t+31)
- log.queuedPing("''"*10, "Foobart", now=t+32)
- log.queuedPing("<>"*10, "Foobar", now=t+32)
- log.connected("Foobar",now=t+60)
- log.connected("Foobarbaz",now=t+60.2)
- log.connectFailed("Foobarbaz",now=t+70)
- log.connected("Foobar",now=t+90)
+ log.connected(id0,now=t+20)
+ log.connectFailed(id1,now=t+20.2)
+ log.connected(id0,now=t+30)
+ log.connected(id1,now=t+30.2)
+ log.connected(id2,now=t+31)
+ log.queuedPing("\x00Z"*10, [id0], now=t+31)
+ log.queuedPing("BN"*10, [id1], now=t+31)
+ log.queuedPing("!!"*10, [id0,id1], now=t+31)
+ log.queuedPing("''"*10, [id2], now=t+32)
+ log.queuedPing("<>"*10, [id0], now=t+32)
+ log.connected(id0,now=t+60)
+ log.connected(id1,now=t+60.2)
+ log.connectFailed(id1,now=t+70)
+ log.connected(id0,now=t+90)
log.gotPing("\x00Z"*10, now=t+130)
log.gotPing("BN"*10, now=t+150)
suspendLog()
@@ -7958,14 +7965,14 @@
# I've been up 200 seconds this day, of which not all has passed.
self.assertFloatEq(ups[interval]['<self>'],
200./(24*60*60))
- # Of the time I've been up, server "foobar" has never been down.
- self.assertFloatEq(ups[interval]['foobar'], 1.0)
- # Foobarbaz was down at 20, up at 30, up at 60, down at 70. So we'll
+ # Of the time I've been up, server with id0 has never been down.
+ self.assertFloatEq(ups[interval][id0], 1.0)
+ # id1 was down at 20, up at 30, up at 60, down at 70. So we'll
# assume it was down from 20...25, up from 25..65, down from 65..70.
# That makes 10 sec down, 40 sec up.
- self.assertFloatEq(ups[interval]['foobarbaz'], 40/50.)
- # Foobart was only down once in the interval; we refuse to extrapolate.
- self.assert_(not ups[interval].has_key('foobart'))
+ self.assertFloatEq(ups[interval][id1], 40/50.)
+ # id2 was only down once in the interval; we refuse to extrapolate.
+ self.assert_(not ups[interval].has_key(id2))
log.calculateChainStatus(now=t+200)
log.calculateAll(now=t+200)
@@ -7979,7 +7986,6 @@
log.calculateOneHopResult(t)
log.calculateChainStatus(t)
-
statusFile = os.path.join(d, "status")
log.calculateAll(statusFile,now=t+200)
env = {}
@@ -8023,7 +8029,7 @@
tc = loader.loadTestsFromTestCase
if 0:
- suite.addTest(tc(DirectoryServerTests))
+ suite.addTest(tc(PingerTests))
return suite
testClasses = [MiscTests,
MinionlibCryptoTests,