From a05b71307698cdb0582ad13636815a68be53f544 Mon Sep 17 00:00:00 2001
From: Brian Warner <warner@allmydata.com>
Date: Mon, 16 Apr 2007 19:55:03 -0700
Subject: [PATCH] test_encode: test filesizes which are an exact multiple of
 the segment size. This test fails right now.

---
 src/allmydata/test/test_encode.py | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/allmydata/test/test_encode.py b/src/allmydata/test/test_encode.py
index 59419cf5..337e1b8e 100644
--- a/src/allmydata/test/test_encode.py
+++ b/src/allmydata/test/test_encode.py
@@ -142,20 +142,22 @@ class Encode(unittest.TestCase):
         return d
 
 class Roundtrip(unittest.TestCase):
-    def send_and_recover(self, NUM_SHARES, NUM_SEGMENTS=4,
+    def send_and_recover(self, NUM_SHARES,
                          AVAILABLE_SHARES=None,
+                         DATA_LENGTH=76,
                          bucket_modes={}):
         if AVAILABLE_SHARES is None:
             AVAILABLE_SHARES = NUM_SHARES
         options = {"max_segment_size": 25} # force use of multiple segments
         e = encode.Encoder(options)
-        data = "happy happy joy joy" * 4
+        data = "happy happy joy joy" * 10
+        assert DATA_LENGTH <= len(data)
+        data = data[:DATA_LENGTH]
         e.setup(StringIO(data))
 
         assert e.num_shares == NUM_SHARES # else we'll be completely confused
         e.setup_codec() # need to rebuild the codec for that change
 
-        assert (NUM_SEGMENTS-1)*e.segment_size < len(data) <= NUM_SEGMENTS*e.segment_size
         shareholders = {}
         all_shareholders = []
         all_peers = []
@@ -204,6 +206,9 @@ class Roundtrip(unittest.TestCase):
     def test_one_share_per_peer(self):
         return self.send_and_recover(100)
 
+    def test_multiple_of_segsize(self):
+        return self.send_and_recover(100, DATA_LENGTH=75)
+
     def test_bad_blocks(self):
         # the first 74 servers have bad blocks, which will be caught by the
         # blockhashes
-- 
2.45.2