diff --git a/docs/source/interface.rst b/docs/source/interface.rst index 8b035cfac0813dacf423da714102b7e39f4b0529..2c004f26b3debbc8232df50a2095abc0fdbc9190 100644 --- a/docs/source/interface.rst +++ b/docs/source/interface.rst @@ -42,32 +42,35 @@ If the voucher is not known then the response is **NOT FOUND**. For any voucher which has previously been submitted, the response is **OK** with an ``application/json`` content-type response body like:: - { "value": <string> + { "number": <string> + , "expected-tokens": <integer> , "created": <iso8601 timestamp> , "state": <state object> , "version": 1 } -The ``value`` property merely indicates the voucher which was requested. +The ``number`` property merely indicates the voucher which was requested. +The ``expected-tokens`` property indicates the total number of ZKAPs the client for which the client intends to redeem the voucher. +Vouchers created using old versions of ZKAPAuthorizer will have a best-guess value here because the real value was not recorded. The ``created`` property indicates when the voucher was first added to the node. -The ``redeemed`` property indicates whether or not the voucher has successfully been redeemed with a payment server yet. -The ``token-count`` property gives the number of blinded token signatures the client received in exchange for redemption of the voucher -(each blinded token signature can be used to construct a one ZKAP), -if it has been redeemed. -If it has not been redeemed then it is ``null``. - The ``state`` property is an object that gives more details about the current state of the voucher. The following values are possible:: { "name": "pending" + , "counter": <integer> } +The integer *counter* value indicates how many successful sub-redemptions have completed for this voucher. + :: { "name": "redeeming" , "started": <iso8601 timestamp> + , "counter": <integer> } +The integer *counter* value has the same meaning as it does for the *pending* state. + :: { "name": "redeemed" diff --git a/src/_zkapauthorizer/model.py b/src/_zkapauthorizer/model.py index 636c3a1b5a49b06ed8aa44ab2bc3361b991d7361..679352e8f5369c23e5bf93a1717db95e8a6e5de7 100644 --- a/src/_zkapauthorizer/model.py +++ b/src/_zkapauthorizer/model.py @@ -951,9 +951,6 @@ class Voucher(object): number, created, expected_tokens, state = row[:4] - if expected_tokens is None: - raise ValueError("Bluib") - return cls( number=number, expected_tokens=expected_tokens, diff --git a/src/_zkapauthorizer/schema.py b/src/_zkapauthorizer/schema.py index 596629950ededd1535cbf6a49a4788d1ea347ef1..a23d3373c9a230d874710183e046d9e9cef954e6 100644 --- a/src/_zkapauthorizer/schema.py +++ b/src/_zkapauthorizer/schema.py @@ -146,10 +146,14 @@ _UPGRADES = { """, """ -- Record the total number of tokens for which we expect to be able to - -- redeem this voucher. For rows in the database before this column - -- was added, we forgot how many tokens we expected. All rows added - -- after this column is added should have a non-NULL value. - ALTER TABLE [vouchers] ADD COLUMN [expected-tokens] integer + -- redeem this voucher. We don't want to allow NULL values here at + -- all because that allows insertion of garbage data going forward. + -- However to add a non-NULL column to a table we have to supply a + -- default value. Since no real vouchers have ever been issued at the + -- time of this upgrade we'll just make up some value. It doesn't + -- particularly matter if it is wrong for some testing voucher someone + -- used. + ALTER TABLE [vouchers] ADD COLUMN [expected-tokens] integer NOT NULL DEFAULT 32768 """, ], } diff --git a/src/_zkapauthorizer/tests/test_controller.py b/src/_zkapauthorizer/tests/test_controller.py index 643749d470d9e2c4cc529c8564a93bcf42b75e3e..d133a3d72133cba18f649704b59ea420f17a40d1 100644 --- a/src/_zkapauthorizer/tests/test_controller.py +++ b/src/_zkapauthorizer/tests/test_controller.py @@ -358,7 +358,6 @@ class PaymentControllerTests(TestCase): ), ) - @given(tahoe_configs(), datetimes(), vouchers(), voucher_counters(), integers(min_value=0, max_value=100)) def test_stop_redeeming_on_error(self, get_config, now, voucher, counter, extra_tokens): """