add gas reporting
This commit is contained in:
parent
c03206c2b8
commit
355aa87d91
|
@ -10,7 +10,7 @@ pragma solidity ^0.8.8;
|
|||
contract AccountLocks {
|
||||
type LockId is bytes32;
|
||||
|
||||
uint256 public constant MAX_LOCKS_PER_ACCOUNT = 128;
|
||||
uint256 public constant MAX_LOCKS_PER_ACCOUNT = 256;
|
||||
|
||||
mapping(LockId => Lock) private locks;
|
||||
mapping(address => Account) private accounts;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
require("@nomiclabs/hardhat-waffle")
|
||||
require("hardhat-deploy")
|
||||
require("hardhat-deploy-ethers")
|
||||
require("hardhat-gas-reporter")
|
||||
|
||||
module.exports = {
|
||||
solidity: {
|
||||
|
@ -20,4 +21,8 @@ module.exports = {
|
|||
tags: ["local"],
|
||||
},
|
||||
},
|
||||
gasReporter: {
|
||||
enabled: process.env.REPORT_GAS ? true : false,
|
||||
showTimeSpent: true,
|
||||
},
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -17,6 +17,7 @@
|
|||
"hardhat": "^2.9.1",
|
||||
"hardhat-deploy": "^0.9.29",
|
||||
"hardhat-deploy-ethers": "^0.3.0-beta.13",
|
||||
"hardhat-gas-reporter": "^1.0.9",
|
||||
"prettier": "^2.5.1",
|
||||
"prettier-plugin-solidity": "^1.0.0-beta.19",
|
||||
"solhint": "^3.3.7"
|
||||
|
|
|
@ -107,6 +107,22 @@ describe("Marketplace", function () {
|
|||
"request already exists"
|
||||
)
|
||||
})
|
||||
|
||||
it("rejects request with more than 256 slots", async function () {
|
||||
await token.approve(marketplace.address, price(request) * 2)
|
||||
request.ask.slots = 257
|
||||
await expect(marketplace.requestStorage(request)).to.be.revertedWith(
|
||||
"Max slots exceeded"
|
||||
)
|
||||
})
|
||||
|
||||
it("rejects request with more than 256 max slot loss", async function () {
|
||||
await token.approve(marketplace.address, price(request) * 2)
|
||||
request.ask.maxSlotLoss = 257
|
||||
await expect(marketplace.requestStorage(request)).to.be.revertedWith(
|
||||
"Max slot loss exceeded"
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe("filling a slot", function () {
|
||||
|
@ -817,4 +833,30 @@ describe("Marketplace", function () {
|
|||
expect(await marketplace.mySlots()).to.not.contain(slotId(slot))
|
||||
})
|
||||
})
|
||||
|
||||
describe.only("gas reporting limits", function () {
|
||||
before(function () {
|
||||
if (!process.env.REPORT_GAS) {
|
||||
this.skip()
|
||||
}
|
||||
})
|
||||
beforeEach(async function () {
|
||||
switchAccount(host)
|
||||
await token.approve(marketplace.address, collateral)
|
||||
await marketplace.deposit(collateral)
|
||||
})
|
||||
it("tests maximum slots with a minimum slot loss", async function () {
|
||||
this.timeout(100000)
|
||||
|
||||
switchAccount(client)
|
||||
request.ask.slots = 256
|
||||
request.ask.maxSlotLoss = 1
|
||||
slot.request = requestId(request)
|
||||
await token.approve(marketplace.address, price(request))
|
||||
await marketplace.requestStorage(request)
|
||||
switchAccount(host)
|
||||
await waitUntilStarted(marketplace, request, proof)
|
||||
await waitUntilFailed(marketplace, request, slot)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue