Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Z
ZKAPAuthorizer
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
Administrator
ZKAPAuthorizer
Commits
5dcbf507
Commit
5dcbf507
authored
3 years ago
by
Jean-Paul Calderone
Browse files
Options
Downloads
Patches
Plain Diff
use setup_example in test_storage_server.py
parent
d59a0b0a
No related branches found
Branches containing commit
No related tags found
1 merge request
!247
Use hypothesis setup_example hook
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/_zkapauthorizer/tests/test_storage_server.py
+15
-20
15 additions, 20 deletions
src/_zkapauthorizer/tests/test_storage_server.py
with
15 additions
and
20 deletions
src/_zkapauthorizer/tests/test_storage_server.py
+
15
−
20
View file @
5dcbf507
...
...
@@ -165,16 +165,27 @@ class PassValidationTests(TestCase):
self
.
clock
,
)
def
setup_example
(
self
):
"""
Prepare the TestCase to run one example of one test.
"""
# The storage server accumulates shares through the course of running
# a single example. Since existing state can invalidate assumptions
# made by the tests, get rid of it.
#
# It might be nice to just create a new, empty storage server here
# instead of cleaning up the old one. For now, that's hard because
# Hypothesis and testtools fixtures don't play nicely together in a
# way that allows us to just move everything from `setUp` into this
# method.
cleanup_storage_server
(
self
.
anonymous_storage_server
)
def
test_allocate_buckets_fails_without_enough_passes
(
self
):
"""
``remote_allocate_buckets`` fails with ``MorePassesRequired`` if it is
passed fewer passes than it requires for the amount of data to be
stored.
"""
# Hypothesis causes our storage server to be used many times. Clean
# up between iterations.
cleanup_storage_server
(
self
.
anonymous_storage_server
)
required_passes
=
2
share_nums
=
{
3
,
7
}
allocated_size
=
int
((
required_passes
*
self
.
pass_value
)
/
len
(
share_nums
))
...
...
@@ -219,10 +230,6 @@ class PassValidationTests(TestCase):
initial writes on shares without supplying passes, the operation fails
with ``MorePassesRequired``.
"""
# Hypothesis causes our storage server to be used many times. Clean
# up between iterations.
cleanup_storage_server
(
self
.
anonymous_storage_server
)
data
=
b
"
01234567
"
offset
=
0
sharenum
=
0
...
...
@@ -272,10 +279,6 @@ class PassValidationTests(TestCase):
vector which will increase the storage requirements of that slot
share by at least ``self.pass_value``.
"""
# hypothesis causes our storage server to be used many times. Clean
# up between iterations.
cleanup_storage_server
(
self
.
anonymous_storage_server
)
tw_vectors
=
{
k
:
v
.
for_call
()
for
(
k
,
v
)
in
test_and_write_vectors_for_shares
.
items
()
}
...
...
@@ -401,10 +404,6 @@ class PassValidationTests(TestCase):
with a storage index. It should return the ZKAPAuthorizer binding
message for the lease-taking operation.
"""
# hypothesis causes our storage server to be used many times. Clean
# up between iterations.
cleanup_storage_server
(
self
.
anonymous_storage_server
)
renew_secret
,
cancel_secret
=
secrets
required_count
=
required_passes
(
...
...
@@ -510,10 +509,6 @@ class PassValidationTests(TestCase):
``share_sizes`` returns the size of the requested mutable shares in the
requested slot.
"""
# hypothesis causes our storage server to be used many times. Clean
# up between iterations.
cleanup_storage_server
(
self
.
anonymous_storage_server
)
tw_vectors
=
{
k
:
v
.
for_call
()
for
(
k
,
v
)
in
test_and_write_vectors_for_shares
.
items
()
}
...
...
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