gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-wallet-core] branch master updated (860cd81f3 -> 28d8c257e)


From: gnunet
Subject: [taler-wallet-core] branch master updated (860cd81f3 -> 28d8c257e)
Date: Tue, 04 Apr 2023 15:26:22 +0200

This is an automated email from the git hooks/post-receive script.

dold pushed a change to branch master
in repository wallet-core.

    from 860cd81f3 add fullfilment url and message if the are present
     new cefec08ce wallet-core: check for broken transactions
     new 07d8498ab wallet-core: implement runIntegrationTestV2
     new 28d8c257e bump version to 0.0.3-dev.11

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 packages/taler-harness/package.json                |   2 +-
 packages/taler-util/package.json                   |   2 +-
 packages/taler-util/src/wallet-types.ts            |  15 ++
 packages/taler-wallet-cli/package.json             |   2 +-
 packages/taler-wallet-core/package.json            |   2 +-
 .../taler-wallet-core/src/operations/pay-peer.ts   |   4 +-
 .../taler-wallet-core/src/operations/testing.ts    | 152 +++++++++++++++++++++
 .../src/operations/transactions.ts                 |  13 ++
 packages/taler-wallet-core/src/wallet-api-types.ts |  12 ++
 packages/taler-wallet-core/src/wallet.ts           |  15 +-
 .../taler-wallet-webextension/manifest-common.json |   4 +-
 packages/taler-wallet-webextension/package.json    |   4 +-
 packages/web-util/package.json                     |   4 +-
 13 files changed, 215 insertions(+), 16 deletions(-)

diff --git a/packages/taler-harness/package.json 
b/packages/taler-harness/package.json
index 9cde1dab9..8def7af61 100644
--- a/packages/taler-harness/package.json
+++ b/packages/taler-harness/package.json
@@ -1,6 +1,6 @@
 {
   "name": "@gnu-taler/taler-harness",
-  "version": "0.9.3-dev.10",
+  "version": "0.9.3-dev.11",
   "description": "",
   "engines": {
     "node": ">=0.12.0"
diff --git a/packages/taler-util/package.json b/packages/taler-util/package.json
index a1af00355..4001d30a6 100644
--- a/packages/taler-util/package.json
+++ b/packages/taler-util/package.json
@@ -1,6 +1,6 @@
 {
   "name": "@gnu-taler/taler-util",
-  "version": "0.9.3-dev.10",
+  "version": "0.9.3-dev.11",
   "description": "Generic helper functionality for GNU Taler",
   "type": "module",
   "types": "./lib/index.node.d.ts",
diff --git a/packages/taler-util/src/wallet-types.ts 
b/packages/taler-util/src/wallet-types.ts
index 940251366..a761c5cff 100644
--- a/packages/taler-util/src/wallet-types.ts
+++ b/packages/taler-util/src/wallet-types.ts
@@ -1247,6 +1247,21 @@ export const codecForIntegrationTestArgs = (): 
Codec<IntegrationTestArgs> =>
     .property("bankAccessApiBaseUrl", codecOptional(codecForAmountString()))
     .build("IntegrationTestArgs");
 
+export interface IntegrationTestV2Args {
+  exchangeBaseUrl: string;
+  bankAccessApiBaseUrl: string;
+  merchantBaseUrl: string;
+  merchantAuthToken?: string;
+}
+
+export const codecForIntegrationTestV2Args = (): Codec<IntegrationTestV2Args> 
=>
+  buildCodecForObject<IntegrationTestV2Args>()
+    .property("exchangeBaseUrl", codecForString())
+    .property("merchantBaseUrl", codecForString())
+    .property("merchantAuthToken", codecOptional(codecForString()))
+    .property("bankAccessApiBaseUrl", codecForAmountString())
+    .build("IntegrationTestV2Args");
+
 export interface AddExchangeRequest {
   exchangeBaseUrl: string;
   forceUpdate?: boolean;
diff --git a/packages/taler-wallet-cli/package.json 
b/packages/taler-wallet-cli/package.json
index cb4660e1a..8d2766227 100644
--- a/packages/taler-wallet-cli/package.json
+++ b/packages/taler-wallet-cli/package.json
@@ -1,6 +1,6 @@
 {
   "name": "@gnu-taler/taler-wallet-cli",
-  "version": "0.9.3-dev.10",
+  "version": "0.9.3-dev.11",
   "description": "",
   "engines": {
     "node": ">=0.18.0"
diff --git a/packages/taler-wallet-core/package.json 
b/packages/taler-wallet-core/package.json
index 9751be476..f6abd43bb 100644
--- a/packages/taler-wallet-core/package.json
+++ b/packages/taler-wallet-core/package.json
@@ -1,6 +1,6 @@
 {
   "name": "@gnu-taler/taler-wallet-core",
-  "version": "0.9.3-dev.10",
+  "version": "0.9.3-dev.11",
   "description": "",
   "engines": {
     "node": ">=0.18.0"
diff --git a/packages/taler-wallet-core/src/operations/pay-peer.ts 
b/packages/taler-wallet-core/src/operations/pay-peer.ts
index ff0e15c00..92ec549dd 100644
--- a/packages/taler-wallet-core/src/operations/pay-peer.ts
+++ b/packages/taler-wallet-core/src/operations/pay-peer.ts
@@ -1000,7 +1000,7 @@ export async function processPeerPushCredit(
   };
 }
 
-export async function confirmPeerPushPayment(
+export async function confirmPeerPushCredit(
   ws: InternalWalletState,
   req: ConfirmPeerPushCreditRequest,
 ): Promise<AcceptPeerPushPaymentResponse> {
@@ -1119,7 +1119,7 @@ export async function processPeerPullDebit(
   };
 }
 
-export async function acceptIncomingPeerPullPayment(
+export async function confirmPeerPullDebit(
   ws: InternalWalletState,
   req: ConfirmPeerPullDebitRequest,
 ): Promise<AcceptPeerPullPaymentResponse> {
diff --git a/packages/taler-wallet-core/src/operations/testing.ts 
b/packages/taler-wallet-core/src/operations/testing.ts
index 873fac021..c1f129fcd 100644
--- a/packages/taler-wallet-core/src/operations/testing.ts
+++ b/packages/taler-wallet-core/src/operations/testing.ts
@@ -18,8 +18,11 @@
  * Imports.
  */
 import {
+  AbsoluteTime,
   base64FromArrayBuffer,
   ConfirmPayResultType,
+  Duration,
+  IntegrationTestV2Args,
   Logger,
   stringToBytes,
   TestPayResult,
@@ -46,6 +49,15 @@ import { applyRefund, confirmPay, preparePayForUri } from 
"./pay-merchant.js";
 import { getBalances } from "./balance.js";
 import { checkLogicInvariant } from "../util/invariants.js";
 import { acceptWithdrawalFromUri } from "./withdraw.js";
+import { updateExchangeFromUrl } from "./exchanges.js";
+import {
+  confirmPeerPullDebit,
+  confirmPeerPushCredit,
+  initiatePeerPullPayment,
+  initiatePeerPushPayment,
+  preparePeerPullDebit,
+  preparePeerPushCredit,
+} from "./pay-peer.js";
 
 const logger = new Logger("operations/testing.ts");
 
@@ -429,6 +441,146 @@ export async function runIntegrationTest(
   logger.trace("integration test: all done!");
 }
 
+export async function runIntegrationTest2(
+  ws: InternalWalletState,
+  args: IntegrationTestV2Args,
+): Promise<void> {
+  logger.info("running test with arguments", args);
+
+  const exchangeInfo = await updateExchangeFromUrl(ws, args.exchangeBaseUrl);
+
+  const currency = exchangeInfo.exchangeDetails.currency;
+
+  const amountToWithdraw = Amounts.parseOrThrow(`${currency}:10`);
+  const amountToSpend = Amounts.parseOrThrow(`${currency}:2`);
+
+  logger.info("withdrawing test balance");
+  await withdrawTestBalance(ws, {
+    amount: Amounts.stringify(amountToWithdraw),
+    bankBaseUrl: args.bankAccessApiBaseUrl /* FIXME: not necessary */,
+    bankAccessApiBaseUrl: args.bankAccessApiBaseUrl,
+    exchangeBaseUrl: args.exchangeBaseUrl,
+  });
+  await ws.runUntilDone();
+  logger.info("done withdrawing test balance");
+
+  const balance = await getBalances(ws);
+
+  logger.trace(JSON.stringify(balance, null, 2));
+
+  const myMerchant: MerchantBackendInfo = {
+    baseUrl: args.merchantBaseUrl,
+    authToken: args.merchantAuthToken,
+  };
+
+  await makePayment(
+    ws,
+    myMerchant,
+    Amounts.stringify(amountToSpend),
+    "hello world",
+  );
+
+  // Wait until the refresh is done
+  await ws.runUntilDone();
+
+  logger.trace("withdrawing test balance for refund");
+  const withdrawAmountTwo = Amounts.parseOrThrow(`${currency}:18`);
+  const spendAmountTwo = Amounts.parseOrThrow(`${currency}:7`);
+  const refundAmount = Amounts.parseOrThrow(`${currency}:6`);
+  const spendAmountThree = Amounts.parseOrThrow(`${currency}:3`);
+
+  await withdrawTestBalance(ws, {
+    amount: Amounts.stringify(withdrawAmountTwo),
+    bankBaseUrl: args.bankAccessApiBaseUrl /* FIXME: not necessary */,
+    bankAccessApiBaseUrl: args.bankAccessApiBaseUrl,
+    exchangeBaseUrl: args.exchangeBaseUrl,
+  });
+
+  // Wait until the withdraw is done
+  await ws.runUntilDone();
+
+  const { orderId: refundOrderId } = await makePayment(
+    ws,
+    myMerchant,
+    Amounts.stringify(spendAmountTwo),
+    "order that will be refunded",
+  );
+
+  const refundUri = await refund(
+    ws.http,
+    myMerchant,
+    refundOrderId,
+    "test refund",
+    Amounts.stringify(refundAmount),
+  );
+
+  logger.trace("refund URI", refundUri);
+
+  await applyRefund(ws, refundUri);
+
+  logger.trace("integration test: applied refund");
+
+  // Wait until the refund is done
+  await ws.runUntilDone();
+
+  logger.trace("integration test: making payment after refund");
+
+  await makePayment(
+    ws,
+    myMerchant,
+    Amounts.stringify(spendAmountThree),
+    "payment after refund",
+  );
+
+  logger.trace("integration test: make payment done");
+
+  await ws.runUntilDone();
+
+  const peerPushInit = await initiatePeerPushPayment(ws, {
+    partialContractTerms: {
+      amount: `${currency}:1`,
+      summary: "Payment Peer Push Test",
+      purse_expiration: AbsoluteTime.toTimestamp(
+        AbsoluteTime.addDuration(
+          AbsoluteTime.now(),
+          Duration.fromSpec({ hours: 1 }),
+        ),
+      ),
+    },
+  });
+
+  const peerPushCredit = await preparePeerPushCredit(ws, {
+    talerUri: peerPushInit.talerUri,
+  });
+
+  await confirmPeerPushCredit(ws, {
+    peerPushPaymentIncomingId: peerPushCredit.peerPushPaymentIncomingId,
+  });
+
+  const peerPullInit = await initiatePeerPullPayment(ws, {
+    partialContractTerms: {
+      amount: `${currency}:1`,
+      summary: "Payment Peer Pull Test",
+      purse_expiration: AbsoluteTime.toTimestamp(
+        AbsoluteTime.addDuration(
+          AbsoluteTime.now(),
+          Duration.fromSpec({ hours: 1 }),
+        ),
+      ),
+    },
+  });
+
+  const peerPullInc = await preparePeerPullDebit(ws, {
+    talerUri: peerPullInit.talerUri,
+  });
+
+  await confirmPeerPullDebit(ws, {
+    peerPullPaymentIncomingId: peerPullInc.peerPullPaymentIncomingId,
+  });
+
+  logger.trace("integration test: all done!");
+}
+
 export async function testPay(
   ws: InternalWalletState,
   args: TestPayArgs,
diff --git a/packages/taler-wallet-core/src/operations/transactions.ts 
b/packages/taler-wallet-core/src/operations/transactions.ts
index 34d76c5c2..133675aa1 100644
--- a/packages/taler-wallet-core/src/operations/transactions.ts
+++ b/packages/taler-wallet-core/src/operations/transactions.ts
@@ -24,6 +24,7 @@ import {
   constructPayPullUri,
   constructPayPushUri,
   ExtendedStatus,
+  j2s,
   Logger,
   OrderShortInfo,
   PaymentStatus,
@@ -1348,6 +1349,18 @@ export async function getTransactions(
       });
     });
 
+  // One-off checks, because of a bug where the wallet previously
+  // did not migrate the DB correctly and caused these amounts
+  // to be missing sometimes.
+  for (let tx of transactions) {
+    if (!tx.amountEffective) {
+      logger.warn(`missing amountEffective in ${j2s(tx)}`);
+    }
+    if (!tx.amountRaw) {
+      logger.warn(`missing amountRaw in ${j2s(tx)}`);
+    }
+  }
+
   const txPending = transactions.filter((x) => x.pending);
   const txNotPending = transactions.filter((x) => !x.pending);
 
diff --git a/packages/taler-wallet-core/src/wallet-api-types.ts 
b/packages/taler-wallet-core/src/wallet-api-types.ts
index 0b1968857..6f46fe8f2 100644
--- a/packages/taler-wallet-core/src/wallet-api-types.ts
+++ b/packages/taler-wallet-core/src/wallet-api-types.ts
@@ -132,6 +132,7 @@ export enum WalletApiOperation {
   PreparePayForTemplate = "preparePayForTemplate",
   GetContractTermsDetails = "getContractTermsDetails",
   RunIntegrationTest = "runIntegrationTest",
+  RunIntegrationTestV2 = "runIntegrationTestV2",
   TestCrypto = "testCrypto",
   TestPay = "testPay",
   AddExchange = "addExchange",
@@ -759,6 +760,16 @@ export type RunIntegrationTestOp = {
   response: EmptyObject;
 };
 
+/**
+ * Run a simple integration test on a test deployment
+ * of the exchange and merchant.
+ */
+export type RunIntegrationTestV2Op = {
+  op: WalletApiOperation.RunIntegrationTest;
+  request: IntegrationTestArgs;
+  response: EmptyObject;
+};
+
 /**
  * Test crypto worker.
  */
@@ -931,6 +942,7 @@ export type WalletOperations = {
   [WalletApiOperation.RemoveBackupProvider]: RemoveBackupProviderOp;
   [WalletApiOperation.GetBackupInfo]: GetBackupInfoOp;
   [WalletApiOperation.RunIntegrationTest]: RunIntegrationTestOp;
+  [WalletApiOperation.RunIntegrationTestV2]: RunIntegrationTestV2Op;
   [WalletApiOperation.TestCrypto]: TestCryptoOp;
   [WalletApiOperation.WithdrawTestBalance]: WithdrawTestBalanceOp;
   [WalletApiOperation.TestPay]: TestPayOp;
diff --git a/packages/taler-wallet-core/src/wallet.ts 
b/packages/taler-wallet-core/src/wallet.ts
index 363214e7b..348d2a834 100644
--- a/packages/taler-wallet-core/src/wallet.ts
+++ b/packages/taler-wallet-core/src/wallet.ts
@@ -112,6 +112,7 @@ import {
   validateIban,
   codecForValidateIbanRequest,
   ValidateIbanResponse,
+  codecForIntegrationTestV2Args,
 } from "@gnu-taler/taler-util";
 import { TalerCryptoInterface } from "./crypto/cryptoImplementation.js";
 import {
@@ -200,8 +201,8 @@ import {
   processPurchase,
 } from "./operations/pay-merchant.js";
 import {
-  acceptIncomingPeerPullPayment,
-  confirmPeerPushPayment,
+  confirmPeerPullDebit,
+  confirmPeerPushCredit,
   preparePeerPullDebit,
   preparePeerPushCredit,
   initiatePeerPullPayment,
@@ -226,6 +227,7 @@ import {
 } from "./operations/refresh.js";
 import {
   runIntegrationTest,
+  runIntegrationTest2,
   testPay,
   withdrawTestBalance,
 } from "./operations/testing.js";
@@ -1046,6 +1048,11 @@ async function dispatchRequestInternal<Op extends 
WalletApiOperation>(
       await runIntegrationTest(ws, req);
       return {};
     }
+    case WalletApiOperation.RunIntegrationTestV2: {
+      const req = codecForIntegrationTestV2Args().decode(payload);
+      await runIntegrationTest2(ws, req);
+      return {};
+    }
     case WalletApiOperation.ValidateIban: {
       const req = codecForValidateIbanRequest().decode(payload);
       const valRes = validateIban(req.iban);
@@ -1461,7 +1468,7 @@ async function dispatchRequestInternal<Op extends 
WalletApiOperation>(
     }
     case WalletApiOperation.ConfirmPeerPushCredit: {
       const req = codecForConfirmPeerPushPaymentRequest().decode(payload);
-      return await confirmPeerPushPayment(ws, req);
+      return await confirmPeerPushCredit(ws, req);
     }
     case WalletApiOperation.CheckPeerPullCredit: {
       const req = codecForPreparePeerPullPaymentRequest().decode(payload);
@@ -1477,7 +1484,7 @@ async function dispatchRequestInternal<Op extends 
WalletApiOperation>(
     }
     case WalletApiOperation.ConfirmPeerPullDebit: {
       const req = codecForAcceptPeerPullPaymentRequest().decode(payload);
-      return await acceptIncomingPeerPullPayment(ws, req);
+      return await confirmPeerPullDebit(ws, req);
     }
     case WalletApiOperation.ApplyDevExperiment: {
       const req = codecForApplyDevExperiment().decode(payload);
diff --git a/packages/taler-wallet-webextension/manifest-common.json 
b/packages/taler-wallet-webextension/manifest-common.json
index 6a4c6f314..d370663e6 100644
--- a/packages/taler-wallet-webextension/manifest-common.json
+++ b/packages/taler-wallet-webextension/manifest-common.json
@@ -2,8 +2,8 @@
   "name": "GNU Taler Wallet (git)",
   "description": "Privacy preserving and transparent payments",
   "author": "GNU Taler Developers",
-  "version": "0.9.3.10",
-  "version_name": "0.9.3-dev.10",
+  "version": "0.9.3.11",
+  "version_name": "0.9.3-dev.11",
   "icons": {
     "16": "static/img/taler-logo-16.png",
     "19": "static/img/taler-logo-19.png",
diff --git a/packages/taler-wallet-webextension/package.json 
b/packages/taler-wallet-webextension/package.json
index 2013da1a4..41940e10c 100644
--- a/packages/taler-wallet-webextension/package.json
+++ b/packages/taler-wallet-webextension/package.json
@@ -1,6 +1,6 @@
 {
   "name": "@gnu-taler/taler-wallet-webextension",
-  "version": "0.9.3-dev.5",
+  "version": "0.9.3-dev.11",
   "description": "GNU Taler Wallet browser extension",
   "main": "./build/index.js",
   "types": "./build/index.d.ts",
@@ -82,4 +82,4 @@
   "pogen": {
     "domain": "taler-wallet-webex"
   }
-}
+}
\ No newline at end of file
diff --git a/packages/web-util/package.json b/packages/web-util/package.json
index ac5ca26ae..3451bc0ad 100644
--- a/packages/web-util/package.json
+++ b/packages/web-util/package.json
@@ -1,6 +1,6 @@
 {
   "name": "@gnu-taler/web-util",
-  "version": "0.9.3-dev.5",
+  "version": "0.9.3-dev.11",
   "description": "Generic helper functionality for GNU Taler Web Apps",
   "type": "module",
   "types": "./lib/index.node.d.ts",
@@ -51,4 +51,4 @@
     "typescript": "^4.9.4",
     "ws": "7.4.5"
   }
-}
+}
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]