-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnonRecovery.test.ts
More file actions
97 lines (90 loc) · 3 KB
/
nonRecovery.test.ts
File metadata and controls
97 lines (90 loc) · 3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import 'should';
import * as request from 'supertest';
import nock from 'nock';
import sinon from 'sinon';
import { app as expressApp } from '../../../masterBitGoExpressApp';
import { AppMode, MasterExpressConfig, TlsMode } from '../../../shared/types';
import { BitGoAPITestHarness } from './testUtils';
describe('Non Recovery Tests', () => {
let agent: request.SuperAgentTest;
const advancedWalletManagerUrl = 'http://advancedwalletmanager.invalid';
const accessToken = 'test-token';
const config: MasterExpressConfig = {
appMode: AppMode.MASTER_EXPRESS,
port: 0,
bind: 'localhost',
timeout: 60000,
env: 'test',
disableEnvCheck: true,
authVersion: 2,
advancedWalletManagerUrl: advancedWalletManagerUrl,
awmServerCaCert: 'dummy-cert',
tlsMode: TlsMode.DISABLED,
httpLoggerFile: '',
clientCertAllowSelfSigned: true,
recoveryMode: false,
};
before(() => {
nock.disableNetConnect();
nock.enableNetConnect('127.0.0.1');
const app = expressApp(config);
agent = request.agent(app);
});
afterEach(() => {
nock.cleanAll();
sinon.restore();
BitGoAPITestHarness.clearConstantsCache();
});
describe('Recovery', () => {
it('should fail to run mbe recovery if not in recovery mode', async () => {
const coin = 'tbtc';
const userPub = 'xpub_user';
const backupPub = 'xpub_backup';
const bitgoPub = 'xpub_bitgo';
const recoveryDestination = 'tb1qprdy6jwxrrr2qrwgd2tzl8z99hqp29jn6f3sguxulqm448myj6jsy2nwsu';
const response = await agent
.post(`/api/v1/${coin}/advancedwallet/recovery`)
.set('Authorization', `Bearer ${accessToken}`)
.send({
multiSigRecoveryParams: {
userPub,
backupPub,
bitgoPub,
walletContractAddress: '',
},
recoveryDestinationAddress: recoveryDestination,
coin,
apiKey: 'key',
coinSpecificParams: {
evmRecoveryOptions: {
gasPrice: 20000000000,
gasLimit: 500000,
},
},
});
response.status.should.equal(500);
response.body.should.have.property('error');
response.body.should.have.property('details');
response.body.details.should.containEql(
'Recovery operations are not enabled. The server must be in recovery mode to perform this action.',
);
});
});
describe('Recovery Consolidation', () => {
it('should fail to run mbe recovery consolidation if not in recovery mode', async () => {
const response = await agent
.post(`/api/v1/trx/advancedwallet/recoveryconsolidations`)
.set('Authorization', `Bearer ${accessToken}`)
.send({
multisigType: 'onchain',
userPub: 'user-xpub',
backupPub: 'backup-xpub',
bitgoPub: 'bitgo-xpub',
tokenContractAddress: 'tron-token',
startingScanIndex: 1,
endingScanIndex: 3,
});
response.status.should.equal(500);
});
});
});