質問するログイン新規登録

質問編集履歴

1

コードの追加

2019/04/23 16:36

投稿

dounatsu
dounatsu

スコア78

title CHANGED
File without changes
body CHANGED
@@ -20,4 +20,53 @@
20
20
  });
21
21
  })
22
22
  }
23
+ ```
24
+
25
+ 以下追記
26
+ ---
27
+ 変に省略してしまい、逆に混乱させてしまって申し訳ありません。
28
+ [こちら](https://github.com/AlisProject/ico-contracts/tree/master/test)が参考にしていたテストです。この中の1つが下記のコードです。
29
+ コードの中で`let token`と宣言したり、`this.startBlock`に代入したり、使い分けている様なのですが、どの様な意図で使い分けているか分からないため質問させて頂きました。
30
+
31
+ ```javascript
32
+ import alis from '../utilities/alis';
33
+ import ether from './helpers/ether';
34
+ import EVMThrow from './helpers/EVMThrow';
35
+
36
+ import { AlisToken, AlisCrowdsale, should, cap, tokenCap, rate, icoStartTime,
37
+ initialAlisFundBalance, goal, whiteList,
38
+ } from './helpers/alis_helper';
39
+
40
+ contract('AlisToken', ([wallet]) => {
41
+ let token;
42
+ const expectedTokenSupply = alis(240000000);
43
+
44
+ beforeEach(async function () {
45
+ this.startBlock = web3.eth.blockNumber + 10;
46
+ this.endBlock = web3.eth.blockNumber + 20;
47
+
48
+ this.crowdsale = await AlisCrowdsale.new(this.startBlock, icoStartTime, this.endBlock,
49
+ rate.base, wallet, ether(cap), alis(tokenCap), initialAlisFundBalance, ether(goal), whiteList);
50
+
51
+ token = AlisToken.at(await this.crowdsale.token());
52
+ });
53
+
54
+ it('owner should be able to burn tokens', async () => {
55
+ const { logs } = await token.burn(alis(10000000), { from: wallet });
56
+
57
+ const balance = await token.balanceOf(wallet);
58
+ balance.should.be.bignumber.equal(expectedTokenSupply);
59
+
60
+ const totalSupply = await token.totalSupply();
61
+ totalSupply.should.be.bignumber.equal(expectedTokenSupply);
62
+
63
+ const event = logs.find(e => e.event === 'Burn');
64
+ should.exist(event);
65
+ });
66
+
67
+ it('cannot burn more tokens than your balance', async () => {
68
+ await token.burn(alis(260000000), { from: wallet })
69
+ .should.be.rejectedWith(EVMThrow);
70
+ });
71
+ });
23
72
  ```