harness: modernize some tests, temporarily disable revocation test
This commit is contained in:
parent
6cc3fb3d04
commit
3d6cff9c84
@ -19,13 +19,12 @@
|
|||||||
*/
|
*/
|
||||||
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
|
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
|
||||||
import { defaultCoinConfig } from "../harness/denomStructures.js";
|
import { defaultCoinConfig } from "../harness/denomStructures.js";
|
||||||
import { GlobalTestState, WalletCli } from "../harness/harness.js";
|
import { GlobalTestState } from "../harness/harness.js";
|
||||||
import {
|
import {
|
||||||
makeTestPayment,
|
|
||||||
createSimpleTestkudosEnvironmentV2,
|
createSimpleTestkudosEnvironmentV2,
|
||||||
withdrawViaBankV2,
|
|
||||||
makeTestPaymentV2,
|
|
||||||
createWalletDaemonWithClient,
|
createWalletDaemonWithClient,
|
||||||
|
makeTestPaymentV2,
|
||||||
|
withdrawViaBankV2,
|
||||||
} from "../harness/helpers.js";
|
} from "../harness/helpers.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -59,7 +58,7 @@ export async function runAgeRestrictionsMixedMerchantTest(t: GlobalTestState) {
|
|||||||
{
|
{
|
||||||
const walletClient = walletOne;
|
const walletClient = walletOne;
|
||||||
|
|
||||||
await withdrawViaBankV2(t, {
|
const wres = await withdrawViaBankV2(t, {
|
||||||
walletClient,
|
walletClient,
|
||||||
bank,
|
bank,
|
||||||
exchange,
|
exchange,
|
||||||
@ -67,6 +66,8 @@ export async function runAgeRestrictionsMixedMerchantTest(t: GlobalTestState) {
|
|||||||
restrictAge: 13,
|
restrictAge: 13,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await wres.withdrawalFinishedCond;
|
||||||
|
|
||||||
const order = {
|
const order = {
|
||||||
summary: "Buy me!",
|
summary: "Buy me!",
|
||||||
amount: "TESTKUDOS:5",
|
amount: "TESTKUDOS:5",
|
||||||
@ -82,7 +83,7 @@ export async function runAgeRestrictionsMixedMerchantTest(t: GlobalTestState) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
await withdrawViaBankV2(t, {
|
const wres = await withdrawViaBankV2(t, {
|
||||||
walletClient: walletTwo,
|
walletClient: walletTwo,
|
||||||
bank,
|
bank,
|
||||||
exchange,
|
exchange,
|
||||||
@ -90,6 +91,9 @@ export async function runAgeRestrictionsMixedMerchantTest(t: GlobalTestState) {
|
|||||||
restrictAge: 13,
|
restrictAge: 13,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
await wres.withdrawalFinishedCond;
|
||||||
|
|
||||||
const order = {
|
const order = {
|
||||||
summary: "Buy me!",
|
summary: "Buy me!",
|
||||||
amount: "TESTKUDOS:5",
|
amount: "TESTKUDOS:5",
|
||||||
@ -101,13 +105,16 @@ export async function runAgeRestrictionsMixedMerchantTest(t: GlobalTestState) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
await withdrawViaBankV2(t, {
|
const wres = await withdrawViaBankV2(t, {
|
||||||
walletClient: walletThree,
|
walletClient: walletThree,
|
||||||
bank,
|
bank,
|
||||||
exchange,
|
exchange,
|
||||||
amount: "TESTKUDOS:20",
|
amount: "TESTKUDOS:20",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
await wres.withdrawalFinishedCond;
|
||||||
|
|
||||||
const order = {
|
const order = {
|
||||||
summary: "Buy me!",
|
summary: "Buy me!",
|
||||||
amount: "TESTKUDOS:5",
|
amount: "TESTKUDOS:5",
|
||||||
|
@ -18,12 +18,10 @@
|
|||||||
* Imports.
|
* Imports.
|
||||||
*/
|
*/
|
||||||
import { PreparePayResultType, TalerErrorCode } from "@gnu-taler/taler-util";
|
import { PreparePayResultType, TalerErrorCode } from "@gnu-taler/taler-util";
|
||||||
import { Wallet, WalletApiOperation } from "@gnu-taler/taler-wallet-core";
|
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
|
||||||
import { GlobalTestState, MerchantPrivateApi } from "../harness/harness.js";
|
import { GlobalTestState, MerchantPrivateApi } from "../harness/harness.js";
|
||||||
import {
|
import {
|
||||||
createSimpleTestkudosEnvironment,
|
|
||||||
createSimpleTestkudosEnvironmentV2,
|
createSimpleTestkudosEnvironmentV2,
|
||||||
withdrawViaBank,
|
|
||||||
withdrawViaBankV2,
|
withdrawViaBankV2,
|
||||||
} from "../harness/helpers.js";
|
} from "../harness/helpers.js";
|
||||||
|
|
||||||
@ -35,7 +33,14 @@ export async function runDenomUnofferedTest(t: GlobalTestState) {
|
|||||||
|
|
||||||
// Withdraw digital cash into the wallet.
|
// Withdraw digital cash into the wallet.
|
||||||
|
|
||||||
await withdrawViaBankV2(t, { walletClient, bank, exchange, amount: "TESTKUDOS:20" });
|
const wres = await withdrawViaBankV2(t, {
|
||||||
|
walletClient,
|
||||||
|
bank,
|
||||||
|
exchange,
|
||||||
|
amount: "TESTKUDOS:20",
|
||||||
|
});
|
||||||
|
|
||||||
|
await wres.withdrawalFinishedCond;
|
||||||
|
|
||||||
// Make the exchange forget the denomination.
|
// Make the exchange forget the denomination.
|
||||||
// Effectively we completely reset the exchange,
|
// Effectively we completely reset the exchange,
|
||||||
@ -108,7 +113,12 @@ export async function runDenomUnofferedTest(t: GlobalTestState) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Now withdrawal should work again.
|
// Now withdrawal should work again.
|
||||||
await withdrawViaBankV2(t, { walletClient, bank, exchange, amount: "TESTKUDOS:20" });
|
await withdrawViaBankV2(t, {
|
||||||
|
walletClient,
|
||||||
|
bank,
|
||||||
|
exchange,
|
||||||
|
amount: "TESTKUDOS:20",
|
||||||
|
});
|
||||||
|
|
||||||
await walletClient.call(WalletApiOperation.TestingWaitTransactionsFinal, {});
|
await walletClient.call(WalletApiOperation.TestingWaitTransactionsFinal, {});
|
||||||
|
|
||||||
|
@ -19,18 +19,18 @@
|
|||||||
*/
|
*/
|
||||||
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
|
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
|
||||||
import {
|
import {
|
||||||
GlobalTestState,
|
|
||||||
BankService,
|
BankService,
|
||||||
ExchangeService,
|
ExchangeService,
|
||||||
|
GlobalTestState,
|
||||||
MerchantService,
|
MerchantService,
|
||||||
setupDb,
|
|
||||||
WalletCli,
|
|
||||||
getPayto,
|
getPayto,
|
||||||
|
setupDb,
|
||||||
} from "../harness/harness.js";
|
} from "../harness/harness.js";
|
||||||
import {
|
import {
|
||||||
withdrawViaBank,
|
SimpleTestEnvironmentNg,
|
||||||
makeTestPayment,
|
createWalletDaemonWithClient,
|
||||||
SimpleTestEnvironment,
|
makeTestPaymentV2,
|
||||||
|
withdrawViaBankV2,
|
||||||
} from "../harness/helpers.js";
|
} from "../harness/helpers.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -39,7 +39,7 @@ import {
|
|||||||
*/
|
*/
|
||||||
export async function createMyTestkudosEnvironment(
|
export async function createMyTestkudosEnvironment(
|
||||||
t: GlobalTestState,
|
t: GlobalTestState,
|
||||||
): Promise<SimpleTestEnvironment> {
|
): Promise<SimpleTestEnvironmentNg> {
|
||||||
const db = await setupDb(t);
|
const db = await setupDb(t);
|
||||||
|
|
||||||
const bank = await BankService.create(t, {
|
const bank = await BankService.create(t, {
|
||||||
@ -147,13 +147,19 @@ export async function createMyTestkudosEnvironment(
|
|||||||
|
|
||||||
console.log("setup done!");
|
console.log("setup done!");
|
||||||
|
|
||||||
const wallet = new WalletCli(t);
|
const { walletClient, walletService } = await createWalletDaemonWithClient(
|
||||||
|
t,
|
||||||
|
{
|
||||||
|
name: "w1",
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
commonDb: db,
|
commonDb: db,
|
||||||
exchange,
|
exchange,
|
||||||
merchant,
|
merchant,
|
||||||
wallet,
|
walletClient,
|
||||||
|
walletService,
|
||||||
bank,
|
bank,
|
||||||
exchangeBankAccount,
|
exchangeBankAccount,
|
||||||
};
|
};
|
||||||
@ -165,19 +171,21 @@ export async function createMyTestkudosEnvironment(
|
|||||||
export async function runFeeRegressionTest(t: GlobalTestState) {
|
export async function runFeeRegressionTest(t: GlobalTestState) {
|
||||||
// Set up test environment
|
// Set up test environment
|
||||||
|
|
||||||
const { wallet, bank, exchange, merchant } =
|
const { walletClient, bank, exchange, merchant } =
|
||||||
await createMyTestkudosEnvironment(t);
|
await createMyTestkudosEnvironment(t);
|
||||||
|
|
||||||
// Withdraw digital cash into the wallet.
|
// Withdraw digital cash into the wallet.
|
||||||
|
|
||||||
await withdrawViaBank(t, {
|
const wres = await withdrawViaBankV2(t, {
|
||||||
wallet,
|
walletClient,
|
||||||
bank,
|
bank,
|
||||||
exchange,
|
exchange,
|
||||||
amount: "TESTKUDOS:1.92",
|
amount: "TESTKUDOS:1.92",
|
||||||
});
|
});
|
||||||
|
|
||||||
const coins = await wallet.client.call(WalletApiOperation.DumpCoins, {});
|
await wres.withdrawalFinishedCond;
|
||||||
|
|
||||||
|
const coins = await walletClient.call(WalletApiOperation.DumpCoins, {});
|
||||||
|
|
||||||
// Make sure we really withdraw one 0.64 and one 1.28 coin.
|
// Make sure we really withdraw one 0.64 and one 1.28 coin.
|
||||||
t.assertTrue(coins.coins.length === 2);
|
t.assertTrue(coins.coins.length === 2);
|
||||||
@ -188,11 +196,11 @@ export async function runFeeRegressionTest(t: GlobalTestState) {
|
|||||||
fulfillment_url: "taler://fulfillment-success/thx",
|
fulfillment_url: "taler://fulfillment-success/thx",
|
||||||
};
|
};
|
||||||
|
|
||||||
await makeTestPayment(t, { wallet, merchant, order });
|
await makeTestPaymentV2(t, { walletClient, merchant, order });
|
||||||
|
|
||||||
await wallet.runUntilDone();
|
await walletClient.call(WalletApiOperation.TestingWaitTransactionsFinal, {});
|
||||||
|
|
||||||
const txs = await wallet.client.call(WalletApiOperation.GetTransactions, {});
|
const txs = await walletClient.call(WalletApiOperation.GetTransactions, {});
|
||||||
t.assertAmountEquals(txs.transactions[1].amountEffective, "TESTKUDOS:1.30");
|
t.assertAmountEquals(txs.transactions[1].amountEffective, "TESTKUDOS:1.30");
|
||||||
console.log(txs);
|
console.log(txs);
|
||||||
}
|
}
|
||||||
|
@ -43,13 +43,15 @@ export async function runMerchantLongpollingTest(t: GlobalTestState) {
|
|||||||
|
|
||||||
// Withdraw digital cash into the wallet.
|
// Withdraw digital cash into the wallet.
|
||||||
|
|
||||||
await withdrawViaBankV2(t, {
|
const wres = await withdrawViaBankV2(t, {
|
||||||
walletClient,
|
walletClient,
|
||||||
bank,
|
bank,
|
||||||
exchange,
|
exchange,
|
||||||
amount: "TESTKUDOS:20",
|
amount: "TESTKUDOS:20",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await wres.withdrawalFinishedCond;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* =========================================================================
|
* =========================================================================
|
||||||
* Create an order and let the wallet pay under a session ID
|
* Create an order and let the wallet pay under a session ID
|
||||||
|
@ -36,13 +36,15 @@ export async function runPaymentForgettableTest(t: GlobalTestState) {
|
|||||||
|
|
||||||
// Withdraw digital cash into the wallet.
|
// Withdraw digital cash into the wallet.
|
||||||
|
|
||||||
await withdrawViaBankV2(t, {
|
const wres = await withdrawViaBankV2(t, {
|
||||||
walletClient,
|
walletClient,
|
||||||
bank,
|
bank,
|
||||||
exchange,
|
exchange,
|
||||||
amount: "TESTKUDOS:20",
|
amount: "TESTKUDOS:20",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await wres.withdrawalFinishedCond;
|
||||||
|
|
||||||
{
|
{
|
||||||
const order = {
|
const order = {
|
||||||
summary: "Buy me!",
|
summary: "Buy me!",
|
||||||
|
@ -24,10 +24,17 @@ import {
|
|||||||
ConfirmPayResultType,
|
ConfirmPayResultType,
|
||||||
URL,
|
URL,
|
||||||
} from "@gnu-taler/taler-util";
|
} from "@gnu-taler/taler-util";
|
||||||
import axiosImp from "axios";
|
|
||||||
const axios = axiosImp.default;
|
|
||||||
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
|
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
|
||||||
import { createSimpleTestkudosEnvironmentV2, withdrawViaBankV2 } from "../harness/helpers.js";
|
import {
|
||||||
|
createSimpleTestkudosEnvironmentV2,
|
||||||
|
withdrawViaBankV2,
|
||||||
|
} from "../harness/helpers.js";
|
||||||
|
import { createPlatformHttpLib } from "@gnu-taler/taler-util/http";
|
||||||
|
|
||||||
|
const httpLib = createPlatformHttpLib({
|
||||||
|
allowHttp: true,
|
||||||
|
enableThrottling: false,
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run test for basic, bank-integrated withdrawal.
|
* Run test for basic, bank-integrated withdrawal.
|
||||||
@ -40,7 +47,12 @@ export async function runPaywallFlowTest(t: GlobalTestState) {
|
|||||||
|
|
||||||
// Withdraw digital cash into the wallet.
|
// Withdraw digital cash into the wallet.
|
||||||
|
|
||||||
await withdrawViaBankV2(t, { walletClient, bank, exchange, amount: "TESTKUDOS:20" });
|
await withdrawViaBankV2(t, {
|
||||||
|
walletClient,
|
||||||
|
bank,
|
||||||
|
exchange,
|
||||||
|
amount: "TESTKUDOS:20",
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* =========================================================================
|
* =========================================================================
|
||||||
@ -74,9 +86,7 @@ export async function runPaywallFlowTest(t: GlobalTestState) {
|
|||||||
t.assertTrue(orderStatus.already_paid_order_id === undefined);
|
t.assertTrue(orderStatus.already_paid_order_id === undefined);
|
||||||
let publicOrderStatusUrl = new URL(orderStatus.order_status_url);
|
let publicOrderStatusUrl = new URL(orderStatus.order_status_url);
|
||||||
|
|
||||||
let publicOrderStatusResp = await axios.get(publicOrderStatusUrl.href, {
|
let publicOrderStatusResp = await httpLib.fetch(publicOrderStatusUrl.href);
|
||||||
validateStatus: () => true,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (publicOrderStatusResp.status != 402) {
|
if (publicOrderStatusResp.status != 402) {
|
||||||
throw Error(
|
throw Error(
|
||||||
@ -85,7 +95,7 @@ export async function runPaywallFlowTest(t: GlobalTestState) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let pubUnpaidStatus = codecForMerchantOrderStatusUnpaid().decode(
|
let pubUnpaidStatus = codecForMerchantOrderStatusUnpaid().decode(
|
||||||
publicOrderStatusResp.data,
|
publicOrderStatusResp.json(),
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log(pubUnpaidStatus);
|
console.log(pubUnpaidStatus);
|
||||||
@ -102,10 +112,8 @@ export async function runPaywallFlowTest(t: GlobalTestState) {
|
|||||||
const proposalId = preparePayResp.proposalId;
|
const proposalId = preparePayResp.proposalId;
|
||||||
|
|
||||||
console.log("requesting", publicOrderStatusUrl.href);
|
console.log("requesting", publicOrderStatusUrl.href);
|
||||||
publicOrderStatusResp = await axios.get(publicOrderStatusUrl.href, {
|
publicOrderStatusResp = await httpLib.fetch(publicOrderStatusUrl.href);
|
||||||
validateStatus: () => true,
|
console.log("response body", publicOrderStatusResp.json());
|
||||||
});
|
|
||||||
console.log("response body", publicOrderStatusResp.data);
|
|
||||||
if (publicOrderStatusResp.status != 402) {
|
if (publicOrderStatusResp.status != 402) {
|
||||||
throw Error(
|
throw Error(
|
||||||
`expected status 402 (after claiming), but got ${publicOrderStatusResp.status}`,
|
`expected status 402 (after claiming), but got ${publicOrderStatusResp.status}`,
|
||||||
@ -113,26 +121,20 @@ export async function runPaywallFlowTest(t: GlobalTestState) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pubUnpaidStatus = codecForMerchantOrderStatusUnpaid().decode(
|
pubUnpaidStatus = codecForMerchantOrderStatusUnpaid().decode(
|
||||||
publicOrderStatusResp.data,
|
publicOrderStatusResp.json(),
|
||||||
);
|
);
|
||||||
|
|
||||||
const confirmPayRes = await walletClient.call(
|
const confirmPayRes = await walletClient.call(WalletApiOperation.ConfirmPay, {
|
||||||
WalletApiOperation.ConfirmPay,
|
proposalId: proposalId,
|
||||||
{
|
|
||||||
proposalId: proposalId,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
t.assertTrue(confirmPayRes.type === ConfirmPayResultType.Done);
|
|
||||||
|
|
||||||
publicOrderStatusResp = await axios.get(publicOrderStatusUrl.href, {
|
|
||||||
validateStatus: () => true,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(publicOrderStatusResp.data);
|
t.assertTrue(confirmPayRes.type === ConfirmPayResultType.Done);
|
||||||
|
publicOrderStatusResp = await httpLib.fetch(publicOrderStatusUrl.href);
|
||||||
|
|
||||||
|
console.log(publicOrderStatusResp.json());
|
||||||
|
|
||||||
if (publicOrderStatusResp.status != 200) {
|
if (publicOrderStatusResp.status != 200) {
|
||||||
console.log(publicOrderStatusResp.data);
|
console.log(publicOrderStatusResp.json());
|
||||||
throw Error(
|
throw Error(
|
||||||
`expected status 200 (after paying), but got ${publicOrderStatusResp.status}`,
|
`expected status 200 (after paying), but got ${publicOrderStatusResp.status}`,
|
||||||
);
|
);
|
||||||
@ -229,19 +231,17 @@ export async function runPaywallFlowTest(t: GlobalTestState) {
|
|||||||
console.log("requesting public status", publicOrderStatusUrl);
|
console.log("requesting public status", publicOrderStatusUrl);
|
||||||
|
|
||||||
// Ask the order status of the claimed-but-unpaid order
|
// Ask the order status of the claimed-but-unpaid order
|
||||||
publicOrderStatusResp = await axios.get(publicOrderStatusUrl.href, {
|
publicOrderStatusResp = await httpLib.fetch(publicOrderStatusUrl.href);
|
||||||
validateStatus: () => true,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (publicOrderStatusResp.status != 402) {
|
if (publicOrderStatusResp.status != 402) {
|
||||||
throw Error(`expected status 402, but got ${publicOrderStatusResp.status}`);
|
throw Error(`expected status 402, but got ${publicOrderStatusResp.status}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
pubUnpaidStatus = codecForMerchantOrderStatusUnpaid().decode(
|
pubUnpaidStatus = codecForMerchantOrderStatusUnpaid().decode(
|
||||||
publicOrderStatusResp.data,
|
publicOrderStatusResp.json(),
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log(publicOrderStatusResp.data);
|
console.log(publicOrderStatusResp.json());
|
||||||
|
|
||||||
t.assertTrue(pubUnpaidStatus.already_paid_order_id === firstOrderId);
|
t.assertTrue(pubUnpaidStatus.already_paid_order_id === firstOrderId);
|
||||||
}
|
}
|
||||||
|
@ -213,3 +213,4 @@ export async function runRevocationTest(t: GlobalTestState) {
|
|||||||
|
|
||||||
runRevocationTest.timeoutMs = 120000;
|
runRevocationTest.timeoutMs = 120000;
|
||||||
runRevocationTest.suites = ["wallet"];
|
runRevocationTest.suites = ["wallet"];
|
||||||
|
runRevocationTest.excludeByDefault = true;
|
10
packages/taler-harness/src/sandcastle-config.ts
Normal file
10
packages/taler-harness/src/sandcastle-config.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
// Work in progress.
|
||||||
|
// TS-based schema for the sandcastle configuration.
|
||||||
|
|
||||||
|
export interface SandcastleConfig {
|
||||||
|
currency: string;
|
||||||
|
merchant: {
|
||||||
|
apiKey: string;
|
||||||
|
baseUrl: string;
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user