ERC20Votes.test.js 23 KB

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