Skip to content

Commit 0b2fdca

Browse files
committed
fix: align DAEMON_ERRORS string checks with canonical constants
The credential daemon error retry logic in DaemonKeyStore used locally hardcoded strings ('SESSION_EXPIRED', 'SOURCE_AUTH_DENIED') that did not match the actual error values sent by the credential daemon (defined in constants.ts as 'invalid or expired session', 'invalid source authentication'). This caused the session refresh/retry path to silently never trigger, permanently blocking all chain operations after a session expiry. ## Changes - `modules/key_store.ts`: Remove local DAEMON_ERRORS shadow object; import DAEMON_ERRORS from constants.ts instead so checks always stay in sync with the daemon's actual error messages. - `modules/chain_orders.ts`: Remove stale unused DAEMON_ERRORS import. - `tests/test_uncertain_broadcast.ts`: Update mock error strings to match the canonical DAEMON_ERRORS values so the tests actually exercise the retry path. ## Testing Notes - Existing test suite covers the retry path (UNC-008h, UNC-008i); mock strings now match real daemon output.
1 parent 51ed6a5 commit 0b2fdca

3 files changed

Lines changed: 4 additions & 8 deletions

File tree

modules/chain_orders.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595

9696
const { BitShares, createAccountClient, waitForConnected, withTimeout } = require('./bitshares_client');
9797
const { floatToBlockchainInt, blockchainToFloat, normalizeInt, validateOrderAmountsWithinLimits } = require('./order/utils/math');
98-
const { FILL_PROCESSING, TIMING, NATIVE_CLIENT, DAEMON_ERRORS } = require('./constants');
98+
const { FILL_PROCESSING, TIMING, NATIVE_CLIENT } = require('./constants');
9999
const Format = require('./order/format');
100100
const { toFiniteNumber } = Format;
101101
const AsyncLock = require('./order/async_lock');

modules/key_store.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const {
77
executeOperationsViaCredentialDaemon,
88
BroadcastUncertainError,
99
} = require('./dexbot_credential_client');
10-
const { TIMING } = require('./constants');
10+
const { TIMING, DAEMON_ERRORS } = require('./constants');
1111
const { path } = require('./path_api');
1212
const { PATHS } = require('./paths');
1313
const { getStorage } = require('./storage');
@@ -123,10 +123,6 @@ export class DaemonKeyStore implements KeyStore {
123123
};
124124
} catch (err: any) {
125125
if (err instanceof BroadcastUncertainError) throw err;
126-
const DAEMON_ERRORS = {
127-
SESSION_EXPIRED: 'SESSION_EXPIRED',
128-
SOURCE_AUTH_DENIED: 'SOURCE_AUTH_DENIED',
129-
};
130126
if (err.message && (err.message.includes(DAEMON_ERRORS.SESSION_EXPIRED) || err.message.includes(DAEMON_ERRORS.SOURCE_AUTH_DENIED))) {
131127
const isSourceAuthError = err.message.includes(DAEMON_ERRORS.SOURCE_AUTH_DENIED);
132128
if (isSourceAuthError) {

tests/test_uncertain_broadcast.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ async function testExecuteBatchRetriesExpiredDaemonSessionOnly() {
689689
const transport = installFakeCredentialDaemonTransport((request, socket) => {
690690
requestCount++;
691691
if (requestCount === 1) {
692-
socket.endLine({ success: false, error: 'SESSION_EXPIRED' });
692+
socket.endLine({ success: false, error: 'invalid or expired session' });
693693
} else {
694694
assert.strictEqual(request.sessionId, 'session-2', 'retry should use renegotiated session');
695695
socket.endLine({ success: true, raw: { ok: true }, operation_results: [['1', '1.7.1']] });
@@ -726,7 +726,7 @@ async function testExecuteBatchRetryPreservesUncertainBroadcastHandling() {
726726
const transport = installFakeCredentialDaemonTransport((request, socket) => {
727727
requestCount++;
728728
if (requestCount === 1) {
729-
socket.endLine({ success: false, error: 'SESSION_EXPIRED' });
729+
socket.endLine({ success: false, error: 'invalid or expired session' });
730730
} else {
731731
assert.strictEqual(request.sessionId, 'session-2', 'retry should use renegotiated session');
732732
socket.endLine({ success: false, code: 'BROADCAST_DEADLINE', error: 'inner broadcast deadline exceeded on retry' });

0 commit comments

Comments
 (0)