Skip to content

Commit

Permalink
Add AssetCreate deploy tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wojciech-turek committed Aug 11, 2023
1 parent a4ec8b8 commit 5a52ca8
Showing 1 changed file with 116 additions and 0 deletions.
116 changes: 116 additions & 0 deletions packages/deploy/test/asset/AssetCreate.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
import {expect} from 'chai';
import {deployments} from 'hardhat';

const setupTest = deployments.createFixture(
async ({deployments, getNamedAccounts, ethers}) => {
const {assetAdmin, backendAuthWallet} = await getNamedAccounts();
await deployments.fixture();
const Asset = await deployments.get('Asset');
const AssetContract = await ethers.getContractAt('Asset', Asset.address);
const AssetCreate = await deployments.get('AssetCreate');
const AssetCreateContract = await ethers.getContractAt(
'AssetCreate',
AssetCreate.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,
AssetCreateContract,
CatalystContract,
TRUSTED_FORWARDER,
AuthSuperValidatorContract,
assetAdmin,
backendAuthWallet,
};
}
);

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

1 comment on commit 5a52ca8

@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.44%

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%100%0%0%15, 18–19
packages/dependency-operator-filter/contracts
   OperatorFiltererUpgradeable.sol88.64%85%100%90%13, 47–48, 57–58
   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.