From 3781cfc85eb6164f56f86510304fbeef98138f30 Mon Sep 17 00:00:00 2001 From: Jun Luo <4catcode@gmail.com> Date: Fri, 28 Jan 2022 10:48:46 +0800 Subject: [PATCH] feat: add support for horizon-v2.13.0 --- stellar_model/model/horizon/claimable_balance.py | 4 ++++ tests/model/horizon/test_claimable_balance.py | 8 +++++++- tests/model/horizon/test_effects.py | 3 +++ tests/model/horizon/test_operations.py | 4 ++++ .../model/horizon/claimable_balance_conditional.json | 6 ++++-- .../effects/claimable_balance_claimant_created.json | 3 ++- .../horizon/operations/create_claimable_balance.json | 3 ++- tests/resources/response/claimable_balances_response.json | 3 ++- tests/resources/response/operations_response.json | 3 ++- 9 files changed, 30 insertions(+), 7 deletions(-) diff --git a/stellar_model/model/horizon/claimable_balance.py b/stellar_model/model/horizon/claimable_balance.py index 10410e8..c90e3e1 100644 --- a/stellar_model/model/horizon/claimable_balance.py +++ b/stellar_model/model/horizon/claimable_balance.py @@ -58,6 +58,10 @@ class ClaimPredicate(BaseModel): "balance can be claimed. If the balance is claimed before the " "date then this clause of the condition is satisfied." ) + abs_before_epoch: Optional[int] = Field( + "The Unix Epoch value represented by the same custom extended " + "ISO date value in the abs_before field." + ) rel_before: Optional[int] = Field( description="A relative deadline for when the claimable balance can be " "claimed. The value represents the number of seconds since the " diff --git a/tests/model/horizon/test_claimable_balance.py b/tests/model/horizon/test_claimable_balance.py index 56723ff..f81c3b8 100644 --- a/tests/model/horizon/test_claimable_balance.py +++ b/tests/model/horizon/test_claimable_balance.py @@ -53,7 +53,9 @@ def test_conditional_valid(self): parsed_data.claimants[0].predicate.abs_before, datetime.datetime(2021, 4, 21, 19, 3, 6, tzinfo=datetime.timezone.utc), ) - + self.assertEqual( + parsed_data.claimants[0].predicate.abs_before_epoch, 1619031786 + ) self.assertEqual( parsed_data.claimants[1].destination, "GDDAESY7RTZAZNWZLZD5RIKP2TWEAVISKQJZ43ZZ2YTMCNICRVW7OJP3", @@ -62,3 +64,7 @@ def test_conditional_valid(self): parsed_data.claimants[1].predicate.not_predicate.abs_before, datetime.datetime(2021, 4, 21, 19, 3, 1, tzinfo=datetime.timezone.utc), ) + self.assertEqual( + parsed_data.claimants[1].predicate.not_predicate.abs_before_epoch, + 1619031781, + ) diff --git a/tests/model/horizon/test_effects.py b/tests/model/horizon/test_effects.py index 62a700a..e5b6514 100644 --- a/tests/model/horizon/test_effects.py +++ b/tests/model/horizon/test_effects.py @@ -569,6 +569,9 @@ def test_valid_claimable_balance_claimant_created(self): parsed_data.predicate.not_predicate.abs_before, datetime.datetime(2021, 4, 26, 4, 0, tzinfo=datetime.timezone.utc), ) + self.assertEqual( + parsed_data.predicate.not_predicate.abs_before_epoch, 1619409600 + ) def test_valid_claimable_balance_claimed(self): raw_data = load_horizon_file("effects/claimable_balance_claimed.json") diff --git a/tests/model/horizon/test_operations.py b/tests/model/horizon/test_operations.py index 33e21c1..833378f 100644 --- a/tests/model/horizon/test_operations.py +++ b/tests/model/horizon/test_operations.py @@ -630,6 +630,10 @@ def test_valid_create_claimable_balance_operation(self): parsed_data.claimants[1].predicate.not_predicate.abs_before, datetime.datetime(2021, 4, 26, 4, 0, tzinfo=datetime.timezone.utc), ) + self.assertEqual( + parsed_data.claimants[1].predicate.not_predicate.abs_before_epoch, + 1619409600, + ) def test_valid_claim_claimable_balance_operation(self): raw_data = load_horizon_file("operations/claim_claimable_balance.json") diff --git a/tests/resources/model/horizon/claimable_balance_conditional.json b/tests/resources/model/horizon/claimable_balance_conditional.json index d304d42..e101010 100644 --- a/tests/resources/model/horizon/claimable_balance_conditional.json +++ b/tests/resources/model/horizon/claimable_balance_conditional.json @@ -22,14 +22,16 @@ { "destination": "GCYTED6QWSGDNLQ2RBXDVYSKCOUB2BC6DLKGAU5QPNONMVN47ABUN6WE", "predicate": { - "abs_before": "2021-04-21T19:03:06Z" + "abs_before": "2021-04-21T19:03:06Z", + "abs_before_epoch": 1619031786 } }, { "destination": "GDDAESY7RTZAZNWZLZD5RIKP2TWEAVISKQJZ43ZZ2YTMCNICRVW7OJP3", "predicate": { "not": { - "abs_before": "2021-04-21T19:03:01Z" + "abs_before": "2021-04-21T19:03:01Z", + "abs_before_epoch": 1619031781 } } } diff --git a/tests/resources/model/horizon/effects/claimable_balance_claimant_created.json b/tests/resources/model/horizon/effects/claimable_balance_claimant_created.json index 22b7412..8377335 100644 --- a/tests/resources/model/horizon/effects/claimable_balance_claimant_created.json +++ b/tests/resources/model/horizon/effects/claimable_balance_claimant_created.json @@ -21,7 +21,8 @@ "amount": "900.0000000", "predicate": { "not": { - "abs_before": "2021-04-26T04:00:00Z" + "abs_before": "2021-04-26T04:00:00Z", + "abs_before_epoch": 1619409600 } } } \ No newline at end of file diff --git a/tests/resources/model/horizon/operations/create_claimable_balance.json b/tests/resources/model/horizon/operations/create_claimable_balance.json index d77c0af..25bf272 100644 --- a/tests/resources/model/horizon/operations/create_claimable_balance.json +++ b/tests/resources/model/horizon/operations/create_claimable_balance.json @@ -38,7 +38,8 @@ "destination": "GCBMP2WKIAX7KVDRCSFXJWFM5P7HDCGTCC76U5XR52OYII6AOWS7G3DT", "predicate": { "not": { - "abs_before": "2021-04-26T04:00:00Z" + "abs_before": "2021-04-26T04:00:00Z", + "abs_before_epoch": 1619409600 } } } diff --git a/tests/resources/response/claimable_balances_response.json b/tests/resources/response/claimable_balances_response.json index dad4d5d..60a11ea 100644 --- a/tests/resources/response/claimable_balances_response.json +++ b/tests/resources/response/claimable_balances_response.json @@ -43,7 +43,8 @@ "destination": "GCBMP2WKIAX7KVDRCSFXJWFM5P7HDCGTCC76U5XR52OYII6AOWS7G3DT", "predicate": { "not": { - "abs_before": "2021-04-26T04:00:00Z" + "abs_before": "2021-04-26T04:00:00Z", + "abs_before_epoch": 1619409600 } } } diff --git a/tests/resources/response/operations_response.json b/tests/resources/response/operations_response.json index 871fd11..de2061e 100644 --- a/tests/resources/response/operations_response.json +++ b/tests/resources/response/operations_response.json @@ -264,7 +264,8 @@ "destination": "GCBMP2WKIAX7KVDRCSFXJWFM5P7HDCGTCC76U5XR52OYII6AOWS7G3DT", "predicate": { "not": { - "abs_before": "2021-04-26T04:00:00Z" + "abs_before": "2021-04-26T04:00:00Z", + "abs_before_epoch": 1619409600 } } }