Repository navigation
test: property tests for expiry arithmetic (grant, extend, renew, subscribe) + fix main build - #146
Merged
Busiii-adetiba merged 1 commit intoOct 17, 2026
Conversation
…renew and subscribe (SynapsVault#108) Property tests (proptest, checked against an integer model): - access-lease: grant sets expires_at = now + duration or rejects overflow; validity holds strictly before expiry; extend adds to max(expiry, now) or rejects overflow leaving the lease unchanged; extensions accumulate; re-grant only after expiry and restarts from now; zero rejected. - subscription: subscribe ends one CYCLE after now; active strictly before period end; renew extends from max(period end, now); early renewals add whole cycles; re-subscribing after cancel carries over remaining time; duplicate subscribe rejected while active. main has failed CI since Oct 16, so these could not run. Minimal fixes to get the workspace compiling and CI green: - access-lease: remove a duplicated grant_lease body left by a merge. - Drop common BUMP/BUMP_THRESH/DAY imports that clashed with each crate's own ledger-based constants (common's DAY is in seconds). - Restore per-contract get_version/is_compatible; the common helpers are u32-based and did not match any caller. Fix subscription require_admin. - common: use the workspace soroban-sdk (was 20.0.0) and add it to the workspace members / Cargo.lock. - vault-registry: fix String::from_bytes call; validate the patch component in is_compatible so "0.1." and "0.1.2.3" are rejected (SynapsVault#83 test). - subscription: subscribe/renew events use data_format = "vec" to match the documented (current_period_end, price, payment_reference) tuple. - Tests: port event assertions to the soroban-sdk 29 ContractEvents API, use propose/accept_transfer instead of removed transfer_ownership, pass the new list() filter args, upload real WASM for success-path upgrade tests, fix a 32-vs-33 length test and an empty-metadata generator. - Regenerate the vault-registry upgrade fixture (make fixture). - clippy (len_zero) and cargo fmt. Closes SynapsVault#108 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
@adenueltech Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #108
Property tests
New
expiry_propstest modules (proptest, 64 cases each) check every expiry rule against a plain-integer model instead of hand-picked examples.access-lease (
contracts/access-lease/src/expiry_props.rs)grant_leasesetsexpires_at = now + durationexactly, or returnsInvalidDurationonu32overflow and stores nothing.expires_atand invalid fromexpires_aton.extend_leaseadds tomax(expires_at, now), so an active lease keeps its remaining time and an expired one restarts. The result is always later than both. Overflow is rejected and the stored lease is left unchanged.AlreadyActivewhile the lease is active; after expiry it restarts from now.subscription (
contracts/subscription/src/expiry_props.rs)subscribeends exactly oneCYCLEafter now.current_period_end.renewextends frommax(current_period_end, now), incrementstotal_renewalsand keepsstarted_at.kearly renewals add exactlykcycles.cancel, access lasts until the period end andrenewreturnsCancelled. Re-subscribing carries over the remaining paid time, or restarts from now after it lapses.subscribewhile active returnsAlreadySubbedand leaves the subscription unchanged.The tests set a long minimum entry TTL on the test ledger, so time can move across several full cycles without storage being archived. The subscription
Overflowbranch isn't exercised: it needs a ledger within one cycle ofu32::MAX, where the host's own TTL arithmetic fails first. That's noted in the test.Fixes needed to get
mainbuildingCI on
mainhas failed on every run since Oct 16, and the workspace didn't compile, so no tests could run. The minimal fixes, each from conflicting merges:grant_leaseOk(lease)followed by another expression), the parse error CI reportsgrant_lease_internaluse common::{BUMP, BUMP_THRESH, DAY}clashed with each crate's own constants.common::DAYis in seconds, and itsBUMP_THRESH>BUMPcommon::get_version/is_compatibleareu32-based and matched none of the three call sitesget_version/is_compatible(last-green behaviour)require_admincommon::require_adminwith aDataKeycommoncratesoroban-sdk = "20.0.0"(workspace is 29), not a workspace member, missing fromCargo.lock(breaks--locked)String::from_bytesgiven&Bytesis_compatible"0.1."and"0.1.2.3"to be rejected, but they were acceptedsubscribe/renewemitted a map, but docs and tests specify the tuple(current_period_end, price, payment_reference)data_format = "vec"ContractEventsAPI (len/get_unchecked), removedtransfer_ownership, old 2-arglist,upgradeto a never-uploaded hash, a 32-vs-33 length typo, an empty-metadata proptest generator, a stale upgrade fixture&false, &Nonetolist(old behaviour), uploaded real WASM, fixed the typo and generator, regenerated the fixture withmake fixturesteps (stellar-cli 27.0.0)len_zero,cargo fmtHow I tested (same steps as CI)
cargo fmt --all -- --check: OKcargo clippy --workspace --all-targets --locked -- -D warnings: OKRUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --locked: OKcargo test --locked -p vault-registry: 62 passedcargo test --locked -p access-lease: 34 passed (incl. 6 property tests)cargo test --locked -p subscription: 14 passed (incl. 6 property tests)stellar contract build: all 3 contracts buildNote: the stricter
vault-registry::is_compatiblealso rejects strings that aren'tX.Y.Z. #144 (the docs PR for #115) lists the cases that returnfalse, and I'll add this one there.🤖 Generated with Claude Code