1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
/*
This file is part of GNU Taler
(C) 2019 GNUnet e.V.
(C) 2024 Taler Systems SA
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 <http://www.gnu.org/licenses/>
*/
import { userIdentifierDerive } from "@gnu-taler/anastasis-core/lib/crypto.js";
import { AmountString, j2s } from "@gnu-taler/taler-util";
import {
WalletApiOperation,
createNativeWalletHost2,
} from "@gnu-taler/taler-wallet-core";
export async function testWithGv() {
const w = await createNativeWalletHost2({});
await w.wallet.client.call(WalletApiOperation.InitWallet, {
config: {
features: {
allowHttp: true,
},
},
});
await w.wallet.client.call(WalletApiOperation.RunIntegrationTest, {
amountToSpend: "KUDOS:1" as AmountString,
amountToWithdraw: "KUDOS:3" as AmountString,
corebankApiBaseUrl: "https://bank.demo.taler.net/",
exchangeBaseUrl: "https://exchange.demo.taler.net/",
merchantBaseUrl: "https://backend.demo.taler.net/",
merchantAuthToken: "secret-token:sandbox",
});
await w.wallet.client.call(WalletApiOperation.TestingWaitTasksDone, {});
await w.wallet.client.call(WalletApiOperation.Shutdown, {});
}
export async function testWithFdold() {
const w = await createNativeWalletHost2({});
await w.wallet.client.call(WalletApiOperation.InitWallet, {
config: {
features: {
allowHttp: true,
},
},
});
await w.wallet.client.call(WalletApiOperation.RunIntegrationTest, {
amountToSpend: "TESTKUDOS:1" as AmountString,
amountToWithdraw: "TESTKUDOS:3" as AmountString,
corebankApiBaseUrl: "https://bank.taler.fdold.eu/",
exchangeBaseUrl: "https://exchange.taler.fdold.eu/",
merchantBaseUrl: "https://merchant.taler.fdold.eu/",
});
await w.wallet.client.call(WalletApiOperation.TestingWaitTasksDone, {});
await w.wallet.client.call(WalletApiOperation.Shutdown, {});
}
export async function testWithLocal(path: string) {
console.log("running local test");
const w = await createNativeWalletHost2({
persistentStoragePath: path ?? "walletdb.json",
});
console.log("created wallet");
await w.wallet.client.call(WalletApiOperation.InitWallet, {
config: {
features: {
allowHttp: true,
},
testing: {
skipDefaults: true,
},
},
});
console.log("initialized wallet");
await w.wallet.client.call(WalletApiOperation.RunIntegrationTest, {
amountToSpend: "TESTKUDOS:1" as AmountString,
amountToWithdraw: "TESTKUDOS:3" as AmountString,
corebankApiBaseUrl: "http://localhost:8082/taler-bank-access/",
exchangeBaseUrl: "http://localhost:8081/",
merchantBaseUrl: "http://localhost:8083/",
});
console.log("started integration test");
await w.wallet.client.call(WalletApiOperation.TestingWaitTasksDone, {});
console.log("done with task loop");
await w.wallet.client.call(WalletApiOperation.Shutdown, {});
console.log("DB stats:", j2s(w.getDbStats()));
}
export async function testArgon2id() {
const userIdVector = {
input_id_data: {
name: "Fleabag",
ssn: "AB123",
},
input_server_salt: "FZ48EFS7WS3R2ZR4V53A3GFFY4",
output_id:
"YS45R6CGJV84K1NN7T14ZBCPVTZ6H15XJSM1FV0R748MHPV82SM0126EBZKBAAGCR34Q9AFKPEW1HRT2Q9GQ5JRA3642AB571DKZS18",
};
if (
(await userIdentifierDerive(
userIdVector.input_id_data,
userIdVector.input_server_salt,
)) != userIdVector.output_id
) {
throw Error("argon2id is not working!");
}
console.log("argon2id is working!");
}
|