-fix test-exchange-deposit
This commit is contained in:
parent
15a1b8d096
commit
321252040e
@ -17,7 +17,11 @@
|
|||||||
/**
|
/**
|
||||||
* Imports.
|
* Imports.
|
||||||
*/
|
*/
|
||||||
import { BankApi, WalletApiOperation } from "@gnu-taler/taler-wallet-core";
|
import {
|
||||||
|
BankApi,
|
||||||
|
WalletApiOperation,
|
||||||
|
WireGatewayApiClient,
|
||||||
|
} from "@gnu-taler/taler-wallet-core";
|
||||||
import { defaultCoinConfig } from "../harness/denomStructures.js";
|
import { defaultCoinConfig } from "../harness/denomStructures.js";
|
||||||
import {
|
import {
|
||||||
getWireMethodForTest,
|
getWireMethodForTest,
|
||||||
@ -158,10 +162,15 @@ export async function runAgeRestrictionsMerchantTest(t: GlobalTestState) {
|
|||||||
exchangeBankAccount.accountPaytoUri,
|
exchangeBankAccount.accountPaytoUri,
|
||||||
);
|
);
|
||||||
|
|
||||||
await BankApi.adminAddIncoming(bank, {
|
const wireGatewayApiClient = new WireGatewayApiClient({
|
||||||
|
wireGatewayApiBaseUrl: exchangeBankAccount.wireGatewayApiBaseUrl,
|
||||||
|
accountName: exchangeBankAccount.accountName,
|
||||||
|
accountPassword: exchangeBankAccount.accountPassword,
|
||||||
|
});
|
||||||
|
|
||||||
|
await wireGatewayApiClient.adminAddIncoming({
|
||||||
amount: "TESTKUDOS:10",
|
amount: "TESTKUDOS:10",
|
||||||
debitAccountPayto: mbu.accountPaytoUri,
|
debitAccountPayto: mbu.accountPaytoUri,
|
||||||
exchangeBankAccount,
|
|
||||||
reservePub: tipReserveResp.reserve_pub,
|
reservePub: tipReserveResp.reserve_pub,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@ import {
|
|||||||
BankApi,
|
BankApi,
|
||||||
BankAccessApi,
|
BankAccessApi,
|
||||||
CreditDebitIndicator,
|
CreditDebitIndicator,
|
||||||
|
WireGatewayApiClient,
|
||||||
} from "@gnu-taler/taler-wallet-core";
|
} from "@gnu-taler/taler-wallet-core";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -121,10 +122,15 @@ export async function runBankApiTest(t: GlobalTestState) {
|
|||||||
|
|
||||||
const res = createEddsaKeyPair();
|
const res = createEddsaKeyPair();
|
||||||
|
|
||||||
await BankApi.adminAddIncoming(bank, {
|
const wireGatewayApiClient = new WireGatewayApiClient({
|
||||||
|
wireGatewayApiBaseUrl: exchangeBankAccount.wireGatewayApiBaseUrl,
|
||||||
|
accountName: exchangeBankAccount.accountName,
|
||||||
|
accountPassword: exchangeBankAccount.accountPassword,
|
||||||
|
});
|
||||||
|
|
||||||
|
await wireGatewayApiClient.adminAddIncoming({
|
||||||
amount: "TESTKUDOS:115",
|
amount: "TESTKUDOS:115",
|
||||||
debitAccountPayto: bankUser.accountPaytoUri,
|
debitAccountPayto: bankUser.accountPaytoUri,
|
||||||
exchangeBankAccount: exchangeBankAccount,
|
|
||||||
reservePub: encodeCrock(res.eddsaPub),
|
reservePub: encodeCrock(res.eddsaPub),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -59,14 +59,13 @@ export async function runExchangeDepositTest(t: GlobalTestState) {
|
|||||||
|
|
||||||
const reserveKeyPair = await cryptoApi.createEddsaKeypair({});
|
const reserveKeyPair = await cryptoApi.createEddsaKeypair({});
|
||||||
|
|
||||||
await topupReserveWithDemobank(
|
await topupReserveWithDemobank({
|
||||||
http,
|
http,
|
||||||
reserveKeyPair.pub,
|
amount: "TESTKUDOS:10",
|
||||||
bank.baseUrl,
|
bankAccessApiBaseUrl: bank.bankAccessApiBaseUrl,
|
||||||
bank.bankAccessApiBaseUrl,
|
|
||||||
exchangeInfo,
|
exchangeInfo,
|
||||||
"TESTKUDOS:10",
|
reservePub: reserveKeyPair.pub,
|
||||||
);
|
});
|
||||||
|
|
||||||
await exchange.runWirewatchOnce();
|
await exchange.runWirewatchOnce();
|
||||||
|
|
||||||
@ -126,7 +125,7 @@ export async function runExchangeDepositTest(t: GlobalTestState) {
|
|||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e instanceof TalerError && e.errorDetail.code === 7005) {
|
if (e instanceof TalerError && e.errorDetail.code === 7005) {
|
||||||
if (e.errorDetail.httpStatusCode === 400) {
|
if (e.errorDetail.httpStatusCode === 409) {
|
||||||
console.log("got expected error response from exchange");
|
console.log("got expected error response from exchange");
|
||||||
console.log(e);
|
console.log(e);
|
||||||
console.log(j2s(e.errorDetail));
|
console.log(j2s(e.errorDetail));
|
||||||
|
@ -17,7 +17,11 @@
|
|||||||
/**
|
/**
|
||||||
* Imports.
|
* Imports.
|
||||||
*/
|
*/
|
||||||
import { WalletApiOperation, BankApi } from "@gnu-taler/taler-wallet-core";
|
import {
|
||||||
|
WalletApiOperation,
|
||||||
|
BankApi,
|
||||||
|
WireGatewayApiClient,
|
||||||
|
} from "@gnu-taler/taler-wallet-core";
|
||||||
import {
|
import {
|
||||||
GlobalTestState,
|
GlobalTestState,
|
||||||
MerchantPrivateApi,
|
MerchantPrivateApi,
|
||||||
@ -53,10 +57,15 @@ export async function runTippingTest(t: GlobalTestState) {
|
|||||||
exchangeBankAccount.accountPaytoUri,
|
exchangeBankAccount.accountPaytoUri,
|
||||||
);
|
);
|
||||||
|
|
||||||
await BankApi.adminAddIncoming(bank, {
|
const wireGatewayApiClient = new WireGatewayApiClient({
|
||||||
|
wireGatewayApiBaseUrl: exchangeBankAccount.wireGatewayApiBaseUrl,
|
||||||
|
accountName: exchangeBankAccount.accountName,
|
||||||
|
accountPassword: exchangeBankAccount.accountPassword,
|
||||||
|
});
|
||||||
|
|
||||||
|
await wireGatewayApiClient.adminAddIncoming({
|
||||||
amount: "TESTKUDOS:10",
|
amount: "TESTKUDOS:10",
|
||||||
debitAccountPayto: mbu.accountPaytoUri,
|
debitAccountPayto: mbu.accountPaytoUri,
|
||||||
exchangeBankAccount,
|
|
||||||
reservePub: tipReserveResp.reserve_pub,
|
reservePub: tipReserveResp.reserve_pub,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -19,7 +19,11 @@
|
|||||||
*/
|
*/
|
||||||
import { GlobalTestState } from "../harness/harness.js";
|
import { GlobalTestState } from "../harness/harness.js";
|
||||||
import { createSimpleTestkudosEnvironment } from "../harness/helpers.js";
|
import { createSimpleTestkudosEnvironment } from "../harness/helpers.js";
|
||||||
import { WalletApiOperation, BankApi } from "@gnu-taler/taler-wallet-core";
|
import {
|
||||||
|
WalletApiOperation,
|
||||||
|
BankApi,
|
||||||
|
WireGatewayApiClient,
|
||||||
|
} from "@gnu-taler/taler-wallet-core";
|
||||||
import { AbsoluteTime, j2s, Logger } from "@gnu-taler/taler-util";
|
import { AbsoluteTime, j2s, Logger } from "@gnu-taler/taler-util";
|
||||||
|
|
||||||
const logger = new Logger("test-withdrawal-manual.ts");
|
const logger = new Logger("test-withdrawal-manual.ts");
|
||||||
@ -65,8 +69,13 @@ export async function runWithdrawalManualTest(t: GlobalTestState) {
|
|||||||
|
|
||||||
const reservePub: string = wres.reservePub;
|
const reservePub: string = wres.reservePub;
|
||||||
|
|
||||||
await BankApi.adminAddIncoming(bank, {
|
const wireGatewayApiClient = new WireGatewayApiClient({
|
||||||
exchangeBankAccount,
|
wireGatewayApiBaseUrl: exchangeBankAccount.wireGatewayApiBaseUrl,
|
||||||
|
accountName: exchangeBankAccount.accountName,
|
||||||
|
accountPassword: exchangeBankAccount.accountPassword,
|
||||||
|
});
|
||||||
|
|
||||||
|
await wireGatewayApiClient.adminAddIncoming({
|
||||||
amount: "TESTKUDOS:10",
|
amount: "TESTKUDOS:10",
|
||||||
debitAccountPayto: user.accountPaytoUri,
|
debitAccountPayto: user.accountPaytoUri,
|
||||||
reservePub: reservePub,
|
reservePub: reservePub,
|
||||||
|
@ -37,6 +37,7 @@ import {
|
|||||||
TalerErrorCode,
|
TalerErrorCode,
|
||||||
} from "@gnu-taler/taler-util";
|
} from "@gnu-taler/taler-util";
|
||||||
import {
|
import {
|
||||||
|
checkSuccessResponseOrThrow,
|
||||||
createPlatformHttpLib,
|
createPlatformHttpLib,
|
||||||
HttpRequestLibrary,
|
HttpRequestLibrary,
|
||||||
readSuccessResponseJsonOrThrow,
|
readSuccessResponseJsonOrThrow,
|
||||||
@ -97,6 +98,9 @@ const codecForWithdrawalOperationInfo = (): Codec<WithdrawalOperationInfo> =>
|
|||||||
.property("taler_withdraw_uri", codecForString())
|
.property("taler_withdraw_uri", codecForString())
|
||||||
.build("WithdrawalOperationInfo");
|
.build("WithdrawalOperationInfo");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Use BankAccessApiClient or WireGatewayApi
|
||||||
|
*/
|
||||||
export namespace BankApi {
|
export namespace BankApi {
|
||||||
// FIXME: Move to BankAccessApi?!
|
// FIXME: Move to BankAccessApi?!
|
||||||
export async function registerAccount(
|
export async function registerAccount(
|
||||||
@ -142,37 +146,6 @@ export namespace BankApi {
|
|||||||
return await registerAccount(bank, username, password);
|
return await registerAccount(bank, username, password);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function adminAddIncoming(
|
|
||||||
bank: BankServiceHandle,
|
|
||||||
params: {
|
|
||||||
exchangeBankAccount: HarnessExchangeBankAccount;
|
|
||||||
amount: string;
|
|
||||||
reservePub: string;
|
|
||||||
debitAccountPayto: string;
|
|
||||||
},
|
|
||||||
) {
|
|
||||||
let url = new URL(
|
|
||||||
`taler-wire-gateway/${params.exchangeBankAccount.accountName}/admin/add-incoming`,
|
|
||||||
bank.bankAccessApiBaseUrl,
|
|
||||||
);
|
|
||||||
await bank.http.postJson(
|
|
||||||
url.href,
|
|
||||||
{
|
|
||||||
amount: params.amount,
|
|
||||||
reserve_pub: params.reservePub,
|
|
||||||
debit_account: params.debitAccountPayto,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
headers: {
|
|
||||||
Authorization: makeBasicAuthHeader(
|
|
||||||
params.exchangeBankAccount.accountName,
|
|
||||||
params.exchangeBankAccount.accountPassword,
|
|
||||||
),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function confirmWithdrawalOperation(
|
export async function confirmWithdrawalOperation(
|
||||||
bank: BankServiceHandle,
|
bank: BankServiceHandle,
|
||||||
bankUser: BankUser,
|
bankUser: BankUser,
|
||||||
@ -227,6 +200,9 @@ export namespace BankApi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use BankAccessApiClient
|
||||||
|
*/
|
||||||
export namespace BankAccessApi {
|
export namespace BankAccessApi {
|
||||||
export async function getAccountBalance(
|
export async function getAccountBalance(
|
||||||
bank: BankServiceHandle,
|
bank: BankServiceHandle,
|
||||||
@ -288,6 +264,45 @@ export interface BankAccessApiCreateTransactionRequest {
|
|||||||
paytoUri: string;
|
paytoUri: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class WireGatewayApiClientArgs {
|
||||||
|
accountName: string;
|
||||||
|
accountPassword: string;
|
||||||
|
wireGatewayApiBaseUrl: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class WireGatewayApiClient {
|
||||||
|
httpLib = createPlatformHttpLib();
|
||||||
|
|
||||||
|
constructor(private args: WireGatewayApiClientArgs) {}
|
||||||
|
|
||||||
|
async adminAddIncoming(params: {
|
||||||
|
amount: string;
|
||||||
|
reservePub: string;
|
||||||
|
debitAccountPayto: string;
|
||||||
|
}): Promise<void> {
|
||||||
|
let url = new URL(
|
||||||
|
`admin/add-incoming`,
|
||||||
|
this.args.wireGatewayApiBaseUrl,
|
||||||
|
);
|
||||||
|
const resp = await this.httpLib.fetch(url.href, {
|
||||||
|
method: "POST",
|
||||||
|
body: {
|
||||||
|
amount: params.amount,
|
||||||
|
reserve_pub: params.reservePub,
|
||||||
|
debit_account: params.debitAccountPayto,
|
||||||
|
},
|
||||||
|
headers: {
|
||||||
|
Authorization: makeBasicAuthHeader(
|
||||||
|
this.args.accountName,
|
||||||
|
this.args.accountPassword,
|
||||||
|
),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
logger.info(`add-incoming response status: ${resp.status}`);
|
||||||
|
await checkSuccessResponseOrThrow(resp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export class BankAccessApiClient {
|
export class BankAccessApiClient {
|
||||||
httpLib = createPlatformHttpLib();
|
httpLib = createPlatformHttpLib();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user