ERC20VotesComp.test.js 22 KB

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