-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsample.test.js
More file actions
61 lines (52 loc) · 1.95 KB
/
Copy pathsample.test.js
File metadata and controls
61 lines (52 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
const { expect } = require("chai");
const { ethers } = require("hardhat");
const { loadFixture } = require("@nomicfoundation/hardhat-network-helpers");
const {
deployWithProxy,
expectEvent,
expectRevert,
expectCustomError,
} = require("./utils/helpers");
contract("SampleContract", function () {
const initParam = "name";
const stateParam = ethers.id("URI_SETTER_ROLE");
const fixture = async () => {
const [deployer, other] = await ethers.getSigners();
const contract = await ethers.deployContract("$ERC1155PausableBurnableSupply", [initParam], {
from: deployer,
});
// OR if its upgradable:
const contractUpgradable = await deployWithProxy("$LPToken", [initParam, initParam]);
return { deployer, other, contract, contractUpgradable };
};
beforeEach(async function () {
Object.assign(this, await loadFixture(fixture));
});
contract("SampleTest", function () {
it("SampleCondition", async function () {
// await expect(
// this.contractUpgradable.mint(this.other.address, 0n, { from: this.deployer })
// ).to.be.revertedWithCustomError(this.contractUpgradable, "LPTokenZeroMint");
// // above is the same with:
await expectCustomError(
this.contractUpgradable.connect(this.deployer).mint(this.other.address, 0n),
this.contractUpgradable,
"LPTokenZeroMint"
// no arguments is ok!
);
});
it("SampleCondition for Upgradable", async function () {
// // connect!
// await expect(this.contract.connect(this.other).setURI("newUri"))
// .to.be.revertedWithCustomError(this.contract, "AccessControlUnauthorizedAccount")
// .withArgs(this.other.address, stateParam);
// // above is the same with:
await expectCustomError(
this.contract.connect(this.other).setURI("newUri"),
this.contract,
"AccessControlUnauthorizedAccount",
[this.other.address, stateParam]
);
});
});
});