Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 82 additions & 1 deletion src/__tests__/api/master/generateWallet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2403,7 +2403,11 @@ describe('POST /api/v1/:coin/advancedwallet/generate', () => {
const asyncApp = expressApp(asyncConfig);
const asyncAgent = request.agent(asyncApp);

const bridgeNock = nock(bridgeUrl).post(`/api/${coin}/key/independent`).reply(202, { jobId });
const bridgeNock = nock(bridgeUrl)
.post(`/api/${coin}/key/independent`)
.matchHeader('X-OSO-Source', 'user,backup')
.matchHeader('X-OSO-Operation', 'multisig_keygen')
.reply(202, { jobId });

const response = await asyncAgent
.post(`/api/v1/${coin}/advancedwallet/generate`)
Expand Down Expand Up @@ -2432,4 +2436,81 @@ describe('POST /api/v1/:coin/advancedwallet/generate', () => {
'EVM keyring wallet generation is not supported for coin tbtc',
);
});

it('should fail when async mode is enabled for TSS wallet generation', async () => {
const bridgeUrl = 'http://bridge.invalid';
sinon.restore();
const asyncBitgo = new BitGoAPI({ env: 'test' });
const asyncConfig = makeConfig({
asyncModeConfig: {
enabled: true,
awmAsyncUrl: bridgeUrl,
pollIntervalInMs: 30000,
jobTtlInSeconds: 3600,
jobTtlMpcInSeconds: 7200,
},
});

sinon.stub(middleware, 'prepareBitGo').callsFake(() => (req, _res, next) => {
(req as BitGoRequest<MasterExpressConfig>).bitgo = asyncBitgo;
(req as BitGoRequest<MasterExpressConfig>).config = asyncConfig;
next();
});

const asyncApp = expressApp(asyncConfig);
const asyncAgent = request.agent(asyncApp);

const response = await asyncAgent
.post(`/api/v1/${eddsaCoin}/advancedwallet/generate`)
.set('Authorization', `Bearer ${accessToken}`)
.send({
label: 'test_wallet',
enterprise: 'test_enterprise',
multisigType: 'tss',
});

response.status.should.equal(400);
response.body.details.should.containEql(
'Async mode is not yet supported for TSS wallet generation',
);
});

it('should fail when async mode is enabled for EVM keyring wallet generation', async () => {
const bridgeUrl = 'http://bridge.invalid';
sinon.restore();
const asyncBitgo = new BitGoAPI({ env: 'test' });
const asyncConfig = makeConfig({
asyncModeConfig: {
enabled: true,
awmAsyncUrl: bridgeUrl,
pollIntervalInMs: 30000,
jobTtlInSeconds: 3600,
jobTtlMpcInSeconds: 7200,
},
});

sinon.stub(middleware, 'prepareBitGo').callsFake(() => (req, _res, next) => {
(req as BitGoRequest<MasterExpressConfig>).bitgo = asyncBitgo;
(req as BitGoRequest<MasterExpressConfig>).config = asyncConfig;
next();
});

const asyncApp = expressApp(asyncConfig);
const asyncAgent = request.agent(asyncApp);

const response = await asyncAgent
.post(`/api/v1/eth/advancedwallet/generate`)
.set('Authorization', `Bearer ${accessToken}`)
.send({
label: 'test_wallet',
enterprise: 'test_enterprise',
multisigType: 'onchain',
evmKeyRingReferenceWalletId: '59cd72485007a239fb00282ed480da1f',
});

response.status.should.equal(400);
response.body.details.should.containEql(
'Async mode is not yet supported for EVM keyring wallet generation',
);
});
});
Loading