diff options
author | Florian Dold <florian@dold.me> | 2023-02-21 21:02:36 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2023-02-21 21:02:36 +0100 |
commit | b648238c4120ed341c76818b4ffa223d0122af78 (patch) | |
tree | dff1c75182170cfeed76c8d926e919470f2c9d71 /packages/taler-wallet-core/src/operations | |
parent | a3c7da975b6375f8c57154875642fb29a67e8731 (diff) |
harness: improve peer-pull integration test, check notificationsv0.9.3-dev.2
Diffstat (limited to 'packages/taler-wallet-core/src/operations')
-rw-r--r-- | packages/taler-wallet-core/src/operations/pay-peer.ts | 17 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/operations/transactions.ts | 30 |
2 files changed, 43 insertions, 4 deletions
diff --git a/packages/taler-wallet-core/src/operations/pay-peer.ts b/packages/taler-wallet-core/src/operations/pay-peer.ts index 8bde47df4..541e96280 100644 --- a/packages/taler-wallet-core/src/operations/pay-peer.ts +++ b/packages/taler-wallet-core/src/operations/pay-peer.ts @@ -72,6 +72,7 @@ import { codecOptional, codecForTimestamp, CancellationToken, + NotificationType, } from "@gnu-taler/taler-util"; import { SpendCoinDetails } from "../crypto/cryptoImplementation.js"; import { @@ -119,7 +120,10 @@ import { processWithdrawalGroup, } from "./withdraw.js"; import { PendingTaskType } from "../pending-types.js"; -import { stopLongpolling } from "./transactions.js"; +import { + constructTransactionIdentifier, + stopLongpolling, +} from "./transactions.js"; const logger = new Logger("operations/peer-to-peer.ts"); @@ -1507,6 +1511,14 @@ export async function processPeerPullCredit( await tx.peerPullPaymentInitiations.put(pi2); }); + ws.notify({ + type: NotificationType.PeerPullCreditReady, + transactionId: constructTransactionIdentifier({ + tag: TransactionType.PeerPullCredit, + pursePub: pullIni.pursePub, + }), + }); + return { type: OperationAttemptResultType.Finished, result: undefined, @@ -1626,9 +1638,6 @@ export async function initiatePeerPullPayment( const pursePair = await ws.cryptoApi.createEddsaKeypair({}); const mergePair = await ws.cryptoApi.createEddsaKeypair({}); - const instructedAmount = Amounts.parseOrThrow( - req.partialContractTerms.amount, - ); const contractTerms = req.partialContractTerms; const hContractTerms = ContractTermsUtil.hashContractTerms(contractTerms); diff --git a/packages/taler-wallet-core/src/operations/transactions.ts b/packages/taler-wallet-core/src/operations/transactions.ts index 1c2ce34bb..764115cef 100644 --- a/packages/taler-wallet-core/src/operations/transactions.ts +++ b/packages/taler-wallet-core/src/operations/transactions.ts @@ -64,6 +64,7 @@ import { } from "../db.js"; import { InternalWalletState } from "../internal-wallet-state.js"; import { PendingTaskType } from "../pending-types.js"; +import { assertUnreachable } from "../util/assertUnreachable.js"; import { checkDbInvariant } from "../util/invariants.js"; import { constructTaskIdentifier, TaskIdentifiers } from "../util/retries.js"; import { @@ -1376,6 +1377,35 @@ export type ParsedTransactionIdentifier = | { tag: TransactionType.Tip; walletTipId: string } | { tag: TransactionType.Withdrawal; withdrawalGroupId: string }; +export function constructTransactionIdentifier( + pTxId: ParsedTransactionIdentifier, +): string { + switch (pTxId.tag) { + case TransactionType.Deposit: + return `txn:${pTxId.tag}:${pTxId.depositGroupId}`; + case TransactionType.Payment: + return `txn:${pTxId.tag}:${pTxId.proposalId}`; + case TransactionType.PeerPullCredit: + return `txn:${pTxId.tag}:${pTxId.pursePub}`; + case TransactionType.PeerPullDebit: + return `txn:${pTxId.tag}:${pTxId.peerPullPaymentIncomingId}`; + case TransactionType.PeerPushCredit: + return `txn:${pTxId.tag}:${pTxId.peerPushPaymentIncomingId}`; + case TransactionType.PeerPushDebit: + return `txn:${pTxId.tag}:${pTxId.pursePub}`; + case TransactionType.Refresh: + return `txn:${pTxId.tag}:${pTxId.refreshGroupId}`; + case TransactionType.Refund: + return `txn:${pTxId.tag}:${pTxId.proposalId}:${pTxId.executionTime}`; + case TransactionType.Tip: + return `txn:${pTxId.tag}:${pTxId.walletTipId}`; + case TransactionType.Withdrawal: + return `txn:${pTxId.tag}:${pTxId.withdrawalGroupId}`; + default: + assertUnreachable(pTxId); + } +} + /** * Parse a transaction identifier string into a typed, structured representation. */ |