ERC721Royalty.test.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. const { BN, constants } = require('@openzeppelin/test-helpers');
  2. const ERC721RoyaltyMock = artifacts.require('ERC721RoyaltyMock');
  3. const { ZERO_ADDRESS } = constants;
  4. const { shouldBehaveLikeERC2981 } = require('../../common/ERC2981.behavior');
  5. contract('ERC721Royalty', function (accounts) {
  6. const [ account1, account2 ] = accounts;
  7. const tokenId1 = new BN('1');
  8. const tokenId2 = new BN('2');
  9. const royalty = new BN('200');
  10. const salePrice = new BN('1000');
  11. beforeEach(async function () {
  12. this.token = await ERC721RoyaltyMock.new('My Token', 'TKN');
  13. await this.token.mint(account1, tokenId1);
  14. await this.token.mint(account1, tokenId2);
  15. this.account1 = account1;
  16. this.account2 = account2;
  17. this.tokenId1 = tokenId1;
  18. this.tokenId2 = tokenId2;
  19. this.salePrice = salePrice;
  20. });
  21. describe('token specific functions', function () {
  22. beforeEach(async function () {
  23. await this.token.setTokenRoyalty(tokenId1, account1, royalty);
  24. });
  25. it('removes royalty information after burn', async function () {
  26. await this.token.burn(tokenId1);
  27. const tokenInfo = await this.token.royaltyInfo(tokenId1, salePrice);
  28. expect(tokenInfo[0]).to.be.equal(ZERO_ADDRESS);
  29. expect(tokenInfo[1]).to.be.bignumber.equal(new BN('0'));
  30. });
  31. });
  32. shouldBehaveLikeERC2981();
  33. });