Skip to content

Commit 22f63c1

Browse files
authored
Merge pull request #29 from BitGo/WP-4724-send-many-integration-tests
test(mbe): add sendMany integration tests
2 parents 95c4a3f + 1c585a2 commit 22f63c1

7 files changed

Lines changed: 498 additions & 30 deletions

File tree

src/__tests__/masterBitgoExpress/generateWallet.test.ts

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,25 @@ describe('POST /api/:coin/wallet/generate', () => {
4141
nock.cleanAll();
4242
});
4343

44-
after(() => {
45-
nock.restore();
46-
});
47-
4844
it('should generate a wallet by calling the enclaved express service', async () => {
4945
const userKeychainNock = nock(enclavedExpressUrl)
50-
.post(`/api/${coin}/key/independent`)
46+
.post(`/api/${coin}/key/independent`, {
47+
source: 'user',
48+
coin: coin,
49+
type: 'independent',
50+
})
5151
.reply(200, {
5252
pub: 'xpub_user',
5353
source: 'user',
5454
type: 'independent',
5555
});
5656

5757
const backupKeychainNock = nock(enclavedExpressUrl)
58-
.post(`/api/${coin}/key/independent`)
58+
.post(`/api/${coin}/key/independent`, {
59+
source: 'backup',
60+
coin: coin,
61+
type: 'independent',
62+
})
5963
.reply(200, {
6064
pub: 'xpub_backup',
6165
source: 'backup',
@@ -134,4 +138,35 @@ describe('POST /api/:coin/wallet/generate', () => {
134138
bitgoAddBitGoKeyNock.done();
135139
bitgoAddWalletNock.done();
136140
});
141+
142+
it('should fail when enclaved express client is not configured', async () => {
143+
// Create a config without enclaved express settings
144+
const invalidConfig: Partial<MasterExpressConfig> = {
145+
appMode: AppMode.MASTER_EXPRESS,
146+
port: 0,
147+
bind: 'localhost',
148+
timeout: 60000,
149+
logFile: '',
150+
env: 'test',
151+
disableEnvCheck: true,
152+
authVersion: 2,
153+
tlsMode: TlsMode.DISABLED,
154+
mtlsRequestCert: false,
155+
allowSelfSigned: true,
156+
};
157+
158+
const app = expressApp(invalidConfig as MasterExpressConfig);
159+
const testAgent = request.agent(app);
160+
161+
const response = await testAgent
162+
.post(`/api/${coin}/wallet/generate`)
163+
.set('Authorization', `Bearer ${accessToken}`)
164+
.send({
165+
label: 'test-wallet',
166+
});
167+
168+
response.status.should.equal(500);
169+
response.body.should.have.property('error');
170+
response.body.error.should.equal('Please configure enclaved express configs.');
171+
});
137172
});

0 commit comments

Comments
 (0)