-
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.
Merge pull request #1095 from thesandboxgame/task/add-intregration-tests
Added integration tests
- Loading branch information
Showing
9 changed files
with
800 additions
and
2 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
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,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']; |
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,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']; |
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,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']; |
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,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']; |
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,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 | ||
); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.
0ffa0dc
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