Skip to content

Commit

Permalink
Merge pull request #1095 from thesandboxgame/task/add-intregration-tests
Browse files Browse the repository at this point in the history
Added integration tests
  • Loading branch information
wojciech-turek authored Aug 16, 2023
2 parents 8ea8af0 + 520949d commit 0ffa0dc
Show file tree
Hide file tree
Showing 9 changed files with 800 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/deploy/deploy/300_catalyst/302_catalyst_setup.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import {DeployFunction} from 'hardhat-deploy/types';
import {HardhatRuntimeEnvironment} from 'hardhat/types';

// TODO this should not be hardcoded here
export const royaltyAmount = 500;

const func: DeployFunction = async function (
hre: HardhatRuntimeEnvironment
): Promise<void> {
Expand Down Expand Up @@ -33,8 +36,7 @@ const func: DeployFunction = async function (

// set catalyst on Royalty Manager
const catalyst = await deployments.get('Catalyst');
// TODO this should not be hardcoded here
const royaltyAmount = 500;

if (
(await read(
'RoyaltyManager',
Expand Down
17 changes: 17 additions & 0 deletions packages/deploy/deploy_mocks/200_marketplace_1.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {HardhatRuntimeEnvironment} from 'hardhat/types';
import {DeployFunction} from 'hardhat-deploy/types';

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const {deployments, getNamedAccounts} = hre;
const {deploy} = deployments;

const {deployer} = await getNamedAccounts();
await deploy('MockERC1155MarketPlace1', {
from: deployer,
contract:
'@sandbox-smart-contracts/dependency-operator-filter/contracts/mock/MockMarketPlace1.sol:MockERC1155MarketPlace1',
log: true,
});
};
export default func;
func.tags = ['MockERC1155MarketPlace1'];
17 changes: 17 additions & 0 deletions packages/deploy/deploy_mocks/300_marketplace_2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {HardhatRuntimeEnvironment} from 'hardhat/types';
import {DeployFunction} from 'hardhat-deploy/types';

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const {deployments, getNamedAccounts} = hre;
const {deploy} = deployments;

const {deployer} = await getNamedAccounts();
await deploy('MockERC1155MarketPlace2', {
from: deployer,
contract:
'@sandbox-smart-contracts/dependency-operator-filter/contracts/mock/MockMarketPlace2.sol:MockERC1155MarketPlace2',
log: true,
});
};
export default func;
func.tags = ['MockERC1155MarketPlace2'];
17 changes: 17 additions & 0 deletions packages/deploy/deploy_mocks/400_marketplace_3.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {HardhatRuntimeEnvironment} from 'hardhat/types';
import {DeployFunction} from 'hardhat-deploy/types';

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const {deployments, getNamedAccounts} = hre;
const {deploy} = deployments;

const {deployer} = await getNamedAccounts();
await deploy('MockERC1155MarketPlace3', {
from: deployer,
contract:
'@sandbox-smart-contracts/dependency-operator-filter/contracts/mock/MockMarketPlace3.sol:MockERC1155MarketPlace3',
log: true,
});
};
export default func;
func.tags = ['MockERC1155MarketPlace3'];
17 changes: 17 additions & 0 deletions packages/deploy/deploy_mocks/500_marketplace_4.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {HardhatRuntimeEnvironment} from 'hardhat/types';
import {DeployFunction} from 'hardhat-deploy/types';

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const {deployments, getNamedAccounts} = hre;
const {deploy} = deployments;

const {deployer} = await getNamedAccounts();
await deploy('MockERC1155MarketPlace4', {
from: deployer,
contract:
'@sandbox-smart-contracts/dependency-operator-filter/contracts/mock/MockMarketPlace4.sol:MockERC1155MarketPlace4',
log: true,
});
};
export default func;
func.tags = ['MockERC1155MarketPlace4'];
103 changes: 103 additions & 0 deletions packages/deploy/test/asset/AssetReveal.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import {expect} from 'chai';
import {deployments} from 'hardhat';

const setupTest = deployments.createFixture(
async ({deployments, getNamedAccounts, ethers}) => {
const {assetAdmin, backendAuthWallet} = await getNamedAccounts();
await deployments.fixture('Asset');
const Asset = await deployments.get('Asset');
const AssetContract = await ethers.getContractAt('Asset', Asset.address);
const AssetReveal = await deployments.get('AssetReveal');
const AssetRevealContract = await ethers.getContractAt(
'AssetReveal',
AssetReveal.address
);
const Catalyst = await deployments.get('Catalyst');
const CatalystContract = await ethers.getContractAt(
'Catalyst',
Catalyst.address
);
const TRUSTED_FORWARDER = await deployments.get('TRUSTED_FORWARDER_V2');
const AuthSuperValidator = await deployments.get('AuthSuperValidator');
const AuthSuperValidatorContract = await ethers.getContractAt(
'AuthSuperValidator',
AuthSuperValidator.address
);

return {
AssetContract,
AssetRevealContract,
CatalystContract,
TRUSTED_FORWARDER,
AuthSuperValidatorContract,
assetAdmin,
backendAuthWallet,
};
}
);

describe('Asset Reveal', function () {
describe('Contract references', function () {
it('AuthSuperValidator', async function () {
const {AssetRevealContract, AuthSuperValidatorContract} =
await setupTest();
expect(await AssetRevealContract.getAuthValidator()).to.be.equal(
AuthSuperValidatorContract.address
);
});
it('Asset', async function () {
const {AssetRevealContract, AssetContract} = await setupTest();
expect(await AssetRevealContract.getAssetContract()).to.be.equal(
AssetContract.address
);
});
});
describe('Roles', function () {
it('Admin', async function () {
const {AssetRevealContract, assetAdmin} = await setupTest();
const defaultAdminRole = await AssetRevealContract.DEFAULT_ADMIN_ROLE();
expect(await AssetRevealContract.hasRole(defaultAdminRole, assetAdmin)).to
.be.true;
});
it("Asset's Minter role is granted to AssetReveal", async function () {
const {AssetRevealContract, AssetContract} = await setupTest();
const minterRole = await AssetContract.MINTER_ROLE();
expect(
await AssetContract.hasRole(minterRole, AssetRevealContract.address)
).to.be.true;
});
it('AuthSuperValidator signer is set to backendAuthWallet', async function () {
const {
AssetRevealContract,
AuthSuperValidatorContract,
backendAuthWallet,
} = await setupTest();
expect(
await AuthSuperValidatorContract.getSigner(AssetRevealContract.address)
).to.be.equal(backendAuthWallet);
expect(
await AuthSuperValidatorContract.getSigner(AssetRevealContract.address)
).to.be.equal(backendAuthWallet);
});
});
describe('EIP712', function () {
it("name is 'Sandbox Asset Reveal'", async function () {
const {AssetRevealContract} = await setupTest();
const eip712Domain = await AssetRevealContract.eip712Domain();
expect(eip712Domain.name).to.be.equal('Sandbox Asset Reveal');
});
it("version is '1.0'", async function () {
const {AssetRevealContract} = await setupTest();
const eip712Domain = await AssetRevealContract.eip712Domain();
expect(eip712Domain.version).to.be.equal('1.0');
});
});
describe('Trusted Forwarder', function () {
it('Trusted forwarder address is set correctly', async function () {
const {AssetRevealContract, TRUSTED_FORWARDER} = await setupTest();
expect(await AssetRevealContract.getTrustedForwarder()).to.be.equal(
TRUSTED_FORWARDER.address
);
});
});
});
Loading

1 comment on commit 0ffa0dc

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage for this commit

97.23%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
packages/asset/contracts
   Asset.sol94.53%89.58%96.43%98.08%108, 193, 298, 298–299, 70
   AssetCreate.sol93.42%75%100%100%125, 127, 160, 266, 64
   AssetReveal.sol96.60%87.50%100%100%138, 170, 365, 406, 68
   AuthSuperValidator.sol100%100%100%100%
   Catalyst.sol94.81%91.94%95.24%98.08%133, 135, 148, 160, 231, 88
packages/asset/contracts/interfaces
   IAsset.sol100%100%100%100%
   IAssetCreate.sol100%100%100%100%
   IAssetReveal.sol100%100%100%100%
   ICatalyst.sol100%100%100%100%
   ITokenUtils.sol100%100%100%100%
packages/asset/contracts/libraries
   TokenIdUtils.sol100%100%100%100%
packages/dependency-metatx/contracts
   ERC2771Handler.sol100%100%100%100%
   ERC2771HandlerAbstract.sol100%100%100%100%
   ERC2771HandlerUpgradeable.sol95.45%83.33%100%100%43
packages/dependency-metatx/contracts/test
   ERC2771HandlerTest.sol100%100%100%100%
   ERC2771HandlerUpgradeableTest.sol100%100%100%100%
   MockTrustedForwarder.sol0%0%0%0%15, 18–19, 19, 19–20
packages/dependency-operator-filter/contracts
   OperatorFiltererUpgradeable.sol88.64%85%100%90%14, 48–49, 58–59
   OperatorFilterSubscription.sol60%50%100%50%18–19
packages/dependency-operator-filter/contracts/interfaces
   IOperatorFilterRegistry.sol100%100%100%100%
packages/dependency-royalty-management/contracts
   MultiRoyaltyDistributor.sol88.71%62.50%100%97.44%101, 108, 41, 41, 41, 41, 70
   RoyaltyDistributor.sol90.91%50%100%100%44
   RoyaltyManager.sol96%86.36%100%100%100, 44, 94
   RoyaltySplitter.sol90.91%75%92.31%95.89%107, 147, 167, 176, 191, 228, 56, 63, 78
packages/dependency-royalty-management/contracts/interfaces
   IERC20Approve.sol100%100%100%100%
   IMultiRoyaltyDistributor.sol100%100%100%100%
   IMultiRoyaltyRecipients.sol100%100%100%100%
   IRoyaltyManager.sol100%100%100%100%
   IRoyaltyUGC.sol100%100%100%100%

Please sign in to comment.