-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a4ec8b8
commit 5a52ca8
Showing
1 changed file
with
116 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
); | ||
}); | ||
}); | ||
}); |
5a52ca8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coverage for this commit
Coverage Report