Use hardhat-exposed to reduce the need for mocks (#3666)

Co-authored-by: Francisco <fg@frang.io>
This commit is contained in:
Hadrien Croubois
2023-01-03 15:38:13 +01:00
committed by GitHub
parent a81b0d0b21
commit c1d9da4052
190 changed files with 2297 additions and 4311 deletions

View File

@ -11,7 +11,7 @@ function shouldBehaveLikeERC2981 () {
describe('default royalty', function () {
beforeEach(async function () {
await this.token.setDefaultRoyalty(this.account1, royaltyFraction);
await this.token.$_setDefaultRoyalty(this.account1, royaltyFraction);
});
it('checks royalty is set', async function () {
@ -27,7 +27,7 @@ function shouldBehaveLikeERC2981 () {
const newPercentage = new BN('25');
// Updated royalty check
await this.token.setDefaultRoyalty(this.account1, newPercentage);
await this.token.$_setDefaultRoyalty(this.account1, newPercentage);
const royalty = new BN((this.salePrice * newPercentage) / 10000);
const newInfo = await this.token.royaltyInfo(this.tokenId1, this.salePrice);
@ -37,7 +37,7 @@ function shouldBehaveLikeERC2981 () {
it('holds same royalty value for different tokens', async function () {
const newPercentage = new BN('20');
await this.token.setDefaultRoyalty(this.account1, newPercentage);
await this.token.$_setDefaultRoyalty(this.account1, newPercentage);
const token1Info = await this.token.royaltyInfo(this.tokenId1, this.salePrice);
const token2Info = await this.token.royaltyInfo(this.tokenId2, this.salePrice);
@ -47,7 +47,7 @@ function shouldBehaveLikeERC2981 () {
it('Remove royalty information', async function () {
const newValue = new BN('0');
await this.token.deleteDefaultRoyalty();
await this.token.$_deleteDefaultRoyalty();
const token1Info = await this.token.royaltyInfo(this.tokenId1, this.salePrice);
const token2Info = await this.token.royaltyInfo(this.tokenId2, this.salePrice);
@ -61,12 +61,12 @@ function shouldBehaveLikeERC2981 () {
it('reverts if invalid parameters', async function () {
await expectRevert(
this.token.setDefaultRoyalty(ZERO_ADDRESS, royaltyFraction),
this.token.$_setDefaultRoyalty(ZERO_ADDRESS, royaltyFraction),
'ERC2981: invalid receiver',
);
await expectRevert(
this.token.setDefaultRoyalty(this.account1, new BN('11000')),
this.token.$_setDefaultRoyalty(this.account1, new BN('11000')),
'ERC2981: royalty fee will exceed salePrice',
);
});
@ -74,7 +74,7 @@ function shouldBehaveLikeERC2981 () {
describe('token based royalty', function () {
beforeEach(async function () {
await this.token.setTokenRoyalty(this.tokenId1, this.account1, royaltyFraction);
await this.token.$_setTokenRoyalty(this.tokenId1, this.account1, royaltyFraction);
});
it('updates royalty amount', async function () {
@ -87,7 +87,7 @@ function shouldBehaveLikeERC2981 () {
expect(initInfo[1]).to.be.bignumber.equal(royalty);
// Updated royalty check
await this.token.setTokenRoyalty(this.tokenId1, this.account1, newPercentage);
await this.token.$_setTokenRoyalty(this.tokenId1, this.account1, newPercentage);
royalty = new BN((this.salePrice * newPercentage) / 10000);
const newInfo = await this.token.royaltyInfo(this.tokenId1, this.salePrice);
@ -97,7 +97,7 @@ function shouldBehaveLikeERC2981 () {
it('holds different values for different tokens', async function () {
const newPercentage = new BN('20');
await this.token.setTokenRoyalty(this.tokenId2, this.account1, newPercentage);
await this.token.$_setTokenRoyalty(this.tokenId2, this.account1, newPercentage);
const token1Info = await this.token.royaltyInfo(this.tokenId1, this.salePrice);
const token2Info = await this.token.royaltyInfo(this.tokenId2, this.salePrice);
@ -108,12 +108,12 @@ function shouldBehaveLikeERC2981 () {
it('reverts if invalid parameters', async function () {
await expectRevert(
this.token.setTokenRoyalty(this.tokenId1, ZERO_ADDRESS, royaltyFraction),
this.token.$_setTokenRoyalty(this.tokenId1, ZERO_ADDRESS, royaltyFraction),
'ERC2981: Invalid parameters',
);
await expectRevert(
this.token.setTokenRoyalty(this.tokenId1, this.account1, new BN('11000')),
this.token.$_setTokenRoyalty(this.tokenId1, this.account1, new BN('11000')),
'ERC2981: royalty fee will exceed salePrice',
);
});
@ -121,7 +121,7 @@ function shouldBehaveLikeERC2981 () {
it('can reset token after setting royalty', async function () {
const newPercentage = new BN('30');
const royalty = new BN((this.salePrice * newPercentage) / 10000);
await this.token.setTokenRoyalty(this.tokenId1, this.account2, newPercentage);
await this.token.$_setTokenRoyalty(this.tokenId1, this.account2, newPercentage);
const tokenInfo = await this.token.royaltyInfo(this.tokenId1, this.salePrice);
@ -129,7 +129,7 @@ function shouldBehaveLikeERC2981 () {
expect(tokenInfo[1]).to.be.bignumber.equal(royalty);
expect(tokenInfo[0]).to.be.equal(this.account2);
await this.token.setTokenRoyalty(this.tokenId2, this.account1, new BN('0'));
await this.token.$_setTokenRoyalty(this.tokenId2, this.account1, new BN('0'));
const result = await this.token.royaltyInfo(this.tokenId2, this.salePrice);
// Token must not share default information
expect(result[0]).to.be.equal(this.account1);
@ -140,7 +140,7 @@ function shouldBehaveLikeERC2981 () {
const newPercentage = new BN('30');
const royalty = new BN((this.salePrice * newPercentage) / 10000);
await this.token.setTokenRoyalty(this.tokenId2, this.account2, newPercentage);
await this.token.$_setTokenRoyalty(this.tokenId2, this.account2, newPercentage);
const token1Info = await this.token.royaltyInfo(this.tokenId1, this.salePrice);
const token2Info = await this.token.royaltyInfo(this.tokenId2, this.salePrice);