Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tahoe-ssk
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
PrivateStorage
tahoe-ssk
Commits
8fe3be49
Commit
8fe3be49
authored
2 years ago
by
Jean-Paul Calderone
Browse files
Options
Downloads
Patches
Plain Diff
Test against all 10 shares
parent
aebe0b73
No related branches found
No related tags found
1 merge request
!3
Add a Binary instance to deserialize from and serialize to the canonical byte representation
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/Spec.hs
+24
-20
24 additions, 20 deletions
test/Spec.hs
with
24 additions
and
20 deletions
test/Spec.hs
+
24
−
20
View file @
8fe3be49
...
...
@@ -28,12 +28,17 @@ tests =
property
$
do
share
<-
forAll
shares
tripping
share
Binary
.
encode
decode'
,
testCase
"known-correct serialized shares round-trip though Share"
$
do
,
testCase
"known-correct serialized shares round-trip though Share"
$
mapM_
knownCorrectRoundTrip
[
0
::
Int
..
9
]
]
knownCorrectRoundTrip
::
Show
a
=>
a
->
IO
()
knownCorrectRoundTrip
n
=
do
-- The files are in "bucket" format. We need to extract the
-- "slot". We do so by stripping a prefix and suffix. To avoid
-- having to parse the prefix, we assert that the suffix is a
-- predictable size.
bucket
<-
LB
.
readFile
"test/data/3of10.
0
"
bucket
<-
LB
.
readFile
(
"test/data/3of10."
<>
show
n
)
let
withoutPrefix
=
LB
.
drop
(
32
+
20
+
32
+
8
+
8
+
368
)
bucket
dataSize
=
LB
.
length
withoutPrefix
-
4
shareData
=
LB
.
take
dataSize
withoutPrefix
...
...
@@ -45,8 +50,7 @@ tests =
let
decoded
=
decode'
shareData
let
encoded
=
(
Binary
.
encode
::
Share
->
LB
.
ByteString
)
<$>
decoded
assertEqual
"original /= encoded"
(
Right
shareData
)
encoded
]
where
decode'
::
Binary
.
Binary
b
=>
LB
.
ByteString
->
Either
(
LB
.
ByteString
,
ByteOffset
,
String
)
b
decode'
=
((
\
(
_
,
_
,
a
)
->
a
)
<$>
)
.
Binary
.
decodeOrFail
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment