質問編集履歴
1
コードの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -43,3 +43,101 @@
|
|
43
43
|
}
|
44
44
|
|
45
45
|
```
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
以下追記
|
50
|
+
|
51
|
+
---
|
52
|
+
|
53
|
+
変に省略してしまい、逆に混乱させてしまって申し訳ありません。
|
54
|
+
|
55
|
+
[こちら](https://github.com/AlisProject/ico-contracts/tree/master/test)が参考にしていたテストです。この中の1つが下記のコードです。
|
56
|
+
|
57
|
+
コードの中で`let token`と宣言したり、`this.startBlock`に代入したり、使い分けている様なのですが、どの様な意図で使い分けているか分からないため質問させて頂きました。
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
```javascript
|
62
|
+
|
63
|
+
import alis from '../utilities/alis';
|
64
|
+
|
65
|
+
import ether from './helpers/ether';
|
66
|
+
|
67
|
+
import EVMThrow from './helpers/EVMThrow';
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
import { AlisToken, AlisCrowdsale, should, cap, tokenCap, rate, icoStartTime,
|
72
|
+
|
73
|
+
initialAlisFundBalance, goal, whiteList,
|
74
|
+
|
75
|
+
} from './helpers/alis_helper';
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
contract('AlisToken', ([wallet]) => {
|
80
|
+
|
81
|
+
let token;
|
82
|
+
|
83
|
+
const expectedTokenSupply = alis(240000000);
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
beforeEach(async function () {
|
88
|
+
|
89
|
+
this.startBlock = web3.eth.blockNumber + 10;
|
90
|
+
|
91
|
+
this.endBlock = web3.eth.blockNumber + 20;
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
this.crowdsale = await AlisCrowdsale.new(this.startBlock, icoStartTime, this.endBlock,
|
96
|
+
|
97
|
+
rate.base, wallet, ether(cap), alis(tokenCap), initialAlisFundBalance, ether(goal), whiteList);
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
token = AlisToken.at(await this.crowdsale.token());
|
102
|
+
|
103
|
+
});
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
it('owner should be able to burn tokens', async () => {
|
108
|
+
|
109
|
+
const { logs } = await token.burn(alis(10000000), { from: wallet });
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
const balance = await token.balanceOf(wallet);
|
114
|
+
|
115
|
+
balance.should.be.bignumber.equal(expectedTokenSupply);
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
const totalSupply = await token.totalSupply();
|
120
|
+
|
121
|
+
totalSupply.should.be.bignumber.equal(expectedTokenSupply);
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
const event = logs.find(e => e.event === 'Burn');
|
126
|
+
|
127
|
+
should.exist(event);
|
128
|
+
|
129
|
+
});
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
it('cannot burn more tokens than your balance', async () => {
|
134
|
+
|
135
|
+
await token.burn(alis(260000000), { from: wallet })
|
136
|
+
|
137
|
+
.should.be.rejectedWith(EVMThrow);
|
138
|
+
|
139
|
+
});
|
140
|
+
|
141
|
+
});
|
142
|
+
|
143
|
+
```
|