-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcache.js
75 lines (57 loc) · 1.87 KB
/
cache.js
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
var expect = require('chai').expect;
var log = console.log;
function clearBytes32(str){
return str.replace(/\u0000/g, '');
}
function toInteger( bigNumber){
return parseInt(bigNumber.toString() );
}
contract("Ballot" , function(accounts){
var ballot = null;
describe("new()" , function(){
var chairperson = null;
var proposalsCount = null;
var firstProposal = null;
before(function(done){
Ballot.new(["hard fork" , "soft fork" , "do nothing"])
.catch(log)
.then(function(contract){
ballot = contract;
})
.catch(log)
.then( function(){
return ballot.chairperson();
})
.catch(log)
.then(function(response){
chairperson = response;
return ballot.getProposal(0);
})
.catch(log})
.then(function(response){
firstProposal = response;
return ballot.proposalsCount();
})
.catch(log)
.then(function(response){
proposalsCount = response;
})
.then(done);
});
it("ballot should be set" , function(){
expect(ballot).to.not.be.null;
} );
it("ballot chairperson should be coinbase" , function(){
expect(chairperson).to.be.equal(accounts[0]);
});
it("ballot first proposal should be set" , function(){
var ascii = web3.toAscii(firstProposal[0]);
expect(clearBytes32(ascii)).to.be.equal("hard fork");
});
it("ballot proposals count should be 3" , function(){
expect( toInteger(proposalsCount) ).to.be.equal(3);
});
describe("vote()" , function(){
//ballot is available here.
});
});