mirror of
https://github.com/logos-storage/logos-storage-contracts-eth.git
synced 2026-01-04 06:13:09 +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")
|
} = require("./evm")
|
||||||
const { getBytes } = require("ethers")
|
const { getBytes } = require("ethers")
|
||||||
const MarketplaceModule = require("../ignition/modules/marketplace")
|
const MarketplaceModule = require("../ignition/modules/marketplace")
|
||||||
|
const { assertDeploymentRejectedWithCustomError } = require("./util")
|
||||||
|
|
||||||
const ACCOUNT_STARTING_BALANCE = 1_000_000_000_000_000n
|
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
|
assertDeploymentRejectedWithCustomError(expectedError, promise)
|
||||||
expect(error)
|
|
||||||
.to.have.property("message")
|
|
||||||
.that.contains(
|
|
||||||
expectedError,
|
|
||||||
`Expected error ${expectedError}, but got ${error.message}`
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,13 +96,10 @@ describe("Marketplace constructor", function () {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const error = await expect(promise).to.be.rejected
|
assertDeploymentRejectedWithCustomError(
|
||||||
expect(error)
|
"Marketplace_MaximumSlashingTooHigh",
|
||||||
.to.have.property("message")
|
promise,
|
||||||
.that.contains(
|
)
|
||||||
expectedError,
|
|
||||||
`Expected error ${expectedError}, but got ${error.message}`
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
const { expect } = require("chai")
|
const { expect } = require("chai")
|
||||||
const PeriodsModule = require("../ignition/modules/periods")
|
const PeriodsModule = require("../ignition/modules/periods")
|
||||||
|
const { assertDeploymentRejectedWithCustomError } = require("./util")
|
||||||
|
|
||||||
describe("Periods", function () {
|
describe("Periods", function () {
|
||||||
it("should revert when secondsPerPeriod is 0", async 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
|
assertDeploymentRejectedWithCustomError(
|
||||||
expect(error)
|
"Periods_InvalidSecondsPerPeriod",
|
||||||
.to.have.property("message")
|
promise,
|
||||||
.that.contains(
|
)
|
||||||
expectedError,
|
|
||||||
`Expected error ${expectedError}, but got ${error.message}`,
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should not revert when secondsPerPeriod more than 0", async function () {
|
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