forked from web3/web3.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheth.defaultAccount.js
More file actions
53 lines (40 loc) · 1.92 KB
/
eth.defaultAccount.js
File metadata and controls
53 lines (40 loc) · 1.92 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
var chai = require('chai');
var assert = chai.assert;
var Eth = require('../packages/web3-eth');
var Web3 = require('../packages/web3');
var eth = new Eth();
var setValue = '0x47D33b27Bb249a2DBab4C0612BF9CaF4C1950855';
describe('web3.eth', function () {
describe('defaultAccount', function () {
it('should check if defaultAccount is set to proper value', function () {
assert.equal(eth.defaultAccount, null);
assert.equal(eth.personal.defaultAccount, null);
assert.equal(eth.Contract.defaultAccount, null);
assert.equal(eth.getCode.method.defaultAccount, null);
});
it('should set defaultAccount for all sub packages is set to proper value, if Eth package is changed', function () {
eth.defaultAccount = setValue;
assert.equal(eth.defaultAccount, setValue);
assert.equal(eth.personal.defaultAccount, setValue);
assert.equal(eth.Contract.defaultAccount, setValue);
assert.equal(eth.getCode.method.defaultAccount, setValue);
});
it('should fail if address is invalid, wich is to be set to defaultAccount', function () {
assert.throws(function(){ eth.defaultAccount = '0x17F33b27Bb249a2DBab4C0612BF9CaF4C1950855'; });
});
it('should have different values for two Eth instances', function () {
var eth1 = new Eth();
eth1.defaultAccount = setValue;
assert.equal(eth1.defaultAccount, setValue);
var eth2 = new Eth();
assert.equal(eth2.defaultAccount, null);
});
it('should have different values for two Web3 instances', function () {
var web31 = new Web3();
web31.eth.defaultAccount = setValue;
assert.equal(web31.eth.defaultAccount, setValue);
var web32 = new Web3();
assert.equal(web32.eth.defaultAccount, null);
});
});
});