gnunet-svn
[Top][All Lists]
Advanced

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

[taler-wallet-core] branch master updated: TWG, payments reversal testin


From: gnunet
Subject: [taler-wallet-core] branch master updated: TWG, payments reversal testing.
Date: Mon, 15 Feb 2021 20:31:27 +0100

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

ms pushed a commit to branch master
in repository wallet-core.

The following commit(s) were added to refs/heads/master by this push:
     new d384bd5c TWG, payments reversal testing.
d384bd5c is described below

commit d384bd5c62198f1160119e60776350109a8ca7d3
Author: MS <ms@taler.net>
AuthorDate: Mon Feb 15 20:28:09 2021 +0100

    TWG, payments reversal testing.
    
    Up to the point where the payments to be reversed get
    created via the native Sandbox API, instead of the add-incoming
    API, that got recently removed from the Nexus implementation.
---
 .../src/integrationtests/helpers.ts                | 10 ++++
 .../src/integrationtests/libeufin.ts               | 60 +++++++++++++++++++---
 .../src/integrationtests/test-libeufin-refund.ts   | 14 ++++-
 3 files changed, 76 insertions(+), 8 deletions(-)

diff --git a/packages/taler-wallet-cli/src/integrationtests/helpers.ts 
b/packages/taler-wallet-cli/src/integrationtests/helpers.ts
index 0bd6750d..bca98375 100644
--- a/packages/taler-wallet-cli/src/integrationtests/helpers.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/helpers.ts
@@ -60,6 +60,16 @@ export interface SimpleTestEnvironment {
   wallet: WalletCli;
 }
 
+export function getRandomIban(countryCode: string): string {
+  return `${countryCode}715001051796${(Math.random() * 100000000)
+    .toString()
+    .substring(0, 8)}`;
+}
+
+export function getRandomString(): string {
+  return Math.random().toString(36).substring(2);
+}
+
 /**
  * Run a test case with a simple TESTKUDOS Taler environment, consisting
  * of one exchange, one bank and one merchant.
diff --git a/packages/taler-wallet-cli/src/integrationtests/libeufin.ts 
b/packages/taler-wallet-cli/src/integrationtests/libeufin.ts
index 1bced0be..9be1135a 100644
--- a/packages/taler-wallet-cli/src/integrationtests/libeufin.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/libeufin.ts
@@ -19,6 +19,7 @@
  */
 import axios from "axios";
 import { URL } from "@gnu-taler/taler-wallet-core";
+import { getRandomIban, getRandomString } from "./helpers";
 import {
   GlobalTestState,
   DbInfo,
@@ -113,6 +114,20 @@ export interface LibeufinPreparedPaymentDetails {
   nexusBankAccountName: string;
 }
 
+export interface LibeufinSandboxAddIncomingRequest {
+  creditorIban: string;
+  creditorBic: string;
+  creditorName: string;
+  debitorIban: string;
+  debitorBic: string;
+  debitorName: string;
+  subject: string;
+  amount: string;
+  currency: string;
+  uid: string;
+  direction: string;
+}
+
 export class LibeufinSandboxService implements LibeufinSandboxServiceInterface 
{
   static async create(
     gc: GlobalTestState,
@@ -221,6 +236,12 @@ export interface CreateEbicsSubscriberRequest {
   systemID?: string;
 }
 
+export interface TwgAddIncomingRequest {
+  amount: string;
+  reserve_pub: string;
+  debit_account: string;
+}
+
 interface CreateEbicsBankAccountRequest {
   subscriber: {
     hostID: string;
@@ -266,6 +287,7 @@ export class NexusUserBundle {
   twgReq: CreateTalerWireGatewayFacadeRequest;
   twgTransferPermission: PostNexusPermissionRequest;
   twgHistoryPermission: PostNexusPermissionRequest;
+  twgAddIncomingPermission: PostNexusPermissionRequest;
   localAccountName: string;
   remoteAccountName: string;
 
@@ -295,8 +317,8 @@ export class NexusUserBundle {
     this.twgTransferPermission = {
       action: "grant",
       permission: {
-        subjectType: `username-${salt}`,
-        subjectId: "twguser",
+        subjectId: `username-${salt}`,
+        subjectType: "user",
         resourceType: "facade",
         resourceId: `twg-${salt}`,
         permissionName: "facade.talerWireGateway.transfer",
@@ -305,8 +327,8 @@ export class NexusUserBundle {
     this.twgHistoryPermission = {
       action: "grant",
       permission: {
-        subjectType: `username-${salt}`,
-        subjectId: "twguser",
+        subjectId: `username-${salt}`,
+        subjectType: "user",
         resourceType: "facade",
         resourceId: `twg-${salt}`,
         permissionName: "facade.talerWireGateway.history",
@@ -327,9 +349,7 @@ export class SandboxUserBundle {
     this.ebicsBankAccount = {
       currency: "EUR",
       bic: "BELADEBEXXX",
-      iban: `DE715001051796${(Math.random() * 100000000)
-        .toString()
-        .substring(0, 8)}`,
+      iban: getRandomIban("DE"),
       label: `remote-account-${salt}`,
       name: `Taler Exchange: ${salt}`,
       subscriber: {
@@ -630,6 +650,32 @@ export namespace LibeufinSandboxApi {
     await axios.post(url.href, req);
   }
 
+  export async function bookPayment(
+    libeufinSandboxService: LibeufinSandboxServiceInterface,
+    creditorBundle: SandboxUserBundle,
+    debitorBundle: SandboxUserBundle,
+    subject: string,
+    amount: string,
+    currency: string,
+  ) {
+    let req: LibeufinSandboxAddIncomingRequest = {
+      creditorIban: creditorBundle.ebicsBankAccount.iban,
+      creditorBic: creditorBundle.ebicsBankAccount.bic,
+      creditorName: creditorBundle.ebicsBankAccount.name,
+      debitorIban: debitorBundle.ebicsBankAccount.iban,
+      debitorBic: debitorBundle.ebicsBankAccount.bic,
+      debitorName: debitorBundle.ebicsBankAccount.name,
+      subject: subject,
+      amount: amount,
+      currency: currency,
+      uid: getRandomString(),
+      direction: "CRDT",
+    };
+    const baseUrl = libeufinSandboxService.baseUrl;
+    let url = new URL("admin/payments", baseUrl);
+    await axios.post(url.href, req);
+  }
+
   export async function simulateIncomingTransaction(
     libeufinSandboxService: LibeufinSandboxServiceInterface,
     accountLabel: string,
diff --git 
a/packages/taler-wallet-cli/src/integrationtests/test-libeufin-refund.ts 
b/packages/taler-wallet-cli/src/integrationtests/test-libeufin-refund.ts
index 2d5103dc..2ceb8be0 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-libeufin-refund.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-libeufin-refund.ts
@@ -20,10 +20,13 @@
 import { CoreApiResponse } from "@gnu-taler/taler-wallet-core";
 import { CoinConfig, defaultCoinConfig } from "./denomStructures";
 import { GlobalTestState } from "./harness";
+import { getRandomIban } from "./helpers";
 import {
   SandboxUserBundle,
   NexusUserBundle,
   launchLibeufinServices,
+  LibeufinNexusApi,
+  LibeufinSandboxApi,
 } from "./libeufin";
 
 /**
@@ -41,9 +44,18 @@ export async function runLibeufinRefundTest(t: 
GlobalTestState) {
   );
   const user02sandbox = new SandboxUserBundle("02");
 
-  await launchLibeufinServices(
+  const libeufinServices = await launchLibeufinServices(
     t,
     [user01nexus, user02nexus],
     [user01sandbox, user02sandbox],
   );
+
+  await LibeufinSandboxApi.bookPayment(
+    libeufinServices.libeufinSandbox,
+    user02sandbox,
+    user01sandbox,
+    "not a public key",
+    "1",
+    "EUR",
+  );
 }

-- 
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]