ERC721Royalty.test.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. require('@openzeppelin/test-helpers');
  2. const { shouldBehaveLikeERC2981 } = require('../../common/ERC2981.behavior');
  3. const ERC721Royalty = artifacts.require('$ERC721Royalty');
  4. contract('ERC721Royalty', function (accounts) {
  5. const [account1, account2, recipient] = accounts;
  6. const tokenId1 = web3.utils.toBN('1');
  7. const tokenId2 = web3.utils.toBN('2');
  8. const royalty = web3.utils.toBN('200');
  9. const salePrice = web3.utils.toBN('1000');
  10. beforeEach(async function () {
  11. this.token = await ERC721Royalty.new('My Token', 'TKN');
  12. await this.token.$_mint(account1, tokenId1);
  13. await this.token.$_mint(account1, tokenId2);
  14. this.account1 = account1;
  15. this.account2 = account2;
  16. this.tokenId1 = tokenId1;
  17. this.tokenId2 = tokenId2;
  18. this.salePrice = salePrice;
  19. });
  20. describe('token specific functions', function () {
  21. beforeEach(async function () {
  22. await this.token.$_setTokenRoyalty(tokenId1, recipient, royalty);
  23. });
  24. it('royalty information are kept during burn and re-mint', async function () {
  25. await this.token.$_burn(tokenId1);
  26. const tokenInfoA = await this.token.royaltyInfo(tokenId1, salePrice);
  27. expect(tokenInfoA[0]).to.be.equal(recipient);
  28. expect(tokenInfoA[1]).to.be.bignumber.equal(salePrice.mul(royalty).divn(1e4));
  29. await this.token.$_mint(account2, tokenId1);
  30. const tokenInfoB = await this.token.royaltyInfo(tokenId1, salePrice);
  31. expect(tokenInfoB[0]).to.be.equal(recipient);
  32. expect(tokenInfoB[1]).to.be.bignumber.equal(salePrice.mul(royalty).divn(1e4));
  33. });
  34. });
  35. shouldBehaveLikeERC2981();
  36. });