Worker-owned reconciliation commits
This commit is contained in:
+17
-7
@@ -127,12 +127,20 @@ test('native RandomX HTTP: three blocks, mined transfer, peer gossip/sync and du
|
||||
|
||||
async function request(base: string, path: string, expected = 200, body?: unknown,
|
||||
headers: Record<string, string> = {}): Promise<Response> {
|
||||
const response = await fetch(`${base}${path}`, {
|
||||
method: body === undefined ? 'GET' : 'POST', redirect: 'error',
|
||||
signal: AbortSignal.any([t.signal, AbortSignal.timeout(30_000)]),
|
||||
headers: { ...(body === undefined ? {} : { 'Content-Type': 'application/json' }), ...headers },
|
||||
body: body === undefined ? undefined : JSON.stringify(body),
|
||||
});
|
||||
const until = Date.now() + 20_000;
|
||||
let response: Response;
|
||||
do {
|
||||
response = await fetch(`${base}${path}`, {
|
||||
method: body === undefined ? 'GET' : 'POST', redirect: 'error',
|
||||
signal: AbortSignal.any([t.signal, AbortSignal.timeout(30_000)]),
|
||||
headers: { ...(body === undefined ? {} : { 'Content-Type': 'application/json' }), ...headers },
|
||||
body: body === undefined ? undefined : JSON.stringify(body),
|
||||
});
|
||||
if (path !== '/api/market/command' || response.status !== 503 || Date.now() >= until ||
|
||||
!(await response.clone().text()).includes('reconciliation is catching up')) break;
|
||||
const retryAfter = Number(response.headers.get('Retry-After'));
|
||||
await delay(Number.isFinite(retryAfter) && retryAfter > 0 ? retryAfter * 1000 : 25, undefined, { signal: t.signal });
|
||||
} while (Date.now() < until);
|
||||
if (response.status !== expected) {
|
||||
assert.fail(`${path}: expected ${expected}, got ${response.status}: ${await response.text()}`);
|
||||
}
|
||||
@@ -360,7 +368,9 @@ test('native RandomX HTTP: three blocks, mined transfer, peer gossip/sync and du
|
||||
assert.deepEqual(canonical.blocks, [block1, block2, block3]);
|
||||
assert.deepEqual(canonical.transfers, [transfer]);
|
||||
assert.deepEqual(canonical.pendingTransfers, []);
|
||||
const settling = await marketCommand<MarketActivityV3>(first.base, market.info, bob, { type: 'activity' });
|
||||
const settling = await waitFor('Worker market delivery reconciliation',
|
||||
() => marketCommand<MarketActivityV3>(first.base, market.info, bob, { type: 'activity' }),
|
||||
activity => activity.orders[0]?.deliveryConfirmations === 1);
|
||||
assert.equal(settling.orders[0].deliveryConfirmations, 1);
|
||||
assert.equal(settling.orders[0].payout, 'not-started');
|
||||
assert.equal((await json<{ listings: MarketListingV3[] }>(second.base, '/api/market')).listings.length, 0);
|
||||
|
||||
Reference in New Issue
Block a user