From ac8f116780a860c8f4acfdf5553bf90d76afe236 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Tue, 9 Aug 2022 15:00:45 +0200 Subject: implement peer to peer push payments --- packages/taler-util/src/taleruri.test.ts | 43 ++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'packages/taler-util/src/taleruri.test.ts') diff --git a/packages/taler-util/src/taleruri.test.ts b/packages/taler-util/src/taleruri.test.ts index 5bf7ad4ee..3ee243fb3 100644 --- a/packages/taler-util/src/taleruri.test.ts +++ b/packages/taler-util/src/taleruri.test.ts @@ -20,6 +20,8 @@ import { parseWithdrawUri, parseRefundUri, parseTipUri, + parsePayPushUri, + constructPayPushUri, } from "./taleruri.js"; test("taler pay url parsing: wrong scheme", (t) => { @@ -182,3 +184,44 @@ test("taler tip pickup uri with instance and prefix", (t) => { t.is(r1.merchantBaseUrl, "https://merchant.example.com/my/pfx/tipm/"); t.is(r1.merchantTipId, "tipid"); }); + +test("taler peer to peer push URI", (t) => { + const url1 = "taler://pay-push/exch.example.com/foo"; + const r1 = parsePayPushUri(url1); + if (!r1) { + t.fail(); + return; + } + t.is(r1.exchangeBaseUrl, "https://exch.example.com/"); + t.is(r1.contractPriv, "foo"); +}); + +test("taler peer to peer push URI (path)", (t) => { + const url1 = "taler://pay-push/exch.example.com:123/bla/foo"; + const r1 = parsePayPushUri(url1); + if (!r1) { + t.fail(); + return; + } + t.is(r1.exchangeBaseUrl, "https://exch.example.com:123/bla/"); + t.is(r1.contractPriv, "foo"); +}); + +test("taler peer to peer push URI (http)", (t) => { + const url1 = "taler+http://pay-push/exch.example.com:123/bla/foo"; + const r1 = parsePayPushUri(url1); + if (!r1) { + t.fail(); + return; + } + t.is(r1.exchangeBaseUrl, "http://exch.example.com:123/bla/"); + t.is(r1.contractPriv, "foo"); +}); + +test("taler peer to peer push URI (construction)", (t) => { + const url = constructPayPushUri({ + exchangeBaseUrl: "https://foo.example.com/bla/", + contractPriv: "123", + }); + t.deepEqual(url, "taler://pay-push/foo.example.com/bla/123"); +}); -- cgit v1.2.3