From 9ce5789fb2172b1d4e96b3dade8835ac13fe3459 Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone <exarkun@twistedmatrix.com> Date: Tue, 28 Apr 2020 10:32:45 -0400 Subject: [PATCH] Make sure these tests use enough tokens They must use at least as many tokens as there are redemption groups --- src/_zkapauthorizer/tests/test_client_resource.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/_zkapauthorizer/tests/test_client_resource.py b/src/_zkapauthorizer/tests/test_client_resource.py index 6c2089a..9c2b538 100644 --- a/src/_zkapauthorizer/tests/test_client_resource.py +++ b/src/_zkapauthorizer/tests/test_client_resource.py @@ -78,6 +78,7 @@ from fixtures import ( from hypothesis import ( given, note, + assume, ) from hypothesis.strategies import ( one_of, @@ -155,7 +156,7 @@ from .matchers import ( ) # A small number of tokens to work with in the tests. -NUM_TOKENS = 10 +NUM_TOKENS = 100 TRANSIENT_ERROR = u"something went wrong, who knows what" @@ -367,6 +368,7 @@ class UnblindedTokenTests(TestCase): root = root_from_config(config, datetime.now) if num_tokens: + assume(num_tokens >= root.controller.num_redemption_groups) # Put in a number of tokens with which to test. redeeming = root.controller.redeem(voucher, num_tokens) # Make sure the operation completed before proceeding. @@ -401,6 +403,7 @@ class UnblindedTokenTests(TestCase): root = root_from_config(config, datetime.now) if num_tokens: + assume(num_tokens >= root.controller.num_redemption_groups) # Put in a number of tokens with which to test. redeeming = root.controller.redeem(voucher, num_tokens) # Make sure the operation completed before proceeding. @@ -420,7 +423,10 @@ class UnblindedTokenTests(TestCase): ) self.assertThat( requesting, - succeeded_with_unblinded_tokens(num_tokens, min(num_tokens, limit)), + succeeded_with_unblinded_tokens( + num_tokens, + min(num_tokens, limit), + ), ) @given(tahoe_configs(), vouchers(), integers(min_value=0, max_value=100), text(max_size=64)) @@ -435,6 +441,7 @@ class UnblindedTokenTests(TestCase): root = root_from_config(config, datetime.now) if num_tokens: + assume(num_tokens >= root.controller.num_redemption_groups) # Put in a number of tokens with which to test. redeeming = root.controller.redeem(voucher, num_tokens) # Make sure the operation completed before proceeding. @@ -500,6 +507,8 @@ class UnblindedTokenTests(TestCase): config = get_config(tempdir.join(b"tahoe"), b"tub.port") root = root_from_config(config, datetime.now) + assume(num_tokens >= root.controller.num_redemption_groups) + # Put in a number of tokens with which to test. redeeming = root.controller.redeem(voucher, num_tokens) # Make sure the operation completed before proceeding. -- GitLab