ERC1155Supply.test.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. const { BN } = require('@openzeppelin/test-helpers');
  2. const { expect } = require('chai');
  3. const ERC1155Supply = artifacts.require('$ERC1155Supply');
  4. contract('ERC1155Supply', function (accounts) {
  5. const [holder] = accounts;
  6. const uri = 'https://token.com';
  7. const firstTokenId = new BN('37');
  8. const firstTokenAmount = new BN('42');
  9. const secondTokenId = new BN('19842');
  10. const secondTokenAmount = new BN('23');
  11. beforeEach(async function () {
  12. this.token = await ERC1155Supply.new(uri);
  13. });
  14. context('before mint', function () {
  15. it('exist', async function () {
  16. expect(await this.token.exists(firstTokenId)).to.be.equal(false);
  17. });
  18. it('totalSupply', async function () {
  19. expect(await this.token.totalSupply(firstTokenId)).to.be.bignumber.equal('0');
  20. });
  21. });
  22. context('after mint', function () {
  23. context('single', function () {
  24. beforeEach(async function () {
  25. await this.token.$_mint(holder, firstTokenId, firstTokenAmount, '0x');
  26. });
  27. it('exist', async function () {
  28. expect(await this.token.exists(firstTokenId)).to.be.equal(true);
  29. });
  30. it('totalSupply', async function () {
  31. expect(await this.token.totalSupply(firstTokenId)).to.be.bignumber.equal(firstTokenAmount);
  32. });
  33. });
  34. context('batch', function () {
  35. beforeEach(async function () {
  36. await this.token.$_mintBatch(
  37. holder,
  38. [firstTokenId, secondTokenId],
  39. [firstTokenAmount, secondTokenAmount],
  40. '0x',
  41. );
  42. });
  43. it('exist', async function () {
  44. expect(await this.token.exists(firstTokenId)).to.be.equal(true);
  45. expect(await this.token.exists(secondTokenId)).to.be.equal(true);
  46. });
  47. it('totalSupply', async function () {
  48. expect(await this.token.totalSupply(firstTokenId)).to.be.bignumber.equal(firstTokenAmount);
  49. expect(await this.token.totalSupply(secondTokenId)).to.be.bignumber.equal(secondTokenAmount);
  50. });
  51. });
  52. });
  53. context('after burn', function () {
  54. context('single', function () {
  55. beforeEach(async function () {
  56. await this.token.$_mint(holder, firstTokenId, firstTokenAmount, '0x');
  57. await this.token.$_burn(holder, firstTokenId, firstTokenAmount);
  58. });
  59. it('exist', async function () {
  60. expect(await this.token.exists(firstTokenId)).to.be.equal(false);
  61. });
  62. it('totalSupply', async function () {
  63. expect(await this.token.totalSupply(firstTokenId)).to.be.bignumber.equal('0');
  64. });
  65. });
  66. context('batch', function () {
  67. beforeEach(async function () {
  68. await this.token.$_mintBatch(
  69. holder,
  70. [firstTokenId, secondTokenId],
  71. [firstTokenAmount, secondTokenAmount],
  72. '0x',
  73. );
  74. await this.token.$_burnBatch(holder, [firstTokenId, secondTokenId], [firstTokenAmount, secondTokenAmount]);
  75. });
  76. it('exist', async function () {
  77. expect(await this.token.exists(firstTokenId)).to.be.equal(false);
  78. expect(await this.token.exists(secondTokenId)).to.be.equal(false);
  79. });
  80. it('totalSupply', async function () {
  81. expect(await this.token.totalSupply(firstTokenId)).to.be.bignumber.equal('0');
  82. expect(await this.token.totalSupply(secondTokenId)).to.be.bignumber.equal('0');
  83. });
  84. });
  85. });
  86. });