harness: fix test-peer-repair

This commit is contained in:
Florian Dold 2023-06-20 16:19:53 +02:00
parent 773712419e
commit 1f60ac76f9
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B

View File

@ -61,7 +61,8 @@ export async function runPeerRepairTest(t: GlobalTestState) {
const wallet2 = w2.walletClient; const wallet2 = w2.walletClient;
const withdrawalDoneCond = wallet1.waitForNotificationCond( const withdrawalDoneCond = wallet1.waitForNotificationCond(
(x) => x.type === NotificationType.TransactionStateTransition && (x) =>
x.type === NotificationType.TransactionStateTransition &&
x.newTxState.major === TransactionMajorState.Done && x.newTxState.major === TransactionMajorState.Done &&
x.transactionId.startsWith("txn:withdrawal:"), x.transactionId.startsWith("txn:withdrawal:"),
); );
@ -102,7 +103,7 @@ export async function runPeerRepairTest(t: GlobalTestState) {
x.type === NotificationType.TransactionStateTransition && x.type === NotificationType.TransactionStateTransition &&
x.transactionId === resp1.transactionId && x.transactionId === resp1.transactionId &&
x.newTxState.major === TransactionMajorState.Pending && x.newTxState.major === TransactionMajorState.Pending &&
x.newTxState.minor === TransactionMinorState.Ready x.newTxState.minor === TransactionMinorState.Ready,
); );
await peerPushDebitReady1Cond; await peerPushDebitReady1Cond;
@ -128,12 +129,9 @@ export async function runPeerRepairTest(t: GlobalTestState) {
x.newTxState.major === TransactionMajorState.Done, x.newTxState.major === TransactionMajorState.Done,
); );
await wallet2.client.call( await wallet2.client.call(WalletApiOperation.ConfirmPeerPushCredit, {
WalletApiOperation.ConfirmPeerPushCredit,
{
peerPushPaymentIncomingId: resp2.peerPushPaymentIncomingId, peerPushPaymentIncomingId: resp2.peerPushPaymentIncomingId,
}, });
);
await peerPushCreditDone1Cond; await peerPushCreditDone1Cond;
await peerPushDebitDone1Cond; await peerPushDebitDone1Cond;
@ -154,6 +152,8 @@ export async function runPeerRepairTest(t: GlobalTestState) {
}); });
wallet1 = w1.walletClient; wallet1 = w1.walletClient;
console.log("attempting peer-push-debit, should fail.");
const initResp2 = await wallet1.client.call( const initResp2 = await wallet1.client.call(
WalletApiOperation.InitiatePeerPushDebit, WalletApiOperation.InitiatePeerPushDebit,
{ {
@ -166,12 +166,37 @@ export async function runPeerRepairTest(t: GlobalTestState) {
}, },
); );
const peerPushDebitFailingCond = wallet1.waitForNotificationCond(
(x) =>
x.type === NotificationType.TransactionStateTransition &&
x.transactionId === initResp2.transactionId &&
x.newTxState.major === TransactionMajorState.Pending &&
x.errorInfo != null,
);
console.log(`waiting for error on ${initResp2.transactionId}`);
await peerPushDebitFailingCond;
console.log("reached error");
// Now withdraw so we have enough coins to re-select
const withdraw2Res = await withdrawViaBankV2(t, {
walletClient: wallet1,
bank,
exchange,
amount: "TESTKUDOS:5",
});
await withdraw2Res.withdrawalFinishedCond;
const peerPushDebitReady2Cond = wallet1.waitForNotificationCond( const peerPushDebitReady2Cond = wallet1.waitForNotificationCond(
(x) => (x) =>
x.type === NotificationType.TransactionStateTransition && x.type === NotificationType.TransactionStateTransition &&
x.transactionId === resp1.transactionId && x.transactionId === initResp2.transactionId &&
x.newTxState.major === TransactionMajorState.Pending && x.newTxState.major === TransactionMajorState.Pending &&
x.newTxState.minor === TransactionMinorState.Ready x.newTxState.minor === TransactionMinorState.Ready,
); );
await peerPushDebitReady2Cond; await peerPushDebitReady2Cond;