tahoe-lafs/src/allmydata/test/test_introducer_and_vdrive.py

43 lines
1.6 KiB
Python
Raw Normal View History

2006-11-30 23:23:01 +00:00
import os
2006-11-30 23:23:01 +00:00
from twisted.trial import unittest
from foolscap.eventual import fireEventually, flushEventualQueue
2006-11-30 23:23:01 +00:00
from allmydata import introducer_and_vdrive
from allmydata.util import testutil
2006-11-30 23:23:01 +00:00
class Basic(testutil.SignalMixin, unittest.TestCase):
2006-12-01 03:20:00 +00:00
def test_loadable(self):
basedir = "introducer_and_vdrive.Basic.test_loadable"
os.mkdir(basedir)
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, (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)
d.addCallback(lambda res: q.stopService())
d.addCallback(flushEventualQueue)
return d