Skip to content

test(payments): compare multi-payment native amounts exactly - #1083

Merged
bmc08gt merged 9 commits into
mainfrom
test/multi-payment-exact-native
Oct 19, 2026
Merged

bmc08gt merged 9 commits into
mainfrom
test/multi-payment-exact-native

Conversation

@bmc08gt

@bmc08gt bmc08gt commented Oct 17, 2026

Copy link
Copy Markdown
Collaborator

Stacked on #1078. Removes the 1e-12 relative tolerance that MultiPaymentIntentVectorTests used for native_amount. With Decimal.doubleValue rounding correctly, each payment's native amount equals Double(fixture string) bit for bit.

The first commit is the same fix as #1082, so this test can pass on its own branch. Once #1082 lands on main and #1078 picks it up, the duplicate commit drops on rebase.

…nges

Build against local client protocol checkouts; pins unchanged.

- ocp: add IntentMultiTransfer for SendPublicMultiPayment (one
  no-privacy transfer per payment) and Client.transferMultiple; handle
  the new Metadata case in IntentMetadata.
- flipcash2: add CommunityService and FlipClient.fetchCommunity for
  GetCommunity.
- Map ReactionUpdate.Action.BOOSTED and
  RemoveReactionResponse.Result.CANNOT_REMOVE_BOOSTED.
- Carry boost_usd on Reactor, EmojiReaction and ReactionUpdate, the chat
  holdings summary, the activity BoostedReaction and the
  ChatMetadata.reaction_boost case.
IntentMultiTransfer.Payment.destinationOwner is now non-optional and is
always written to the SendPublicMultiPayment metadata, since the server
requires it when a destination PRIMARY is auto-opened. Client.transferMultiple
takes a non-optional owner too.

The intent now also rejects a destination owner equal to the source authority
(destinationIsSource) and any payment whose native currency differs from the
verified rate's currency (currencyMismatch, compared case-insensitively).

Tests cover owner presence, appMetadata set/absent, duplicate owner, owner
equal to source authority, destination equal to source vault, mint mismatch,
and currency mismatch.
Add MultiPaymentIntentVectorTests, which builds IntentMultiTransfer from
multi_payment_intent.json and asserts actions, compact messages, SHA-256,
ed25519 signatures, proto metadata, and the eight rejection cases.

The vectors expect destination == source vault and a repeated destination
owner to be distinct rules from the others, so IntentMultiTransfer.Error
gains duplicateDestinationOwner and a destination equal to the source vault
now throws destinationIsSource instead of duplicateDestination.

Add a repo-root .swift-version containing "xcode" so swiftly resolves to
the Xcode toolchain; a swiftly 6.2.1 toolchain fails to build
FlipcashCore/Package.swift against this Xcode's SDK.
`doubleValue` divided the mantissa by ten once per decimal digit, so
0.007 became 0.006999999999999999 and 0.000001 became
1.0000000000000002e-06. Android's `BigDecimal.toDouble()` rounds
correctly, so the two apps could send different `native_amount`
doubles in intent `client_exchange_data` for the same amount.

Parse `description` with `Double(String)` instead. `NSDecimalNumber`'s
`doubleValue` is no fix: over 200k sampled decimals it missed on
exactly the same values as the loop, while the string parse missed none.
With Decimal.doubleValue correctly rounded, the native_amount each
payment carries equals Double(fixture string) bit for bit, so the
1e-12 relative tolerance has nothing left to absorb.
@bmc08gt bmc08gt self-assigned this Oct 17, 2026
@bmc08gt
bmc08gt changed the base branch from chore/contract-ocp-0.8.0-flipcash2-0.20.0 to main October 19, 2026 14:49
* origin/main:
  feat(chat): pick a new group's currency from a full-width row (#1084)
  fix(core): round Decimal.doubleValue correctly (#1082)
  feat(flipcash): adopt ocp 0.8.0 and flipcash2 0.20.0 contracts (#1078)
  chore: bump version to 2026.10.4 (#1086)
  chore: record 2026.10.3 as the production release (#1089)
  ci(release-manifest): record every TestFlight build when it processes (#1088)
  build: update release manifest
  test: stop four retry-only tests failing on a loaded runner (#1087)
  fix: clear the 2026.10.3 release test gate (#1085)
  build: update release manifest
  fix(chat): cap the attach card's corner radius at 40pt on iOS 26 (#1081)
  feat(update): check for an update every time the app returns from the background (#1080)
  build: update release manifest
  chore(chat): log where the inline photo picker flow stops (#1079)
  build: update release manifest
  fix(chat): open the author's profile from the avatar beside a photo (#1077)
  feat(chat): forward a message through the share sheet (#1076)
  feat(chat): draw message links as a message card (#1057)

# Conflicts:
#	FlipcashCoreVectors/Tests/FlipcashCoreVectorsTests/MultiPaymentIntentVectorTests.swift
* origin/main:
  fix(chat): name the users a join notice is about (#1090)
@bmc08gt
bmc08gt merged commit d860cf8 into main Oct 19, 2026
2 of 3 checks passed
@bmc08gt
bmc08gt deleted the test/multi-payment-exact-native branch October 23, 2026 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant