Skip to content

Commit 7e5de35

Browse files
committed
feat: add ASYNC_MODE mode config and env vars
Introduces ASYNC_MODE configuration support to Master BitGo Express. `ADVANCED_WALLET_MANAGER_URL` isn't required when `ASYNC_MODE=true` now. Instead, `AWM_BRIDGE_URL` is required when ASYNC mode is enabled. Ticket: WCN-743
1 parent 471644c commit 7e5de35

19 files changed

Lines changed: 178 additions & 11 deletions

src/__tests__/api/master/accelerate.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { Tbtc } from '@bitgo-beta/sdk-coin-btc';
77
import { app as expressApp } from '../../../masterBitGoExpressApp';
88
import { AppMode, MasterExpressConfig, TlsMode } from '../../../shared/types';
99
import { Environments, Wallet } from '@bitgo-beta/sdk-core';
10-
import { BitGoAPITestHarness } from './testUtils';
10+
import { BitGoAPITestHarness, DEFAULT_ASYNC_MODE_CONFIG } from './testUtils';
1111

1212
const TBTC_PREBUILD_PSBT_HEX = utxolib.bitgo
1313
.createPsbtForNetwork({ network: utxolib.networks.testnet })
@@ -64,6 +64,7 @@ describe('POST /api/v1/:coin/advancedwallet/:walletId/accelerate', () => {
6464
awmServerCaCert: 'test-cert',
6565
tlsMode: TlsMode.DISABLED,
6666
clientCertAllowSelfSigned: true,
67+
asyncModeConfig: DEFAULT_ASYNC_MODE_CONFIG,
6768
};
6869

6970
const app = expressApp(config);

src/__tests__/api/master/awmBackupClient.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'should';
22
import { AppMode, MasterExpressConfig, TlsMode } from '../../../shared/types';
3+
import { DEFAULT_ASYNC_MODE_CONFIG } from './testUtils';
34
import {
45
createAwmClient,
56
createAwmBackupClient,
@@ -19,6 +20,7 @@ describe('AWM Backup Client', () => {
1920
awmServerCaCert: 'dummy-cert',
2021
tlsMode: TlsMode.DISABLED,
2122
clientCertAllowSelfSigned: true,
23+
asyncModeConfig: DEFAULT_ASYNC_MODE_CONFIG,
2224
};
2325

2426
describe('createAwmBackupClient', () => {

src/__tests__/api/master/consolidate.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { AppMode, MasterExpressConfig, TlsMode } from '../../../shared/types';
77
import { Environments } from '@bitgo-beta/sdk-core';
88
import { Hteth } from '@bitgo-beta/sdk-coin-eth';
99
import * as transactionRequests from '../../../masterBitgoExpress/handlers/transactionRequests';
10-
import { BitGoAPITestHarness } from './testUtils';
10+
import { BitGoAPITestHarness, DEFAULT_ASYNC_MODE_CONFIG } from './testUtils';
1111

1212
describe('POST /api/v1/:coin/advancedwallet/:walletId/consolidate', () => {
1313
let agent: request.SuperAgentTest;
@@ -61,6 +61,7 @@ describe('POST /api/v1/:coin/advancedwallet/:walletId/consolidate', () => {
6161
awmServerCaCert: 'test-cert',
6262
tlsMode: TlsMode.DISABLED,
6363
clientCertAllowSelfSigned: true,
64+
asyncModeConfig: DEFAULT_ASYNC_MODE_CONFIG,
6465
};
6566

6667
const app = expressApp(config);

src/__tests__/api/master/consolidateUnspents.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { Btc } from '@bitgo-beta/sdk-coin-btc';
77
import { app as expressApp } from '../../../masterBitGoExpressApp';
88
import { AppMode, MasterExpressConfig, TlsMode } from '../../../shared/types';
99
import { Environments, Wallet } from '@bitgo-beta/sdk-core';
10-
import { BitGoAPITestHarness } from './testUtils';
10+
import { BitGoAPITestHarness, DEFAULT_ASYNC_MODE_CONFIG } from './testUtils';
1111

1212
const BTC_PREBUILD_PSBT_HEX = utxolib.bitgo
1313
.createPsbtForNetwork({ network: utxolib.networks.bitcoin })
@@ -64,6 +64,7 @@ describe('POST /api/v1/:coin/advancedwallet/:walletId/consolidateunspents', () =
6464
awmServerCaCert: 'test-cert',
6565
tlsMode: TlsMode.DISABLED,
6666
clientCertAllowSelfSigned: true,
67+
asyncModeConfig: DEFAULT_ASYNC_MODE_CONFIG,
6768
};
6869

6970
const app = expressApp(config);

src/__tests__/api/master/generateWallet.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { Environments } from '@bitgo-beta/sdk-core';
1010
import { BitGoAPI } from '@bitgo-beta/sdk-api';
1111
import * as middleware from '../../../shared/middleware';
1212
import { BitGoRequest } from '../../../types/request';
13-
import { BitGoAPITestHarness } from './testUtils';
13+
import { BitGoAPITestHarness, DEFAULT_ASYNC_MODE_CONFIG } from './testUtils';
1414

1515
function mockWalletResponse(id: string, coinName: string, overrides: Record<string, unknown> = {}) {
1616
return {
@@ -86,6 +86,7 @@ describe('POST /api/v1/:coin/advancedwallet/generate', () => {
8686
awmServerCaCert: 'dummy-cert',
8787
tlsMode: TlsMode.DISABLED,
8888
clientCertAllowSelfSigned: true,
89+
asyncModeConfig: DEFAULT_ASYNC_MODE_CONFIG,
8990
};
9091

9192
// Setup middleware stubs before creating app
@@ -125,6 +126,7 @@ describe('POST /api/v1/:coin/advancedwallet/generate', () => {
125126
awmServerCaCert: 'dummy-cert',
126127
tlsMode: TlsMode.DISABLED,
127128
clientCertAllowSelfSigned: true,
129+
asyncModeConfig: DEFAULT_ASYNC_MODE_CONFIG,
128130
};
129131

130132
sinon.stub(middleware, 'prepareBitGo').callsFake(() => (req, res, next) => {
@@ -366,6 +368,7 @@ describe('POST /api/v1/:coin/advancedwallet/generate', () => {
366368
awmServerCaCert: 'dummy-cert',
367369
tlsMode: TlsMode.DISABLED,
368370
clientCertAllowSelfSigned: true,
371+
asyncModeConfig: DEFAULT_ASYNC_MODE_CONFIG,
369372
};
370373

371374
sinon.stub(middleware, 'prepareBitGo').callsFake(() => (req, res, next) => {
@@ -1018,6 +1021,7 @@ describe('POST /api/v1/:coin/advancedwallet/generate', () => {
10181021
awmServerCaCert: 'dummy-cert',
10191022
tlsMode: TlsMode.DISABLED,
10201023
clientCertAllowSelfSigned: true,
1024+
asyncModeConfig: DEFAULT_ASYNC_MODE_CONFIG,
10211025
};
10221026

10231027
sinon.stub(middleware, 'prepareBitGo').callsFake(() => (req, res, next) => {

src/__tests__/api/master/musigRecovery.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import * as request from 'supertest';
66
import { app as expressApp } from '../../../masterBitGoExpressApp';
77
import { AppMode, MasterExpressConfig, TlsMode } from '../../../shared/types';
88
import { data as ethRecoveryData } from '../../mocks/ethRecoveryMusigMockData';
9-
import { BitGoAPITestHarness } from './testUtils';
9+
import { BitGoAPITestHarness, DEFAULT_ASYNC_MODE_CONFIG } from './testUtils';
1010

1111
describe('POST /api/v1/:coin/advancedwallet/recovery', () => {
1212
let agent: request.SuperAgentTest;
@@ -32,6 +32,7 @@ describe('POST /api/v1/:coin/advancedwallet/recovery', () => {
3232
tlsMode: TlsMode.DISABLED,
3333
clientCertAllowSelfSigned: true,
3434
recoveryMode: true,
35+
asyncModeConfig: DEFAULT_ASYNC_MODE_CONFIG,
3536
};
3637

3738
const app = expressApp(config);

src/__tests__/api/master/nonRecovery.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import nock from 'nock';
44
import sinon from 'sinon';
55
import { app as expressApp } from '../../../masterBitGoExpressApp';
66
import { AppMode, MasterExpressConfig, TlsMode } from '../../../shared/types';
7-
import { BitGoAPITestHarness } from './testUtils';
7+
import { BitGoAPITestHarness, DEFAULT_ASYNC_MODE_CONFIG } from './testUtils';
88

99
describe('Non Recovery Tests', () => {
1010
let agent: request.SuperAgentTest;
@@ -24,6 +24,7 @@ describe('Non Recovery Tests', () => {
2424
httpLoggerFile: '',
2525
clientCertAllowSelfSigned: true,
2626
recoveryMode: false,
27+
asyncModeConfig: DEFAULT_ASYNC_MODE_CONFIG,
2728
};
2829

2930
before(() => {

src/__tests__/api/master/recoveryConsolidationsWallet.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import nock from 'nock';
55
import { app as expressApp } from '../../../masterBitGoExpressApp';
66
import { AppMode, MasterExpressConfig, TlsMode } from '../../../shared/types';
77
import { Trx } from '@bitgo-beta/sdk-coin-trx';
8-
import { BitGoAPITestHarness } from './testUtils';
8+
import { BitGoAPITestHarness, DEFAULT_ASYNC_MODE_CONFIG } from './testUtils';
99

1010
describe('POST /api/v1/:coin/advancedwallet/recoveryconsolidations', () => {
1111
let agent: request.SuperAgentTest;
@@ -143,6 +143,7 @@ describe('POST /api/v1/:coin/advancedwallet/recoveryconsolidations', () => {
143143
tlsMode: TlsMode.DISABLED,
144144
clientCertAllowSelfSigned: true,
145145
recoveryMode: true,
146+
asyncModeConfig: DEFAULT_ASYNC_MODE_CONFIG,
146147
};
147148
const app = expressApp(config);
148149
agent = request.agent(app);

src/__tests__/api/master/recoveryWallet.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import nock from 'nock';
44
import sinon from 'sinon';
55
import { app as expressApp } from '../../../masterBitGoExpressApp';
66
import { AppMode, MasterExpressConfig, TlsMode } from '../../../shared/types';
7-
import { BitGoAPITestHarness } from './testUtils';
7+
import { BitGoAPITestHarness, DEFAULT_ASYNC_MODE_CONFIG } from './testUtils';
88

99
describe('Recovery Tests', () => {
1010
let agent: request.SuperAgentTest;
@@ -24,6 +24,7 @@ describe('Recovery Tests', () => {
2424
tlsMode: TlsMode.DISABLED,
2525
clientCertAllowSelfSigned: true,
2626
recoveryMode: true,
27+
asyncModeConfig: DEFAULT_ASYNC_MODE_CONFIG,
2728
};
2829

2930
before(() => {

src/__tests__/api/master/recoveryWalletMpcV2.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import nock from 'nock';
44
import sinon from 'sinon';
55
import { app as expressApp } from '../../../masterBitGoExpressApp';
66
import { AppMode, MasterExpressConfig, TlsMode } from '../../../shared/types';
7-
import { BitGoAPITestHarness } from './testUtils';
7+
import { BitGoAPITestHarness, DEFAULT_ASYNC_MODE_CONFIG } from './testUtils';
88

99
describe('MBE mpcv2 recovery', () => {
1010
let agent: request.SuperAgentTest;
@@ -31,6 +31,7 @@ describe('MBE mpcv2 recovery', () => {
3131
tlsMode: TlsMode.DISABLED,
3232
clientCertAllowSelfSigned: true,
3333
recoveryMode: true,
34+
asyncModeConfig: DEFAULT_ASYNC_MODE_CONFIG,
3435
};
3536

3637
const app = expressApp(config);

0 commit comments

Comments
 (0)