From f3ff5a72257dda27cab555f8b8d921d45bfc3e4b Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Tue, 23 Aug 2022 11:29:45 +0200 Subject: peer-to-peer pull payments MVP p2p pull wip --- .../src/integrationtests/test-peer-to-peer-pull.ts | 70 ++++++++++++++++++++ .../src/integrationtests/test-peer-to-peer-push.ts | 75 ++++++++++++++++++++++ .../src/integrationtests/test-peer-to-peer.ts | 75 ---------------------- .../src/integrationtests/testrunner.ts | 6 +- 4 files changed, 149 insertions(+), 77 deletions(-) create mode 100644 packages/taler-wallet-cli/src/integrationtests/test-peer-to-peer-pull.ts create mode 100644 packages/taler-wallet-cli/src/integrationtests/test-peer-to-peer-push.ts delete mode 100644 packages/taler-wallet-cli/src/integrationtests/test-peer-to-peer.ts (limited to 'packages/taler-wallet-cli/src/integrationtests') diff --git a/packages/taler-wallet-cli/src/integrationtests/test-peer-to-peer-pull.ts b/packages/taler-wallet-cli/src/integrationtests/test-peer-to-peer-pull.ts new file mode 100644 index 000000000..e78bd5a29 --- /dev/null +++ b/packages/taler-wallet-cli/src/integrationtests/test-peer-to-peer-pull.ts @@ -0,0 +1,70 @@ +/* + This file is part of GNU Taler + (C) 2020 Taler Systems S.A. + + GNU Taler is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + GNU Taler; see the file COPYING. If not, see + */ + +/** + * Imports. + */ +import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; +import { GlobalTestState } from "../harness/harness.js"; +import { + createSimpleTestkudosEnvironment, + withdrawViaBank, +} from "../harness/helpers.js"; + +/** + * Run test for basic, bank-integrated withdrawal and payment. + */ +export async function runPeerToPeerPullTest(t: GlobalTestState) { + // Set up test environment + + const { wallet, bank, exchange, merchant } = + await createSimpleTestkudosEnvironment(t); + + // Withdraw digital cash into the wallet. + + await withdrawViaBank(t, { wallet, bank, exchange, amount: "TESTKUDOS:20" }); + + await wallet.runUntilDone(); + + const resp = await wallet.client.call( + WalletApiOperation.InitiatePeerPullPayment, + { + exchangeBaseUrl: exchange.baseUrl, + amount: "TESTKUDOS:5", + partialContractTerms: { + summary: "Hello World", + }, + }, + ); + + const checkResp = await wallet.client.call( + WalletApiOperation.CheckPeerPullPayment, + { + talerUri: resp.talerUri, + }, + ); + + const acceptResp = await wallet.client.call( + WalletApiOperation.AcceptPeerPullPayment, + { + peerPullPaymentIncomingId: checkResp.peerPullPaymentIncomingId, + }, + ); + + await wallet.runUntilDone(); +} + +runPeerToPeerPullTest.suites = ["wallet"]; diff --git a/packages/taler-wallet-cli/src/integrationtests/test-peer-to-peer-push.ts b/packages/taler-wallet-cli/src/integrationtests/test-peer-to-peer-push.ts new file mode 100644 index 000000000..11360f6e9 --- /dev/null +++ b/packages/taler-wallet-cli/src/integrationtests/test-peer-to-peer-push.ts @@ -0,0 +1,75 @@ +/* + This file is part of GNU Taler + (C) 2020 Taler Systems S.A. + + GNU Taler is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + GNU Taler; see the file COPYING. If not, see + */ + +/** + * Imports. + */ +import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; +import { GlobalTestState } from "../harness/harness.js"; +import { + createSimpleTestkudosEnvironment, + withdrawViaBank, +} from "../harness/helpers.js"; + +/** + * Run test for basic, bank-integrated withdrawal and payment. + */ +export async function runPeerToPeerPushTest(t: GlobalTestState) { + // Set up test environment + + const { wallet, bank, exchange, merchant } = + await createSimpleTestkudosEnvironment(t); + + // Withdraw digital cash into the wallet. + + await withdrawViaBank(t, { wallet, bank, exchange, amount: "TESTKUDOS:20" }); + + await wallet.runUntilDone(); + + const resp = await wallet.client.call( + WalletApiOperation.InitiatePeerPushPayment, + { + amount: "TESTKUDOS:5", + partialContractTerms: { + summary: "Hello World", + }, + }, + ); + + console.log(resp); + + const checkResp = await wallet.client.call( + WalletApiOperation.CheckPeerPushPayment, + { + talerUri: resp.talerUri, + }, + ); + + console.log(checkResp); + + const acceptResp = await wallet.client.call( + WalletApiOperation.AcceptPeerPushPayment, + { + peerPushPaymentIncomingId: checkResp.peerPushPaymentIncomingId, + }, + ); + + console.log(acceptResp); + + await wallet.runUntilDone(); +} + +runPeerToPeerPushTest.suites = ["wallet"]; diff --git a/packages/taler-wallet-cli/src/integrationtests/test-peer-to-peer.ts b/packages/taler-wallet-cli/src/integrationtests/test-peer-to-peer.ts deleted file mode 100644 index c22258bc8..000000000 --- a/packages/taler-wallet-cli/src/integrationtests/test-peer-to-peer.ts +++ /dev/null @@ -1,75 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2020 Taler Systems S.A. - - GNU Taler is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - GNU Taler; see the file COPYING. If not, see - */ - -/** - * Imports. - */ -import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; -import { GlobalTestState } from "../harness/harness.js"; -import { - createSimpleTestkudosEnvironment, - withdrawViaBank, -} from "../harness/helpers.js"; - -/** - * Run test for basic, bank-integrated withdrawal and payment. - */ -export async function runPeerToPeerTest(t: GlobalTestState) { - // Set up test environment - - const { wallet, bank, exchange, merchant } = - await createSimpleTestkudosEnvironment(t); - - // Withdraw digital cash into the wallet. - - await withdrawViaBank(t, { wallet, bank, exchange, amount: "TESTKUDOS:20" }); - - await wallet.runUntilDone(); - - const resp = await wallet.client.call( - WalletApiOperation.InitiatePeerPushPayment, - { - amount: "TESTKUDOS:5", - partialContractTerms: { - summary: "Hello World", - }, - }, - ); - - console.log(resp); - - const checkResp = await wallet.client.call( - WalletApiOperation.CheckPeerPushPayment, - { - talerUri: resp.talerUri, - }, - ); - - console.log(checkResp); - - const acceptResp = await wallet.client.call( - WalletApiOperation.AcceptPeerPushPayment, - { - peerPushPaymentIncomingId: checkResp.peerPushPaymentIncomingId, - }, - ); - - console.log(acceptResp); - - await wallet.runUntilDone(); -} - -runPeerToPeerTest.suites = ["wallet"]; diff --git a/packages/taler-wallet-cli/src/integrationtests/testrunner.ts b/packages/taler-wallet-cli/src/integrationtests/testrunner.ts index cafcce79e..88e67a8bb 100644 --- a/packages/taler-wallet-cli/src/integrationtests/testrunner.ts +++ b/packages/taler-wallet-cli/src/integrationtests/testrunner.ts @@ -73,7 +73,8 @@ import { runPaymentDemoTest } from "./test-payment-on-demo"; import { runPaymentTransientTest } from "./test-payment-transient"; import { runPaymentZeroTest } from "./test-payment-zero.js"; import { runPaywallFlowTest } from "./test-paywall-flow"; -import { runPeerToPeerTest } from "./test-peer-to-peer.js"; +import { runPeerToPeerPullTest } from "./test-peer-to-peer-pull.js"; +import { runPeerToPeerPushTest } from "./test-peer-to-peer-push.js"; import { runRefundTest } from "./test-refund"; import { runRefundAutoTest } from "./test-refund-auto"; import { runRefundGoneTest } from "./test-refund-gone"; @@ -154,7 +155,8 @@ const allTests: TestMainFunction[] = [ runPaymentZeroTest, runPayPaidTest, runPaywallFlowTest, - runPeerToPeerTest, + runPeerToPeerPushTest, + runPeerToPeerPullTest, runRefundAutoTest, runRefundGoneTest, runRefundIncrementalTest, -- cgit v1.2.3