mirror of
https://github.com/logos-storage/logos-storage-contracts-eth.git
synced 2026-01-02 13:23:10 +00:00
Export contract deployment custom error assert into a function
This commit is contained in:
parent
ec47be2685
commit
f2757067f6
@ -41,6 +41,7 @@ const {
|
||||
} = require("./evm")
|
||||
const { getBytes } = require("ethers")
|
||||
const MarketplaceModule = require("../ignition/modules/marketplace")
|
||||
const { assertDeploymentRejectedWithCustomError } = require("./util")
|
||||
|
||||
const ACCOUNT_STARTING_BALANCE = 1_000_000_000_000_000n
|
||||
|
||||
@ -67,13 +68,7 @@ describe("Marketplace constructor", function () {
|
||||
},
|
||||
})
|
||||
|
||||
const error = await expect(promise).to.be.rejected
|
||||
expect(error)
|
||||
.to.have.property("message")
|
||||
.that.contains(
|
||||
expectedError,
|
||||
`Expected error ${expectedError}, but got ${error.message}`
|
||||
)
|
||||
assertDeploymentRejectedWithCustomError(expectedError, promise)
|
||||
})
|
||||
}
|
||||
|
||||
@ -101,13 +96,10 @@ describe("Marketplace constructor", function () {
|
||||
},
|
||||
})
|
||||
|
||||
const error = await expect(promise).to.be.rejected
|
||||
expect(error)
|
||||
.to.have.property("message")
|
||||
.that.contains(
|
||||
expectedError,
|
||||
`Expected error ${expectedError}, but got ${error.message}`
|
||||
)
|
||||
assertDeploymentRejectedWithCustomError(
|
||||
"Marketplace_MaximumSlashingTooHigh",
|
||||
promise,
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
const { expect } = require("chai")
|
||||
const PeriodsModule = require("../ignition/modules/periods")
|
||||
const { assertDeploymentRejectedWithCustomError } = require("./util")
|
||||
|
||||
describe("Periods", function () {
|
||||
it("should revert when secondsPerPeriod is 0", async function () {
|
||||
@ -10,15 +11,11 @@ describe("Periods", function () {
|
||||
},
|
||||
},
|
||||
})
|
||||
const expectedError = "Periods_InvalidSecondsPerPeriod"
|
||||
|
||||
const error = await expect(promise).to.be.rejected
|
||||
expect(error)
|
||||
.to.have.property("message")
|
||||
.that.contains(
|
||||
expectedError,
|
||||
`Expected error ${expectedError}, but got ${error.message}`,
|
||||
)
|
||||
assertDeploymentRejectedWithCustomError(
|
||||
"Periods_InvalidSecondsPerPeriod",
|
||||
promise,
|
||||
)
|
||||
})
|
||||
|
||||
it("should not revert when secondsPerPeriod more than 0", async function () {
|
||||
|
||||
13
test/util.js
Normal file
13
test/util.js
Normal file
@ -0,0 +1,13 @@
|
||||
export async function assertDeploymentRejectedWithCustomError(
|
||||
customError,
|
||||
deploymentPromise,
|
||||
) {
|
||||
const error = await expect(deploymentPromise).to.be.rejected
|
||||
|
||||
expect(error)
|
||||
.to.have.property("message")
|
||||
.that.contains(
|
||||
customError,
|
||||
`Expected error ${expectedError}, but got ${error.message}`,
|
||||
)
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user