-logging
This commit is contained in:
parent
5eb339b836
commit
06301efda3
@ -20,6 +20,7 @@
|
||||
import {
|
||||
Duration,
|
||||
j2s,
|
||||
Logger,
|
||||
NotificationType,
|
||||
TransactionMajorState,
|
||||
TransactionMinorState,
|
||||
@ -45,6 +46,8 @@ import { EnvOptions, SimpleTestEnvironmentNg } from "../harness/helpers.js";
|
||||
import * as http from "node:http";
|
||||
import { createPlatformHttpLib } from "@gnu-taler/taler-util/http";
|
||||
|
||||
const logger = new Logger("test-kyc.ts");
|
||||
|
||||
export async function createKycTestkudosEnvironment(
|
||||
t: GlobalTestState,
|
||||
coinConfig: CoinConfig[] = defaultCoinConfig.map((x) => x("TESTKUDOS")),
|
||||
@ -226,7 +229,7 @@ function splitInTwoAt(s: string, separator: string): [string, string] {
|
||||
async function runTestfakeKycService(): Promise<TestfakeKycService> {
|
||||
const server = http.createServer((req, res) => {
|
||||
const requestUrl = req.url!;
|
||||
console.log(`kyc: got ${req.method} request`, requestUrl);
|
||||
logger.info(`kyc: got ${req.method} request, ${requestUrl}`);
|
||||
|
||||
const [path, query] = splitInTwoAt(requestUrl, "?");
|
||||
|
||||
@ -254,7 +257,7 @@ async function runTestfakeKycService(): Promise<TestfakeKycService> {
|
||||
});
|
||||
|
||||
req.on("end", () => {
|
||||
console.log("login request body:", reqBody);
|
||||
logger.info("login request body:", reqBody);
|
||||
|
||||
res.writeHead(200, { "Content-Type": "application/json" });
|
||||
// Normally, the access_token would also include which user we're trying
|
||||
@ -267,7 +270,7 @@ async function runTestfakeKycService(): Promise<TestfakeKycService> {
|
||||
);
|
||||
});
|
||||
} else if (path === "/oauth/v2/info") {
|
||||
console.log("authorization header:", req.headers.authorization);
|
||||
logger.info("authorization header:", req.headers.authorization);
|
||||
res.writeHead(200, { "Content-Type": "application/json" });
|
||||
res.end(
|
||||
JSON.stringify({
|
||||
@ -352,11 +355,14 @@ export async function runKycTest(t: GlobalTestState) {
|
||||
|
||||
const kycNotif = await kycNotificationCond;
|
||||
|
||||
console.log("got kyc notification:", j2s(kycNotif));
|
||||
logger.info("got kyc notification:", j2s(kycNotif));
|
||||
|
||||
const txState = await walletClient.client.call(WalletApiOperation.GetTransactionById, {
|
||||
transactionId: withdrawalTxId
|
||||
});
|
||||
const txState = await walletClient.client.call(
|
||||
WalletApiOperation.GetTransactionById,
|
||||
{
|
||||
transactionId: withdrawalTxId,
|
||||
},
|
||||
);
|
||||
|
||||
t.assertDeepEqual(txState.type, TransactionType.Withdrawal);
|
||||
|
||||
@ -364,7 +370,7 @@ export async function runKycTest(t: GlobalTestState) {
|
||||
|
||||
t.assertTrue(!!kycUrl);
|
||||
|
||||
console.log(`kyc URL is ${kycUrl}`);
|
||||
logger.info(`kyc URL is ${kycUrl}`);
|
||||
|
||||
// We now simulate the user interacting with the KYC service,
|
||||
// which would usually done in the browser.
|
||||
@ -375,11 +381,13 @@ export async function runKycTest(t: GlobalTestState) {
|
||||
});
|
||||
const kycServerResp = await httpLib.fetch(kycUrl);
|
||||
const kycLoginResp = await kycServerResp.json();
|
||||
console.log("kyc server resp:", j2s(kycLoginResp));
|
||||
logger.info(`kyc server resp: ${j2s(kycLoginResp)}`);
|
||||
const kycProofUrl = kycLoginResp.redirect_uri;
|
||||
// We need to "visit" the KYC proof URL at least once to trigger the exchange
|
||||
// asking for the KYC status.
|
||||
const proofHttpResp = await httpLib.fetch(kycProofUrl);
|
||||
console.log("proof resp status", proofHttpResp.status);
|
||||
console.log("resp headers", proofHttpResp.headers.toJSON());
|
||||
logger.info(`proof resp status ${proofHttpResp.status}`);
|
||||
logger.info(`resp headers ${j2s(proofHttpResp.headers.toJSON())}`);
|
||||
|
||||
// Now that KYC is done, withdrawal should finally succeed.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user