ERC20VotesComp.test.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529
  1. /* eslint-disable */
  2. const { BN, constants, expectEvent, expectRevert, time } = require('@openzeppelin/test-helpers');
  3. const { expect } = require('chai');
  4. const { MAX_UINT256, ZERO_ADDRESS, ZERO_BYTES32 } = constants;
  5. const { fromRpcSig } = require('ethereumjs-util');
  6. const ethSigUtil = require('eth-sig-util');
  7. const Wallet = require('ethereumjs-wallet').default;
  8. const { promisify } = require('util');
  9. const queue = promisify(setImmediate);
  10. const ERC20VotesCompMock = artifacts.require('ERC20VotesCompMock');
  11. const { EIP712Domain, domainSeparator } = require('../../../helpers/eip712');
  12. const Delegation = [
  13. { name: 'delegatee', type: 'address' },
  14. { name: 'nonce', type: 'uint256' },
  15. { name: 'expiry', type: 'uint256' },
  16. ];
  17. async function countPendingTransactions() {
  18. return parseInt(
  19. await network.provider.send('eth_getBlockTransactionCountByNumber', ['pending'])
  20. );
  21. }
  22. async function batchInBlock (txs) {
  23. try {
  24. // disable auto-mining
  25. await network.provider.send('evm_setAutomine', [false]);
  26. // send all transactions
  27. const promises = txs.map(fn => fn());
  28. // wait for node to have all pending transactions
  29. while (txs.length > await countPendingTransactions()) {
  30. await queue();
  31. }
  32. // mine one block
  33. await network.provider.send('evm_mine');
  34. // fetch receipts
  35. const receipts = await Promise.all(promises);
  36. // Sanity check, all tx should be in the same block
  37. const minedBlocks = new Set(receipts.map(({ receipt }) => receipt.blockNumber));
  38. expect(minedBlocks.size).to.equal(1);
  39. return receipts;
  40. } finally {
  41. // enable auto-mining
  42. await network.provider.send('evm_setAutomine', [true]);
  43. }
  44. }
  45. contract('ERC20VotesComp', function (accounts) {
  46. const [ holder, recipient, holderDelegatee, recipientDelegatee, other1, other2 ] = accounts;
  47. const name = 'My Token';
  48. const symbol = 'MTKN';
  49. const version = '1';
  50. const supply = new BN('10000000000000000000000000');
  51. beforeEach(async function () {
  52. this.token = await ERC20VotesCompMock.new(name, symbol);
  53. // We get the chain id from the contract because Ganache (used for coverage) does not return the same chain id
  54. // from within the EVM as from the JSON RPC interface.
  55. // See https://github.com/trufflesuite/ganache-core/issues/515
  56. this.chainId = await this.token.getChainId();
  57. });
  58. it('initial nonce is 0', async function () {
  59. expect(await this.token.nonces(holder)).to.be.bignumber.equal('0');
  60. });
  61. it('domain separator', async function () {
  62. expect(
  63. await this.token.DOMAIN_SEPARATOR(),
  64. ).to.equal(
  65. await domainSeparator(name, version, this.chainId, this.token.address),
  66. );
  67. });
  68. it('minting restriction', async function () {
  69. const amount = new BN('2').pow(new BN('96'));
  70. await expectRevert(
  71. this.token.mint(holder, amount),
  72. 'ERC20Votes: total supply risks overflowing votes',
  73. );
  74. });
  75. describe('set delegation', function () {
  76. describe('call', function () {
  77. it('delegation with balance', async function () {
  78. await this.token.mint(holder, supply);
  79. expect(await this.token.delegates(holder)).to.be.equal(ZERO_ADDRESS);
  80. const { receipt } = await this.token.delegate(holder, { from: holder });
  81. expectEvent(receipt, 'DelegateChanged', {
  82. delegator: holder,
  83. fromDelegate: ZERO_ADDRESS,
  84. toDelegate: holder,
  85. });
  86. expectEvent(receipt, 'DelegateVotesChanged', {
  87. delegate: holder,
  88. previousBalance: '0',
  89. newBalance: supply,
  90. });
  91. expect(await this.token.delegates(holder)).to.be.equal(holder);
  92. expect(await this.token.getCurrentVotes(holder)).to.be.bignumber.equal(supply);
  93. expect(await this.token.getPriorVotes(holder, receipt.blockNumber - 1)).to.be.bignumber.equal('0');
  94. await time.advanceBlock();
  95. expect(await this.token.getPriorVotes(holder, receipt.blockNumber)).to.be.bignumber.equal(supply);
  96. });
  97. it('delegation without balance', async function () {
  98. expect(await this.token.delegates(holder)).to.be.equal(ZERO_ADDRESS);
  99. const { receipt } = await this.token.delegate(holder, { from: holder });
  100. expectEvent(receipt, 'DelegateChanged', {
  101. delegator: holder,
  102. fromDelegate: ZERO_ADDRESS,
  103. toDelegate: holder,
  104. });
  105. expectEvent.notEmitted(receipt, 'DelegateVotesChanged');
  106. expect(await this.token.delegates(holder)).to.be.equal(holder);
  107. });
  108. });
  109. describe('with signature', function () {
  110. const delegator = Wallet.generate();
  111. const delegatorAddress = web3.utils.toChecksumAddress(delegator.getAddressString());
  112. const nonce = 0;
  113. const buildData = (chainId, verifyingContract, message) => ({ data: {
  114. primaryType: 'Delegation',
  115. types: { EIP712Domain, Delegation },
  116. domain: { name, version, chainId, verifyingContract },
  117. message,
  118. }});
  119. beforeEach(async function () {
  120. await this.token.mint(delegatorAddress, supply);
  121. });
  122. it('accept signed delegation', async function () {
  123. const { v, r, s } = fromRpcSig(ethSigUtil.signTypedMessage(
  124. delegator.getPrivateKey(),
  125. buildData(this.chainId, this.token.address, {
  126. delegatee: delegatorAddress,
  127. nonce,
  128. expiry: MAX_UINT256,
  129. }),
  130. ));
  131. expect(await this.token.delegates(delegatorAddress)).to.be.equal(ZERO_ADDRESS);
  132. const { receipt } = await this.token.delegateBySig(delegatorAddress, nonce, MAX_UINT256, v, r, s);
  133. expectEvent(receipt, 'DelegateChanged', {
  134. delegator: delegatorAddress,
  135. fromDelegate: ZERO_ADDRESS,
  136. toDelegate: delegatorAddress,
  137. });
  138. expectEvent(receipt, 'DelegateVotesChanged', {
  139. delegate: delegatorAddress,
  140. previousBalance: '0',
  141. newBalance: supply,
  142. });
  143. expect(await this.token.delegates(delegatorAddress)).to.be.equal(delegatorAddress);
  144. expect(await this.token.getCurrentVotes(delegatorAddress)).to.be.bignumber.equal(supply);
  145. expect(await this.token.getPriorVotes(delegatorAddress, receipt.blockNumber - 1)).to.be.bignumber.equal('0');
  146. await time.advanceBlock();
  147. expect(await this.token.getPriorVotes(delegatorAddress, receipt.blockNumber)).to.be.bignumber.equal(supply);
  148. });
  149. it('rejects reused signature', async function () {
  150. const { v, r, s } = fromRpcSig(ethSigUtil.signTypedMessage(
  151. delegator.getPrivateKey(),
  152. buildData(this.chainId, this.token.address, {
  153. delegatee: delegatorAddress,
  154. nonce,
  155. expiry: MAX_UINT256,
  156. }),
  157. ));
  158. await this.token.delegateBySig(delegatorAddress, nonce, MAX_UINT256, v, r, s);
  159. await expectRevert(
  160. this.token.delegateBySig(delegatorAddress, nonce, MAX_UINT256, v, r, s),
  161. 'ERC20Votes: invalid nonce',
  162. );
  163. });
  164. it('rejects bad delegatee', async function () {
  165. const { v, r, s } = fromRpcSig(ethSigUtil.signTypedMessage(
  166. delegator.getPrivateKey(),
  167. buildData(this.chainId, this.token.address, {
  168. delegatee: delegatorAddress,
  169. nonce,
  170. expiry: MAX_UINT256,
  171. }),
  172. ));
  173. const receipt = await this.token.delegateBySig(holderDelegatee, nonce, MAX_UINT256, v, r, s);
  174. const { args } = receipt.logs.find(({ event }) => event == 'DelegateChanged');
  175. expect(args.delegator).to.not.be.equal(delegatorAddress);
  176. expect(args.fromDelegate).to.be.equal(ZERO_ADDRESS);
  177. expect(args.toDelegate).to.be.equal(holderDelegatee);
  178. });
  179. it('rejects bad nonce', async function () {
  180. const { v, r, s } = fromRpcSig(ethSigUtil.signTypedMessage(
  181. delegator.getPrivateKey(),
  182. buildData(this.chainId, this.token.address, {
  183. delegatee: delegatorAddress,
  184. nonce,
  185. expiry: MAX_UINT256,
  186. }),
  187. ));
  188. await expectRevert(
  189. this.token.delegateBySig(delegatorAddress, nonce + 1, MAX_UINT256, v, r, s),
  190. 'ERC20Votes: invalid nonce',
  191. );
  192. });
  193. it('rejects expired permit', async function () {
  194. const expiry = (await time.latest()) - time.duration.weeks(1);
  195. const { v, r, s } = fromRpcSig(ethSigUtil.signTypedMessage(
  196. delegator.getPrivateKey(),
  197. buildData(this.chainId, this.token.address, {
  198. delegatee: delegatorAddress,
  199. nonce,
  200. expiry,
  201. }),
  202. ));
  203. await expectRevert(
  204. this.token.delegateBySig(delegatorAddress, nonce, expiry, v, r, s),
  205. 'ERC20Votes: signature expired',
  206. );
  207. });
  208. });
  209. });
  210. describe('change delegation', function () {
  211. beforeEach(async function () {
  212. await this.token.mint(holder, supply);
  213. await this.token.delegate(holder, { from: holder });
  214. });
  215. it('call', async function () {
  216. expect(await this.token.delegates(holder)).to.be.equal(holder);
  217. const { receipt } = await this.token.delegate(holderDelegatee, { from: holder });
  218. expectEvent(receipt, 'DelegateChanged', {
  219. delegator: holder,
  220. fromDelegate: holder,
  221. toDelegate: holderDelegatee,
  222. });
  223. expectEvent(receipt, 'DelegateVotesChanged', {
  224. delegate: holder,
  225. previousBalance: supply,
  226. newBalance: '0',
  227. });
  228. expectEvent(receipt, 'DelegateVotesChanged', {
  229. delegate: holderDelegatee,
  230. previousBalance: '0',
  231. newBalance: supply,
  232. });
  233. expect(await this.token.delegates(holder)).to.be.equal(holderDelegatee);
  234. expect(await this.token.getCurrentVotes(holder)).to.be.bignumber.equal('0');
  235. expect(await this.token.getCurrentVotes(holderDelegatee)).to.be.bignumber.equal(supply);
  236. expect(await this.token.getPriorVotes(holder, receipt.blockNumber - 1)).to.be.bignumber.equal(supply);
  237. expect(await this.token.getPriorVotes(holderDelegatee, receipt.blockNumber - 1)).to.be.bignumber.equal('0');
  238. await time.advanceBlock();
  239. expect(await this.token.getPriorVotes(holder, receipt.blockNumber)).to.be.bignumber.equal('0');
  240. expect(await this.token.getPriorVotes(holderDelegatee, receipt.blockNumber)).to.be.bignumber.equal(supply);
  241. });
  242. });
  243. describe('transfers', function () {
  244. beforeEach(async function () {
  245. await this.token.mint(holder, supply);
  246. });
  247. it('no delegation', async function () {
  248. const { receipt } = await this.token.transfer(recipient, 1, { from: holder });
  249. expectEvent(receipt, 'Transfer', { from: holder, to: recipient, value: '1' });
  250. expectEvent.notEmitted(receipt, 'DelegateVotesChanged');
  251. this.holderVotes = '0';
  252. this.recipientVotes = '0';
  253. });
  254. it('sender delegation', async function () {
  255. await this.token.delegate(holder, { from: holder });
  256. const { receipt } = await this.token.transfer(recipient, 1, { from: holder });
  257. expectEvent(receipt, 'Transfer', { from: holder, to: recipient, value: '1' });
  258. expectEvent(receipt, 'DelegateVotesChanged', { delegate: holder, previousBalance: supply, newBalance: supply.subn(1) });
  259. this.holderVotes = supply.subn(1);
  260. this.recipientVotes = '0';
  261. });
  262. it('receiver delegation', async function () {
  263. await this.token.delegate(recipient, { from: recipient });
  264. const { receipt } = await this.token.transfer(recipient, 1, { from: holder });
  265. expectEvent(receipt, 'Transfer', { from: holder, to: recipient, value: '1' });
  266. expectEvent(receipt, 'DelegateVotesChanged', { delegate: recipient, previousBalance: '0', newBalance: '1' });
  267. this.holderVotes = '0';
  268. this.recipientVotes = '1';
  269. });
  270. it('full delegation', async function () {
  271. await this.token.delegate(holder, { from: holder });
  272. await this.token.delegate(recipient, { from: recipient });
  273. const { receipt } = await this.token.transfer(recipient, 1, { from: holder });
  274. expectEvent(receipt, 'Transfer', { from: holder, to: recipient, value: '1' });
  275. expectEvent(receipt, 'DelegateVotesChanged', { delegate: holder, previousBalance: supply, newBalance: supply.subn(1) });
  276. expectEvent(receipt, 'DelegateVotesChanged', { delegate: recipient, previousBalance: '0', newBalance: '1' });
  277. this.holderVotes = supply.subn(1);
  278. this.recipientVotes = '1';
  279. });
  280. afterEach(async function () {
  281. expect(await this.token.getCurrentVotes(holder)).to.be.bignumber.equal(this.holderVotes);
  282. expect(await this.token.getCurrentVotes(recipient)).to.be.bignumber.equal(this.recipientVotes);
  283. // need to advance 2 blocks to see the effect of a transfer on "getPriorVotes"
  284. const blockNumber = await time.latestBlock();
  285. await time.advanceBlock();
  286. expect(await this.token.getPriorVotes(holder, blockNumber)).to.be.bignumber.equal(this.holderVotes);
  287. expect(await this.token.getPriorVotes(recipient, blockNumber)).to.be.bignumber.equal(this.recipientVotes);
  288. });
  289. });
  290. // The following tests are a adaptation of https://github.com/compound-finance/compound-protocol/blob/master/tests/Governance/CompTest.js.
  291. describe('Compound test suite', function () {
  292. beforeEach(async function () {
  293. await this.token.mint(holder, supply);
  294. });
  295. describe('balanceOf', function () {
  296. it('grants to initial account', async function () {
  297. expect(await this.token.balanceOf(holder)).to.be.bignumber.equal('10000000000000000000000000');
  298. });
  299. });
  300. describe('numCheckpoints', function () {
  301. it('returns the number of checkpoints for a delegate', async function () {
  302. await this.token.transfer(recipient, '100', { from: holder }); //give an account a few tokens for readability
  303. expect(await this.token.numCheckpoints(other1)).to.be.bignumber.equal('0');
  304. const t1 = await this.token.delegate(other1, { from: recipient });
  305. expect(await this.token.numCheckpoints(other1)).to.be.bignumber.equal('1');
  306. const t2 = await this.token.transfer(other2, 10, { from: recipient });
  307. expect(await this.token.numCheckpoints(other1)).to.be.bignumber.equal('2');
  308. const t3 = await this.token.transfer(other2, 10, { from: recipient });
  309. expect(await this.token.numCheckpoints(other1)).to.be.bignumber.equal('3');
  310. const t4 = await this.token.transfer(recipient, 20, { from: holder });
  311. expect(await this.token.numCheckpoints(other1)).to.be.bignumber.equal('4');
  312. expect(await this.token.checkpoints(other1, 0)).to.be.deep.equal([ t1.receipt.blockNumber.toString(), '100' ]);
  313. expect(await this.token.checkpoints(other1, 1)).to.be.deep.equal([ t2.receipt.blockNumber.toString(), '90' ]);
  314. expect(await this.token.checkpoints(other1, 2)).to.be.deep.equal([ t3.receipt.blockNumber.toString(), '80' ]);
  315. expect(await this.token.checkpoints(other1, 3)).to.be.deep.equal([ t4.receipt.blockNumber.toString(), '100' ]);
  316. await time.advanceBlock();
  317. expect(await this.token.getPriorVotes(other1, t1.receipt.blockNumber)).to.be.bignumber.equal('100');
  318. expect(await this.token.getPriorVotes(other1, t2.receipt.blockNumber)).to.be.bignumber.equal('90');
  319. expect(await this.token.getPriorVotes(other1, t3.receipt.blockNumber)).to.be.bignumber.equal('80');
  320. expect(await this.token.getPriorVotes(other1, t4.receipt.blockNumber)).to.be.bignumber.equal('100');
  321. });
  322. it('does not add more than one checkpoint in a block', async function () {
  323. await this.token.transfer(recipient, '100', { from: holder });
  324. expect(await this.token.numCheckpoints(other1)).to.be.bignumber.equal('0');
  325. const [ t1, t2, t3 ] = await batchInBlock([
  326. () => this.token.delegate(other1, { from: recipient, gas: 100000 }),
  327. () => this.token.transfer(other2, 10, { from: recipient, gas: 100000 }),
  328. () => this.token.transfer(other2, 10, { from: recipient, gas: 100000 }),
  329. ]);
  330. expect(await this.token.numCheckpoints(other1)).to.be.bignumber.equal('1');
  331. expect(await this.token.checkpoints(other1, 0)).to.be.deep.equal([ t1.receipt.blockNumber.toString(), '80' ]);
  332. // expectReve(await this.token.checkpoints(other1, 1)).to.be.deep.equal([ '0', '0' ]); // Reverts due to array overflow check
  333. // expect(await this.token.checkpoints(other1, 2)).to.be.deep.equal([ '0', '0' ]); // Reverts due to array overflow check
  334. const t4 = await this.token.transfer(recipient, 20, { from: holder });
  335. expect(await this.token.numCheckpoints(other1)).to.be.bignumber.equal('2');
  336. expect(await this.token.checkpoints(other1, 1)).to.be.deep.equal([ t4.receipt.blockNumber.toString(), '100' ]);
  337. });
  338. });
  339. describe('getPriorVotes', function () {
  340. it('reverts if block number >= current block', async function () {
  341. await expectRevert(
  342. this.token.getPriorVotes(other1, 5e10),
  343. 'ERC20Votes: block not yet mined',
  344. );
  345. });
  346. it('returns 0 if there are no checkpoints', async function () {
  347. expect(await this.token.getPriorVotes(other1, 0)).to.be.bignumber.equal('0');
  348. });
  349. it('returns the latest block if >= last checkpoint block', async function () {
  350. const t1 = await this.token.delegate(other1, { from: holder });
  351. await time.advanceBlock();
  352. await time.advanceBlock();
  353. expect(await this.token.getPriorVotes(other1, t1.receipt.blockNumber)).to.be.bignumber.equal('10000000000000000000000000');
  354. expect(await this.token.getPriorVotes(other1, t1.receipt.blockNumber + 1)).to.be.bignumber.equal('10000000000000000000000000');
  355. });
  356. it('returns zero if < first checkpoint block', async function () {
  357. await time.advanceBlock();
  358. const t1 = await this.token.delegate(other1, { from: holder });
  359. await time.advanceBlock();
  360. await time.advanceBlock();
  361. expect(await this.token.getPriorVotes(other1, t1.receipt.blockNumber - 1)).to.be.bignumber.equal('0');
  362. expect(await this.token.getPriorVotes(other1, t1.receipt.blockNumber + 1)).to.be.bignumber.equal('10000000000000000000000000');
  363. });
  364. it('generally returns the voting balance at the appropriate checkpoint', async function () {
  365. const t1 = await this.token.delegate(other1, { from: holder });
  366. await time.advanceBlock();
  367. await time.advanceBlock();
  368. const t2 = await this.token.transfer(other2, 10, { from: holder });
  369. await time.advanceBlock();
  370. await time.advanceBlock();
  371. const t3 = await this.token.transfer(other2, 10, { from: holder });
  372. await time.advanceBlock();
  373. await time.advanceBlock();
  374. const t4 = await this.token.transfer(holder, 20, { from: other2 });
  375. await time.advanceBlock();
  376. await time.advanceBlock();
  377. expect(await this.token.getPriorVotes(other1, t1.receipt.blockNumber - 1)).to.be.bignumber.equal('0');
  378. expect(await this.token.getPriorVotes(other1, t1.receipt.blockNumber)).to.be.bignumber.equal('10000000000000000000000000');
  379. expect(await this.token.getPriorVotes(other1, t1.receipt.blockNumber + 1)).to.be.bignumber.equal('10000000000000000000000000');
  380. expect(await this.token.getPriorVotes(other1, t2.receipt.blockNumber)).to.be.bignumber.equal('9999999999999999999999990');
  381. expect(await this.token.getPriorVotes(other1, t2.receipt.blockNumber + 1)).to.be.bignumber.equal('9999999999999999999999990');
  382. expect(await this.token.getPriorVotes(other1, t3.receipt.blockNumber)).to.be.bignumber.equal('9999999999999999999999980');
  383. expect(await this.token.getPriorVotes(other1, t3.receipt.blockNumber + 1)).to.be.bignumber.equal('9999999999999999999999980');
  384. expect(await this.token.getPriorVotes(other1, t4.receipt.blockNumber)).to.be.bignumber.equal('10000000000000000000000000');
  385. expect(await this.token.getPriorVotes(other1, t4.receipt.blockNumber + 1)).to.be.bignumber.equal('10000000000000000000000000');
  386. });
  387. });
  388. });
  389. describe('getPastTotalSupply', function () {
  390. beforeEach(async function () {
  391. await this.token.delegate(holder, { from: holder });
  392. });
  393. it('reverts if block number >= current block', async function () {
  394. await expectRevert(
  395. this.token.getPastTotalSupply(5e10),
  396. 'ERC20Votes: block not yet mined',
  397. );
  398. });
  399. it('returns 0 if there are no checkpoints', async function () {
  400. expect(await this.token.getPastTotalSupply(0)).to.be.bignumber.equal('0');
  401. });
  402. it('returns the latest block if >= last checkpoint block', async function () {
  403. t1 = await this.token.mint(holder, supply);
  404. await time.advanceBlock();
  405. await time.advanceBlock();
  406. expect(await this.token.getPastTotalSupply(t1.receipt.blockNumber)).to.be.bignumber.equal(supply);
  407. expect(await this.token.getPastTotalSupply(t1.receipt.blockNumber + 1)).to.be.bignumber.equal(supply);
  408. });
  409. it('returns zero if < first checkpoint block', async function () {
  410. await time.advanceBlock();
  411. const t1 = await this.token.mint(holder, supply);
  412. await time.advanceBlock();
  413. await time.advanceBlock();
  414. expect(await this.token.getPastTotalSupply(t1.receipt.blockNumber - 1)).to.be.bignumber.equal('0');
  415. expect(await this.token.getPastTotalSupply(t1.receipt.blockNumber + 1)).to.be.bignumber.equal('10000000000000000000000000');
  416. });
  417. it('generally returns the voting balance at the appropriate checkpoint', async function () {
  418. const t1 = await this.token.mint(holder, supply);
  419. await time.advanceBlock();
  420. await time.advanceBlock();
  421. const t2 = await this.token.burn(holder, 10);
  422. await time.advanceBlock();
  423. await time.advanceBlock();
  424. const t3 = await this.token.burn(holder, 10);
  425. await time.advanceBlock();
  426. await time.advanceBlock();
  427. const t4 = await this.token.mint(holder, 20);
  428. await time.advanceBlock();
  429. await time.advanceBlock();
  430. expect(await this.token.getPastTotalSupply(t1.receipt.blockNumber - 1)).to.be.bignumber.equal('0');
  431. expect(await this.token.getPastTotalSupply(t1.receipt.blockNumber)).to.be.bignumber.equal('10000000000000000000000000');
  432. expect(await this.token.getPastTotalSupply(t1.receipt.blockNumber + 1)).to.be.bignumber.equal('10000000000000000000000000');
  433. expect(await this.token.getPastTotalSupply(t2.receipt.blockNumber)).to.be.bignumber.equal('9999999999999999999999990');
  434. expect(await this.token.getPastTotalSupply(t2.receipt.blockNumber + 1)).to.be.bignumber.equal('9999999999999999999999990');
  435. expect(await this.token.getPastTotalSupply(t3.receipt.blockNumber)).to.be.bignumber.equal('9999999999999999999999980');
  436. expect(await this.token.getPastTotalSupply(t3.receipt.blockNumber + 1)).to.be.bignumber.equal('9999999999999999999999980');
  437. expect(await this.token.getPastTotalSupply(t4.receipt.blockNumber)).to.be.bignumber.equal('10000000000000000000000000');
  438. expect(await this.token.getPastTotalSupply(t4.receipt.blockNumber + 1)).to.be.bignumber.equal('10000000000000000000000000');
  439. });
  440. });
  441. });