Merged
Conversation
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.
test: add schema consistency tests for common event helpers
Closes #328
Summary
remitwise-commoncoveringRemitwiseEventstopic/payload schema,clamp_limitboundaries, enum discriminant stability, TTL constant relationships, and trait correctness.ARCHIVE_LIFETIME_THRESHOLDandARCHIVE_BUMP_AMOUNTconstant definitions that would cause compilation errors (hardcoded values duplicated the computed values usingDAY_IN_LEDGERS).proptestkey ininsurance/Cargo.tomlthat was blocking workspace-wide compilation.soroban-sdkwithtestutilsfeature toremitwise-commondev-dependencies to enable event inspection in tests.remittance_split,family_wallet,orchestrator) that were blocking CI builds.Motivation
remitwise-commonis imported by 7 contracts but had zero test coverage. Any silent change to enum discriminants, event topic ordering, or constant values could propagate undetected across the entire workspace. These tests lock down the public API surface and prevent accidental schema drift.Additionally, the workspace had multiple compilation-breaking issues from prior merges that needed resolution for CI to pass.
Test Coverage Breakdown
clamp_limitboundary/property tests[1, MAX_PAGE_LIMIT]Category,FamilyRole,CoverageType,EventCategory,EventPriorityFamilyRoleorderingOrdcontract used for access control comparisonsto_u32()conversionas u32cast andto_u32()methodDAY_IN_LEDGERSvalue, threshold < bump invariants, exact day-count formulasSIGNATURE_EXPIRATION,MAX_BATCH_SIZE,CONTRACT_VERSION, pagination defaultsRemitwiseEvents::emittopic schemaTopic[0]= "Remitwise" namespace,Topic[1]= category,Topic[2]= priority,Topic[3]= action, payload fidelity (u32, bool, tuple), exhaustive 5x3 category-priority matrixRemitwiseEvents::emit_batchschemaemitandemit_batchshare namespace/category positions; batch action lives in payload, not topicsClone+Eqfor contract types,Copyfor event enumsTotal: 40 tests
Files Changed
remitwise-common/src/lib.rs#[cfg(test)] mod testswith 40 tests; removed duplicateARCHIVE_*constantsremitwise-common/Cargo.toml[dev-dependencies]withsoroban-sdktestutilsinsurance/Cargo.tomlproptestkey in[dev-dependencies]remittance_split/src/lib.rsRemittanceSplitError; addedSplitAuthPayloadstruct; addedexported_atfield toExportSnapshot; importedclamp_limit; fixedverify_snapshotchecksum call signature; fixed undefinedcurrent_max_id/schedulesvariables increate_schedulefamily_wallet/src/lib.rsprecision_limit: Noneto 2FamilyMemberinitializers; addedvalidate_precision_spendingfunction; importedpanic_with_error!macroorchestrator/src/lib.rsvalidate_two_addressesandconsume_noncehelper methods; prefixed unusednonceparams with_Compilation Fixes Detail
remittance_split/src/lib.rsPercentageOutOfRange,PercentagesDoNotSumTo100,SnapshotNotInitialized,InvalidPercentageRange,FutureTimestamp,OwnerMismatchadded toRemittanceSplitError(discriminants 17–22)SplitAuthPayloaddefined with domain-separated auth fields matching its usage ininitialize_splitexported_at: u64added toExportSnapshotand populated inexport_snapshotclamp_limitimported fromremitwise_commonforget_audit_logcurrent_max_idandschedules.contains_key()increate_schedulefixed to use storage readsverify_snapshotwas passingexported_atinstead of&schedulestocompute_checksumfamily_wallet/src/lib.rsprecision_limit: Noneadded to owner and initial memberFamilyMemberinitializers ininit()validate_precision_spendingimplemented to validate amounts againstPrecisionSpendingLimitconstraintspanic_with_error!added to importsorchestrator/src/lib.rsvalidate_two_addresses(self-reference and duplicate detection) andconsume_nonce(replay protection via monotonic counter) addednonceparameters prefixed with_inexecute_bill_paymentandexecute_insurance_paymentSecurity Notes
"Remitwise", category, priority, action) that on-chain indexers depend on. Any topic reordering would break downstream consumers.#[contracttype]enums stored on-chain.threshold < bump) ensure storage entries are always renewed before they expire.RemitwiseEvents::emitsecurity doc).SplitAuthPayloadincludes full domain separation (network ID, contract address, operation) to prevent cross-contract replay.validate_two_addressesprevents self-referencing and duplicate contract addresses in orchestrator flows.consume_nonceprovides replay protection with a monotonic counter per caller.How to Test
cargo build --release --target wasm32-unknown-unknown cargo test -p remitwise-commonChecklist
remitwise-common/src/lib.rsRemitwiseEventstopic orderingremittance_split,family_wallet, andorchestratortestutilsfeature flag for existingsoroban-sdk)