diff --git a/src/_zkapauthorizer/_storage_client.py b/src/_zkapauthorizer/_storage_client.py index 05949131bc7602e185196447b569e3cdf9a4ff56..e4c8e598a01d050e1c36ad93ba8f9bd54c240b71 100644 --- a/src/_zkapauthorizer/_storage_client.py +++ b/src/_zkapauthorizer/_storage_client.py @@ -312,12 +312,12 @@ class ZKAPAuthorizerStorageClient(object): """ alreadygot, bucketwriters = result if alreadygot: - # Some passes don't need to be spent because the server already - # has some of the share data. - actual_size = allocated_size * len(bucketwriters) + # Passes only need to be spent for buckets that are being + # allocated. Someone already paid for any shares the server + # already has. actual_passes = required_passes( self._pass_value, - [actual_size], + [allocated_size] * len(bucketwriters), ) to_spend, to_reset = pass_group.split(range(actual_passes)) to_spend.mark_spent() diff --git a/src/_zkapauthorizer/tests/test_storage_protocol.py b/src/_zkapauthorizer/tests/test_storage_protocol.py index 44afe1314baa83d94a41c0507a12e1508bcf9228..f1dba779b6e53b62006c4ff16d89c66e38aca426 100644 --- a/src/_zkapauthorizer/tests/test_storage_protocol.py +++ b/src/_zkapauthorizer/tests/test_storage_protocol.py @@ -418,14 +418,14 @@ class ShareTests(TestCase): # the total number of passes issued during the test. anticipated_passes = required_passes( self.pass_value, - [size * len(all_sharenums)], + [size] * len(all_sharenums), ) # The number of passes that will *actually* need to be spent depends # on the size and number of shares that really need to be allocated. expected_spent_passes = required_passes( self.pass_value, - [size * len(all_sharenums - existing_sharenums)], + [size] * len(all_sharenums - existing_sharenums), ) # The number of passes returned is just the difference between those