Repository navigation
Expand file tree
/
Copy pathCoinPubTest.js
More file actions
146 lines (126 loc) · 4.43 KB
/
Copy pathCoinPubTest.js
File metadata and controls
146 lines (126 loc) · 4.43 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
var CoinPub = artifacts.require("./CoinPub.sol");
contract('CoinPub', function(accounts) {
it("creates a Coin with readerstake of 1 ", function() {
var N=1;
var instance;
return CoinPub.new( {
from: accounts[0],
})
.then(_instance => {
instance = _instance;
return instance.createCoinStruct(1,"MYCoin","BK","boardroom");
})
.then(() =>{
return instance.structRet.call(1);
})
.then(resultValue => {
console.log(resultValue);
assert.equal(resultValue.toString(), N, "Readershipstake should be 1");
// Do not return anything on the last callback or it will believe there is an error.
});
});
it("creates a Coin with a tokenname of MYCoin", function() {
var Name="MYCoin";
var instance;
return CoinPub.new( {
from: accounts[0],
})
.then(_instance => {
instance = _instance;
return instance.createCoinStruct(1,"MYCoin","BK","boardroom");
})
.then(() =>{
return instance.nameret.call(1);
})
.then(resultValue => {
console.log(resultValue);
assert.equal(resultValue.toString(), Name, "tokenname should be MYCoin");
// Do not return anything on the last callback or it will believe there is an error.
});
});
it("creates a Coin with a tokensymbol of BK", function() {
var Symbol="BK";
var instance;
return CoinPub.new( {
from: accounts[0],
})
.then(_instance => {
instance = _instance;
return instance.createCoinStruct(1,"MYCoin","BK","boardroom");
})
.then(() =>{
return instance.symbolret.call(1);
})
.then(resultValue => {
console.log(resultValue);
assert.equal(resultValue.toString(), Symbol, " symbol should be BK");
// Do not return anything on the last callback or it will believe there is an error.
});
});
it(" CoinID will increment with iterate with function call", function() {
var Symbol="BKK";
var instance;
return CoinPub.new( {
from: accounts[0],
})
.then(_instance => {
instance = _instance;
return instance.createCoinStruct(1,"MYCoin","BK","boardroom");
}).then(() =>{
return instance.createCoinStruct(1,"MYCoin","BKK","boardroom");
}).then(() =>{
return instance.symbolret.call(2);
})
.then(resultValue => {
console.log(resultValue);
assert.equal(resultValue.toString(), Symbol, " symbol should be BK");
// Do not return anything on the last callback or it will believe there is an error.
});
});
it(" modify Coin works", function() {
var goal=100;
var s=2;
var e=4;
var eligible=300;
var instance;
return CoinPub.new( {
from: accounts[0],
})
.then(_instance => {
instance = _instance;
return instance.createCoinStruct(1,"MYCoin","BK","boardroom");
}).then(() =>{
return instance.modifyCoinStruct(1,100,2,4,300);
}).then(() =>{
return instance.getOtherparams.call(1);
})
.then(resultValue => {
// console.log(resultValue);
assert.equal(resultValue[0].c.toString(), goal, " goal should be 100");
assert.equal(resultValue[1].toString(), s, " start should be 2");
assert.equal(resultValue[2].toString(), e, " end should be 4");
assert.equal(resultValue[3].toString(), eligible, " eligible should be 300");
// Do not return anything on the last callback or it will believe there is an error.
});
});
it(" add a partner works", function() {
var stake=100;
var instance;
return CoinPub.new( {
from: accounts[0],
})
.then(_instance => {
instance = _instance;
return instance.createCoinStruct(1,"MYCoin","BK","boardroom");
}).then(() =>{
return instance.addPartner(1,100);
}).then(() =>{
return instance.getPartnerShare.call(1,0);
})
.then(resultValue => {
//console.log(resultValue);
assert.equal(resultValue.toString(), stake, " gstake should be 100");
// Do not return anything on the last callback or it will believe there is an error.
});
});
});