From 81a63f3eeee241ba2316122cbf8a35d9a525bfc1 Mon Sep 17 00:00:00 2001 From: Ayush Tiwari Date: Mon, 9 Oct 2023 20:44:04 +0530 Subject: [PATCH] refactor: updated contract name --- .../contracts/mocks/RoyaltyInfoMock.sol | 15 +++++++++++++++ .../test/exchange/RoyaltiesRegistry.test.ts | 13 +++++-------- packages/marketplace/test/fixtures.ts | 10 ++++------ 3 files changed, 24 insertions(+), 14 deletions(-) create mode 100644 packages/marketplace/contracts/mocks/RoyaltyInfoMock.sol diff --git a/packages/marketplace/contracts/mocks/RoyaltyInfoMock.sol b/packages/marketplace/contracts/mocks/RoyaltyInfoMock.sol new file mode 100644 index 0000000000..3234b8b7cf --- /dev/null +++ b/packages/marketplace/contracts/mocks/RoyaltyInfoMock.sol @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: MIT + +pragma solidity 0.8.21; + +/// @title RoyaltyInfoMock Contract +/// @dev Implements royaltyInfo function but not supportInferace. +/// @dev used to execute getRoyalties() in RoyaltiesRegistry contract with royaltyType = 3 +contract RoyaltyInfoMock { + function royaltyInfo( + uint256 /* _tokenId */, + uint256 /* _salePrice */ + ) external view returns (address receiver, uint256 royaltyAmount) { + return (msg.sender, 0); + } +} diff --git a/packages/marketplace/test/exchange/RoyaltiesRegistry.test.ts b/packages/marketplace/test/exchange/RoyaltiesRegistry.test.ts index 3e68030583..adcef4904b 100644 --- a/packages/marketplace/test/exchange/RoyaltiesRegistry.test.ts +++ b/packages/marketplace/test/exchange/RoyaltiesRegistry.test.ts @@ -369,27 +369,24 @@ describe('RoyaltiesRegistry.sol', function () { }); it('should getRoyalties for token with royaltiesType 3 that only implements royaltyInfo', async function () { - const { - RoyaltiesRegistryAsDeployer, - RoyaltiesRegistryAsUser, - TestRoyaltyInfo, - } = await loadFixture(deployFixtures); + const {RoyaltiesRegistryAsDeployer, RoyaltiesRegistryAsUser, RoyaltyInfo} = + await loadFixture(deployFixtures); await loadFixture(deployFixtures); await RoyaltiesRegistryAsDeployer.forceSetRoyaltiesType( - await TestRoyaltyInfo.getAddress(), + await RoyaltyInfo.getAddress(), 3 ); expect( await RoyaltiesRegistryAsUser.getRoyaltiesType( - await TestRoyaltyInfo.getAddress() + await RoyaltyInfo.getAddress() ) ).to.be.equal(3); expect( await RoyaltiesRegistryAsUser.getRoyalties.staticCall( - await TestRoyaltyInfo.getAddress(), + await RoyaltyInfo.getAddress(), 1 ) ).to.be.deep.eq([]); diff --git a/packages/marketplace/test/fixtures.ts b/packages/marketplace/test/fixtures.ts index c735de128e..50effd09de 100644 --- a/packages/marketplace/test/fixtures.ts +++ b/packages/marketplace/test/fixtures.ts @@ -107,11 +107,9 @@ async function deploy() { ); await TestERC721WithRoyaltyWithoutIROYALTYUGC.waitForDeployment(); - const TestRoyaltyInfoFactory = await ethers.getContractFactory( - 'TestRoyaltyInfo' - ); - const TestRoyaltyInfo = await TestRoyaltyInfoFactory.deploy(); - await TestRoyaltyInfo.waitForDeployment(); + const RoyaltyInfoFactory = await ethers.getContractFactory('RoyaltyInfoMock'); + const RoyaltyInfo = await RoyaltyInfoFactory.deploy(); + await RoyaltyInfo.waitForDeployment(); const ERC20ContractFactory = await ethers.getContractFactory('TestERC20'); const ERC20Contract = await ERC20ContractFactory.deploy(); @@ -167,7 +165,7 @@ async function deploy() { ERC721WithRoyalty, ERC1155WithRoyalty, TestERC721WithRoyaltyWithoutIROYALTYUGC, - TestRoyaltyInfo, + RoyaltyInfo, RoyaltiesProvider, ERC1271Contract, deployer,