2006-11-30 23:23:01 +00:00
|
|
|
|
2007-07-12 22:33:30 +00:00
|
|
|
import os
|
2006-11-30 23:23:01 +00:00
|
|
|
from twisted.trial import unittest
|
2007-05-24 00:37:20 +00:00
|
|
|
from foolscap.eventual import fireEventually, flushEventualQueue
|
2006-11-30 23:23:01 +00:00
|
|
|
|
2007-04-30 16:57:52 +00:00
|
|
|
from allmydata import introducer_and_vdrive
|
2007-04-24 04:15:02 +00:00
|
|
|
from allmydata.util import testutil
|
2006-11-30 23:23:01 +00:00
|
|
|
|
2007-04-24 04:15:02 +00:00
|
|
|
class Basic(testutil.SignalMixin, unittest.TestCase):
|
2006-12-01 03:20:00 +00:00
|
|
|
def test_loadable(self):
|
2007-07-12 22:33:30 +00:00
|
|
|
basedir = "introducer_and_vdrive.Basic.test_loadable"
|
|
|
|
os.mkdir(basedir)
|
|
|
|
q = introducer_and_vdrive.IntroducerAndVdrive(basedir)
|
2007-05-24 00:37:20 +00:00
|
|
|
d = fireEventually(None)
|
|
|
|
d.addCallback(lambda res: q.startService())
|
2007-07-12 22:33:30 +00:00
|
|
|
d.addCallback(lambda res: q.when_tub_ready())
|
|
|
|
def _check_parameters(res):
|
|
|
|
i = q.getServiceNamed("introducer")
|
|
|
|
self.failUnlessEqual(i._encoding_parameters, (3, 7, 10))
|
|
|
|
d.addCallback(_check_parameters)
|
|
|
|
d.addCallback(lambda res: q.stopService())
|
|
|
|
d.addCallback(flushEventualQueue)
|
|
|
|
return d
|
|
|
|
|
|
|
|
def test_set_parameters(self):
|
|
|
|
basedir = "introducer_and_vdrive.Basic.test_set_parameters"
|
|
|
|
os.mkdir(basedir)
|
|
|
|
f = open(os.path.join(basedir, "encoding_parameters"), "w")
|
|
|
|
f.write("25 75 100")
|
|
|
|
f.close()
|
|
|
|
q = introducer_and_vdrive.IntroducerAndVdrive(basedir)
|
|
|
|
d = fireEventually(None)
|
|
|
|
d.addCallback(lambda res: q.startService())
|
|
|
|
d.addCallback(lambda res: q.when_tub_ready())
|
|
|
|
def _check_parameters(res):
|
|
|
|
i = q.getServiceNamed("introducer")
|
|
|
|
self.failUnlessEqual(i._encoding_parameters, (25, 75, 100))
|
|
|
|
d.addCallback(_check_parameters)
|
2007-03-08 22:10:36 +00:00
|
|
|
d.addCallback(lambda res: q.stopService())
|
2007-04-04 23:09:13 +00:00
|
|
|
d.addCallback(flushEventualQueue)
|
2007-03-08 22:10:36 +00:00
|
|
|
return d
|
|
|
|
|