-
Notifications
You must be signed in to change notification settings - Fork 39
/
TezosHardwareOperations.spec.ts
125 lines (104 loc) · 4.48 KB
/
TezosHardwareOperations.spec.ts
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
import {expect} from "chai";
import {TezosWalletUtil, TezosLedgerWallet} from "../src";
import {HardwareDeviceType} from "../src/types/wallet/HardwareDeviceType";
import {TezosNodeWriter} from "../src";
import {
blockHead,
forgedOpGroupList,
appliedOpList,
injectOpList,
accountMockList,
managerKeyMockList,
walletInfoLists
} from './TezosOperations.responses';
import mochaAsync from './mochaTestHelper';
const nock = require('nock');
const { unlockFundraiserIdentity } = TezosWalletUtil;
const {
sendKeyRevealOperation,
sendTransactionOperation,
sendDelegationOperation,
} = TezosNodeWriter;
const tezosURL = 'http://conseil.server';
const derivationPathIndex = 0;
const derivationPath = `44'/1729'/0'/0'/${derivationPathIndex}'`;
const ktAddress = 'KT1WvyJ1qUrWzShA2T6QeL7AW4DR6GspUimM';
let keyStore;
let keyStore1;
let opIndex = 0;
let testCondition = true;
/*describe('Ledger Test', () => {
before(async () => {
keyStore = await TezosLedgerWallet.unlockAddress(HardwareDeviceType.LedgerNanoS, derivationPath).catch(() => false);
if (!keyStore) { testCondition = false; }
const info1 = walletInfoLists[1];
keyStore1 = await unlockFundraiserIdentity(info1.mnemonic.join(' '), info1.email, info1.password, info1.pkh);
keyStore1.storeType = 'Fundraiser';
const nockOb = nock(tezosURL);
nockOb
.persist()
.get(`/chains/main/blocks/head`)
.reply(200, blockHead);
const accountUrl = `/chains/main/blocks/${blockHead.hash}/context/contracts/${keyStore.publicKeyHash}`;
nockOb
.get(accountUrl)
.reply(200, accountMockList[0]);
const accountUrl1 = `/chains/main/blocks/${blockHead.hash}/context/contracts/${keyStore1.publicKeyHash}`;
nockOb
.get(accountUrl1)
.reply(200, accountMockList[1]);
const accountDelegateUrl = `/chains/main/blocks/${blockHead.hash}/context/contracts/${ktAddress}`;
nockOb
.get(accountDelegateUrl)
.reply(200, accountMockList[2]);
const accountMangerUrl = `/chains/main/blocks/${blockHead.hash}/context/contracts/${keyStore.publicKeyHash}/manager_key`;
nockOb
.get(accountMangerUrl)
.reply(200, managerKeyMockList[0]);
const nonAccountMangerUrl = `/chains/main/blocks/${blockHead.hash}/context/contracts/${keyStore1.publicKeyHash}/manager_key`;
nockOb
.get(nonAccountMangerUrl)
.reply(200, managerKeyMockList[1]);
const ktAccountMangerUrl = `/chains/main/blocks/${blockHead.hash}/context/contracts/${ktAddress}/manager_key`;
nockOb
.get(ktAccountMangerUrl)
.reply(200, managerKeyMockList[0]);
});
beforeEach(async function () {
const nockOb2 = nock(tezosURL);
nockOb2
.persist()
.filteringRequestBody(body => '*')
.post(`/chains/main/blocks/head/helpers/forge/operations`, '*')
.reply(200, forgedOpGroupList[opIndex])
.post(`/chains/main/blocks/head/helpers/preapply/operations`, '*')
.reply(200, appliedOpList[opIndex])
.post(`/injection/operation?chain=main`, '*')
.reply(200, injectOpList[opIndex]);
opIndex ++;
if (!testCondition) {
this.skip();
}
});
it('sendKeyRevealOperation', mochaAsync(async () => {
const revealResult = await sendKeyRevealOperation(tezosURL, keyStore, 0, derivationPath);
expect(revealResult).to.exist;
expect(revealResult.operationGroupID).to.be.a('string');
}));
it('sendTransactionOperation', mochaAsync(async () => {
const toAddress = 'tz1fX6A2miVXjNyReg2dpt2TsXLkZ4w7zRGa';
const amount = 10000000;
const fee = 100000;
const sendResult = await sendTransactionOperation(tezosURL, keyStore, toAddress, amount, fee, derivationPath);
expect(sendResult).to.exist;
expect(sendResult.operationGroupID).to.be.a('string');
}));
it('sendDelegationOperation', mochaAsync(async () => {
const delegator = 'KT1WvyJ1qUrWzShA2T6QeL7AW4DR6GspUimM';
const bakerAddress = 'tz3gN8NTLNLJg5KRsUU47NHNVHbdhcFXjjaB';
const fee = 300000;
const delegationResult = await sendDelegationOperation(tezosURL, keyStore, bakerAddress, fee, derivationPath);
expect(delegationResult).to.exist;
expect(delegationResult.operationGroupID).to.be.a('string');
}));
});*/