wallet-core: fix withdrawal state machine
This commit is contained in:
parent
8d19b80153
commit
2337ddab61
@ -84,6 +84,8 @@ export async function runWalletBackupBasicTest(t: GlobalTestState) {
|
|||||||
|
|
||||||
await withdrawViaBank(t, { wallet, bank, exchange, amount: "TESTKUDOS:10" });
|
await withdrawViaBank(t, { wallet, bank, exchange, amount: "TESTKUDOS:10" });
|
||||||
|
|
||||||
|
await wallet.runUntilDone();
|
||||||
|
|
||||||
await wallet.client.call(WalletApiOperation.RunBackupCycle, {});
|
await wallet.client.call(WalletApiOperation.RunBackupCycle, {});
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -59,6 +59,8 @@ export async function runWalletBackupDoublespendTest(t: GlobalTestState) {
|
|||||||
|
|
||||||
await withdrawViaBank(t, { wallet, bank, exchange, amount: "TESTKUDOS:10" });
|
await withdrawViaBank(t, { wallet, bank, exchange, amount: "TESTKUDOS:10" });
|
||||||
|
|
||||||
|
await wallet.runUntilDone();
|
||||||
|
|
||||||
await wallet.client.call(WalletApiOperation.RunBackupCycle, {});
|
await wallet.client.call(WalletApiOperation.RunBackupCycle, {});
|
||||||
await wallet.runUntilDone();
|
await wallet.runUntilDone();
|
||||||
await wallet.client.call(WalletApiOperation.RunBackupCycle, {});
|
await wallet.client.call(WalletApiOperation.RunBackupCycle, {});
|
||||||
|
@ -126,6 +126,11 @@ export enum WithdrawalGroupStatus {
|
|||||||
*/
|
*/
|
||||||
QueryingStatus = OperationStatusRange.ACTIVE_START + 2,
|
QueryingStatus = OperationStatusRange.ACTIVE_START + 2,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ready for withdrawal.
|
||||||
|
*/
|
||||||
|
Ready = OperationStatusRange.ACTIVE_START + 3,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The corresponding withdraw record has been created.
|
* The corresponding withdraw record has been created.
|
||||||
* No further processing is done, unless explicitly requested
|
* No further processing is done, unless explicitly requested
|
||||||
|
@ -1023,7 +1023,7 @@ async function queryReserve(
|
|||||||
logger.warn(`withdrawal group ${withdrawalGroupId} not found`);
|
logger.warn(`withdrawal group ${withdrawalGroupId} not found`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
wg.status = WithdrawalGroupStatus.Finished;
|
wg.status = WithdrawalGroupStatus.Ready;
|
||||||
await tx.withdrawalGroups.put(wg);
|
await tx.withdrawalGroups.put(wg);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1138,6 +1138,9 @@ export async function processWithdrawalGroup(
|
|||||||
case WithdrawalGroupStatus.Finished:
|
case WithdrawalGroupStatus.Finished:
|
||||||
// We can try to withdraw, nothing needs to be done with the reserve.
|
// We can try to withdraw, nothing needs to be done with the reserve.
|
||||||
break;
|
break;
|
||||||
|
case WithdrawalGroupStatus.Ready:
|
||||||
|
// Continue with the actual withdrawal!
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new InvariantViolatedError(
|
throw new InvariantViolatedError(
|
||||||
`unknown reserve record status: ${withdrawalGroup.status}`,
|
`unknown reserve record status: ${withdrawalGroup.status}`,
|
||||||
|
@ -492,6 +492,7 @@ async function runTaskLoop(
|
|||||||
ws: InternalWalletState,
|
ws: InternalWalletState,
|
||||||
opts: RetryLoopOpts = {},
|
opts: RetryLoopOpts = {},
|
||||||
): Promise<TaskLoopResult> {
|
): Promise<TaskLoopResult> {
|
||||||
|
logger.info(`running task loop opts=${j2s(opts)}`);
|
||||||
let retriesExceeded = false;
|
let retriesExceeded = false;
|
||||||
for (let iteration = 0; !ws.stopped; iteration++) {
|
for (let iteration = 0; !ws.stopped; iteration++) {
|
||||||
const pending = await getPendingOperations(ws);
|
const pending = await getPendingOperations(ws);
|
||||||
|
Loading…
Reference in New Issue
Block a user