forked from ethereum/mist
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic.test.js
More file actions
116 lines (79 loc) · 2.86 KB
/
Copy pathbasic.test.js
File metadata and controls
116 lines (79 loc) · 2.86 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
const _ = require('underscore');
const Q = require('bluebird');
const fs = require('fs');
const path = require('path');
const test = require('../_base').mocha(module, {
app: 'wallet',
});
test['Title test'] = function* () {
const client = this.client;
yield client.waitUntilWindowLoaded();
(yield client.getTitle()).should.eql('Ethereum Wallet');
}
test['account balances'] = function* () {
const web3 = this.web3;
const client = this.client;
const realBalances = this.getRealAccountBalances();
const appBalances = this.getUiAccountBalances();
realBalances.should.not.be.null;
realBalances.should.eql('5');
appBalances.should.eql(realBalances);
};
// test['create account'] = function*() {
// const web3 = this.web3;
// const client = this.client;
// const originalBalances = yield this.getRealAccountBalances();
// yield _createNewAccount.call(this);
// const realBalances = yield this.getRealAccountBalances();
// const appBalances = yield this.getUiAccountBalances();
// _.keys(realBalances).length.should.eql(_.keys(originalBalances).length + 1);
// appBalances.should.eql(realBalances);
// };
test['deposit into account'] = function* () {
const web3 = this.web3;
const client = this.client;
const accounts = web3.eth.accounts;
yield _createNewAccount.call(this);
const newAccount = _.difference(web3.eth.accounts, accounts)[0];
yield this.openAccountInUi(newAccount);
// links
const accLinks = yield this.getUiElements('.dapp-actionbar li');
yield client.elementIdClick(accLinks[0].ELEMENT);
// fill in send form and submit
yield _completeSendForm.call(this, 1);
// do some mining
yield this.startMining();
yield Q.delay(10000);
yield this.stopMining();
// check balances
const realBalances = yield this.getRealAccountBalances();
realBalances[newAccount].should.eql(1);
};
const _createNewAccount = function* () {
const client = this.client;
// open password window
yield this.openAndFocusNewWindow(() => {
return client.click('button.create.account');
});
// enter password
yield client.setValue('form .password', '1234');
yield client.click('form button.ok');
// re-enter password
yield client.setValue('form .password-repeat', '1234');
yield client.click('form button.ok');
yield Q.delay(10000);
yield client.window(this.mainWindowHandle);
};
const _completeSendForm = function* (amt) {
const client = this.client;
// enter password
yield client.setValue('form input[name=amount]', `${amt}`);
// open password window
yield this.openAndFocusNewWindow(() => {
return client.click('form button[type=submit]');
});
// fill in password and submit
yield client.setValue('form input[type=password]', '1234');
yield client.click('form button.ok');
yield Q.delay(5000);
};