Skip to content

Commit

Permalink
Merge branch 'asset-l2-integration' of https://github.com/thesandboxg…
Browse files Browse the repository at this point in the history
…ame/sandbox-smart-contracts into integration-tests
  • Loading branch information
wojciech-turek committed Aug 16, 2023
2 parents 867f4ea + 0ffa0dc commit fd2398c
Show file tree
Hide file tree
Showing 7 changed files with 401 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

0 comments on commit fd2398c

Please sign in to comment.