mirror of
https://github.com/logos-storage/logos-storage-contracts-eth.git
synced 2026-01-05 06:43:07 +00:00
Update Vault tests for ignition
This commit is contained in:
parent
110ac8197a
commit
0807f7d52c
@ -98,7 +98,7 @@ describe("Marketplace constructor", function () {
|
||||
|
||||
assertDeploymentRejectedWithCustomError(
|
||||
"Marketplace_MaximumSlashingTooHigh",
|
||||
promise,
|
||||
promise
|
||||
)
|
||||
})
|
||||
})
|
||||
@ -109,7 +109,6 @@ describe("Marketplace", function () {
|
||||
|
||||
let marketplace
|
||||
let token
|
||||
let verifier
|
||||
let client,
|
||||
clientWithdrawRecipient,
|
||||
host,
|
||||
@ -672,7 +671,7 @@ describe("Marketplace", function () {
|
||||
// Make a reservation from another host
|
||||
switchAccount(host2)
|
||||
collateral = collateralPerSlot(request)
|
||||
await token.approve(marketplace.address, collateral)
|
||||
await token.approve(await marketplace.getAddress(), collateral)
|
||||
await marketplace.reserveSlot(slot.request, slot.index)
|
||||
|
||||
// Switch host and free the slot
|
||||
@ -687,7 +686,7 @@ describe("Marketplace", function () {
|
||||
await marketplace.reserveSlot(slot.request, slot.index)
|
||||
let currPeriod = periodOf(await currentTime())
|
||||
await advanceTimeTo(periodEnd(currPeriod) + 1)
|
||||
await token.approve(marketplace.address, collateral)
|
||||
await token.approve(await marketplace.getAddress(), collateral)
|
||||
await marketplace.fillSlot(slot.request, slot.index, proof)
|
||||
})
|
||||
})
|
||||
@ -1130,10 +1129,8 @@ describe("Marketplace", function () {
|
||||
clientWithdrawRecipient.address
|
||||
)
|
||||
const endBalance = await token.balanceOf(clientWithdrawRecipient.address)
|
||||
expect(endBalance - ACCOUNT_STARTING_BALANCE).to.equal(
|
||||
maxPrice(request) - expectedPartialhostRewardRecipient
|
||||
expect(endBalance - startBalance).to.equal(
|
||||
maxPrice(request) - expectedPartialhostRewardRecipient,
|
||||
maxPrice(request) - expectedPartialhostRewardRecipient
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
15
test/evm.js
15
test/evm.js
@ -2,27 +2,32 @@ const {
|
||||
time,
|
||||
mine,
|
||||
takeSnapshot,
|
||||
setNextBlockTimestamp,
|
||||
} = require("@nomicfoundation/hardhat-network-helpers")
|
||||
const hre = require("hardhat")
|
||||
const provider = hre.network.provider
|
||||
|
||||
const snapshots = []
|
||||
|
||||
async function snapshot() {
|
||||
const snapshot = await takeSnapshot()
|
||||
const automine = await ethers.provider.send("hardhat_getAutomine")
|
||||
const time = await currentTime()
|
||||
const automine = await provider.send("hardhat_getAutomine")
|
||||
snapshots.push({ snapshot, automine, time })
|
||||
}
|
||||
|
||||
async function revert() {
|
||||
const { snapshot, time, automine } = snapshots.pop()
|
||||
if (snapshot) {
|
||||
setNextBlockTimestamp(time)
|
||||
await ethers.provider.send("evm_setAutomine", [automine])
|
||||
return snapshot.restore()
|
||||
await snapshot.restore()
|
||||
await setNextBlockTimestamp(time)
|
||||
await provider.send("evm_setAutomine", [automine])
|
||||
}
|
||||
}
|
||||
|
||||
async function setAutomine(enabled) {
|
||||
await provider.send("evm_setAutomine", [enabled])
|
||||
}
|
||||
|
||||
async function ensureMinimumBlockHeight(height) {
|
||||
while ((await time.latestBlock()) < height) {
|
||||
await mine()
|
||||
|
||||
@ -1,13 +1,15 @@
|
||||
export async function assertDeploymentRejectedWithCustomError(
|
||||
customError,
|
||||
deploymentPromise,
|
||||
) {
|
||||
const error = await expect(deploymentPromise).to.be.rejected
|
||||
module.exports = {
|
||||
assertDeploymentRejectedWithCustomError: async function (
|
||||
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}`,
|
||||
)
|
||||
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