ERC20VotesComp.test.js 23 KB

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