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