extract BlockHasher and TreeHasher classes
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
from basetest import *
|
||||
from zfs_autobackup.BlockHasher import BlockHasher
|
||||
|
||||
|
||||
class TestZfsCheck(unittest2.TestCase):
|
||||
@ -17,24 +18,25 @@ class TestZfsCheck(unittest2.TestCase):
|
||||
# 959e6b58078f0cfd2fb3d37e978fda51820473ff whole_whole2
|
||||
# 309ffffba2e1977d12f3b7469971f30d28b94bd8 whole_whole2_partial
|
||||
|
||||
block_hasher=BlockHasher(count=1)
|
||||
|
||||
self.assertEqual(
|
||||
list(block_hash("tests/data/empty", count=1)),
|
||||
list(block_hasher.generate("tests/data/empty")),
|
||||
[]
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
list(block_hash("tests/data/partial", count=1)),
|
||||
list(block_hasher.generate("tests/data/partial")),
|
||||
[(0, "642027d63bb0afd7e0ba197f2c66ad03e3d70de1")]
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
list(block_hash("tests/data/whole", count=1)),
|
||||
list(block_hasher.generate("tests/data/whole")),
|
||||
[(0, "3c0bf91170d873b8e327d3bafb6bc074580d11b7")]
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
list(block_hash("tests/data/whole_whole2", count=1)),
|
||||
list(block_hasher.generate("tests/data/whole_whole2")),
|
||||
[
|
||||
(0, "3c0bf91170d873b8e327d3bafb6bc074580d11b7"),
|
||||
(1, "2e863f1fcccd6642e4e28453eba10d2d3f74d798")
|
||||
@ -42,7 +44,7 @@ class TestZfsCheck(unittest2.TestCase):
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
list(block_hash("tests/data/whole_whole2_partial", count=1)),
|
||||
list(block_hasher.generate("tests/data/whole_whole2_partial")),
|
||||
[
|
||||
(0, "3c0bf91170d873b8e327d3bafb6bc074580d11b7"), #whole
|
||||
(1, "2e863f1fcccd6642e4e28453eba10d2d3f74d798"), #whole2
|
||||
@ -50,16 +52,18 @@ class TestZfsCheck(unittest2.TestCase):
|
||||
]
|
||||
)
|
||||
|
||||
block_hasher=BlockHasher(count=2)
|
||||
self.assertEqual(
|
||||
list(block_hash("tests/data/whole_whole2_partial", count=2)),
|
||||
list(block_hasher.generate("tests/data/whole_whole2_partial")),
|
||||
[
|
||||
(0, "959e6b58078f0cfd2fb3d37e978fda51820473ff"), #whole_whole2
|
||||
(1, "642027d63bb0afd7e0ba197f2c66ad03e3d70de1") #partial
|
||||
]
|
||||
)
|
||||
|
||||
block_hasher=BlockHasher(count=10)
|
||||
self.assertEqual(
|
||||
list(block_hash("tests/data/whole_whole2_partial", count=10)),
|
||||
list(block_hasher.generate("tests/data/whole_whole2_partial")),
|
||||
[
|
||||
(0, "309ffffba2e1977d12f3b7469971f30d28b94bd8"), #whole_whole2_partial
|
||||
])
|
||||
|
||||
Reference in New Issue
Block a user