fix idb bug, p2p integration test
This commit is contained in:
parent
fff3df81e4
commit
bf516a77e8
@ -59,7 +59,7 @@ export const extractKey = (keyPath: IDBKeyPath | IDBKeyPath[], value: any) => {
|
|||||||
remainingKeyPath = null;
|
remainingKeyPath = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!object.hasOwnProperty(identifier)) {
|
if (object == null || !object.hasOwnProperty(identifier)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,9 +26,7 @@ test("basics", (t) => {
|
|||||||
|
|
||||||
t.deepEqual(getIndexKeys([1, 2, 3], "", false), [[1, 2, 3]]);
|
t.deepEqual(getIndexKeys([1, 2, 3], "", false), [[1, 2, 3]]);
|
||||||
|
|
||||||
t.throws(() => {
|
t.deepEqual(getIndexKeys({ foo: 42 }, "foo.bar", false), []);
|
||||||
getIndexKeys({ foo: 42 }, "foo.bar", false);
|
|
||||||
});
|
|
||||||
|
|
||||||
t.deepEqual(getIndexKeys({ foo: 42 }, "foo", true), [42]);
|
t.deepEqual(getIndexKeys({ foo: 42 }, "foo", true), [42]);
|
||||||
t.deepEqual(
|
t.deepEqual(
|
||||||
|
@ -38,6 +38,9 @@ export function getIndexKeys(
|
|||||||
return keys;
|
return keys;
|
||||||
} else if (typeof keyPath === "string" || Array.isArray(keyPath)) {
|
} else if (typeof keyPath === "string" || Array.isArray(keyPath)) {
|
||||||
let key = extractKey(keyPath, value);
|
let key = extractKey(keyPath, value);
|
||||||
|
if (key == null) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
return [valueToKey(key)];
|
return [valueToKey(key)];
|
||||||
} else {
|
} else {
|
||||||
throw Error(`unsupported key path: ${typeof keyPath}`);
|
throw Error(`unsupported key path: ${typeof keyPath}`);
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
* Imports.
|
* Imports.
|
||||||
*/
|
*/
|
||||||
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
|
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
|
||||||
import { GlobalTestState } from "../harness/harness.js";
|
import { GlobalTestState, WalletCli } from "../harness/harness.js";
|
||||||
import {
|
import {
|
||||||
createSimpleTestkudosEnvironment,
|
createSimpleTestkudosEnvironment,
|
||||||
withdrawViaBank,
|
withdrawViaBank,
|
||||||
@ -30,16 +30,23 @@ import {
|
|||||||
export async function runPeerToPeerPushTest(t: GlobalTestState) {
|
export async function runPeerToPeerPushTest(t: GlobalTestState) {
|
||||||
// Set up test environment
|
// Set up test environment
|
||||||
|
|
||||||
const { wallet, bank, exchange, merchant } =
|
const { bank, exchange } = await createSimpleTestkudosEnvironment(t);
|
||||||
await createSimpleTestkudosEnvironment(t);
|
|
||||||
|
const wallet1 = new WalletCli(t, "w1");
|
||||||
|
const wallet2 = new WalletCli(t, "w2");
|
||||||
|
|
||||||
// Withdraw digital cash into the wallet.
|
// Withdraw digital cash into the wallet.
|
||||||
|
|
||||||
await withdrawViaBank(t, { wallet, bank, exchange, amount: "TESTKUDOS:20" });
|
await withdrawViaBank(t, {
|
||||||
|
wallet: wallet1,
|
||||||
|
bank,
|
||||||
|
exchange,
|
||||||
|
amount: "TESTKUDOS:20",
|
||||||
|
});
|
||||||
|
|
||||||
await wallet.runUntilDone();
|
await wallet1.runUntilDone();
|
||||||
|
|
||||||
const resp = await wallet.client.call(
|
const resp = await wallet1.client.call(
|
||||||
WalletApiOperation.InitiatePeerPushPayment,
|
WalletApiOperation.InitiatePeerPushPayment,
|
||||||
{
|
{
|
||||||
amount: "TESTKUDOS:5",
|
amount: "TESTKUDOS:5",
|
||||||
@ -51,7 +58,7 @@ export async function runPeerToPeerPushTest(t: GlobalTestState) {
|
|||||||
|
|
||||||
console.log(resp);
|
console.log(resp);
|
||||||
|
|
||||||
const checkResp = await wallet.client.call(
|
const checkResp = await wallet2.client.call(
|
||||||
WalletApiOperation.CheckPeerPushPayment,
|
WalletApiOperation.CheckPeerPushPayment,
|
||||||
{
|
{
|
||||||
talerUri: resp.talerUri,
|
talerUri: resp.talerUri,
|
||||||
@ -60,7 +67,7 @@ export async function runPeerToPeerPushTest(t: GlobalTestState) {
|
|||||||
|
|
||||||
console.log(checkResp);
|
console.log(checkResp);
|
||||||
|
|
||||||
const acceptResp = await wallet.client.call(
|
const acceptResp = await wallet2.client.call(
|
||||||
WalletApiOperation.AcceptPeerPushPayment,
|
WalletApiOperation.AcceptPeerPushPayment,
|
||||||
{
|
{
|
||||||
peerPushPaymentIncomingId: checkResp.peerPushPaymentIncomingId,
|
peerPushPaymentIncomingId: checkResp.peerPushPaymentIncomingId,
|
||||||
@ -69,7 +76,8 @@ export async function runPeerToPeerPushTest(t: GlobalTestState) {
|
|||||||
|
|
||||||
console.log(acceptResp);
|
console.log(acceptResp);
|
||||||
|
|
||||||
await wallet.runUntilDone();
|
await wallet1.runUntilDone();
|
||||||
|
await wallet2.runUntilDone();
|
||||||
}
|
}
|
||||||
|
|
||||||
runPeerToPeerPushTest.suites = ["wallet"];
|
runPeerToPeerPushTest.suites = ["wallet"];
|
||||||
|
@ -72,6 +72,7 @@ import { checkDbInvariant } from "../util/invariants.js";
|
|||||||
import { internalCreateWithdrawalGroup } from "./withdraw.js";
|
import { internalCreateWithdrawalGroup } from "./withdraw.js";
|
||||||
import { GetReadOnlyAccess } from "../util/query.js";
|
import { GetReadOnlyAccess } from "../util/query.js";
|
||||||
import { createRefreshGroup } from "./refresh.js";
|
import { createRefreshGroup } from "./refresh.js";
|
||||||
|
import { updateExchangeFromUrl } from "./exchanges.js";
|
||||||
|
|
||||||
const logger = new Logger("operations/peer-to-peer.ts");
|
const logger = new Logger("operations/peer-to-peer.ts");
|
||||||
|
|
||||||
@ -339,6 +340,9 @@ export async function checkPeerPushPayment(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const exchangeBaseUrl = uri.exchangeBaseUrl;
|
const exchangeBaseUrl = uri.exchangeBaseUrl;
|
||||||
|
|
||||||
|
await updateExchangeFromUrl(ws, exchangeBaseUrl);
|
||||||
|
|
||||||
const contractPriv = uri.contractPriv;
|
const contractPriv = uri.contractPriv;
|
||||||
const contractPub = encodeCrock(eddsaGetPublic(decodeCrock(contractPriv)));
|
const contractPub = encodeCrock(eddsaGetPublic(decodeCrock(contractPriv)));
|
||||||
|
|
||||||
@ -463,6 +467,8 @@ export async function acceptPeerPushPayment(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await updateExchangeFromUrl(ws, peerInc.exchangeBaseUrl);
|
||||||
|
|
||||||
const amount = Amounts.parseOrThrow(peerInc.contractTerms.amount);
|
const amount = Amounts.parseOrThrow(peerInc.contractTerms.amount);
|
||||||
|
|
||||||
const mergeReserveInfo = await getMergeReserveInfo(ws, {
|
const mergeReserveInfo = await getMergeReserveInfo(ws, {
|
||||||
|
Loading…
Reference in New Issue
Block a user