mirror of
https://github.com/status-im/dagger-contracts.git
synced 2025-01-24 13:30:03 +00:00
33010bd20c
* feat(slot-reservations): Allow slots to be reserved Closes #175. Allows reservation of slots, without an implementation of the expanding window. - Add a function called `reserveSlot(address, SlotId)`, that allows three unique addresses per slot to be reserved, that returns bool if successful. - Use `mapping(SlotId => EnumerableSet.AddressSet)` - Return false if the address could not be added to the set (if `EnumerableSet.add` returns false) - Add `canReserveSlot(address, SlotId)` - Return `true` if set of reservations is less than 3 and the set doesn't already contain the address - Return `true` otherwise (for now, later add in logic for checking the address is inside the expanding window) - Call `canReserveSlot` from `reserveSlot` as a `require` or invariant - Add `SlotReservations` configuration struct to the network-level config, with `maxReservations`
39 lines
966 B
Solidity
39 lines
966 B
Solidity
// SPDX-License-Identifier: MIT
|
|
pragma solidity ^0.8.23;
|
|
|
|
import "./TestToken.sol";
|
|
import "./Marketplace.sol";
|
|
import "./TestVerifier.sol";
|
|
|
|
contract FuzzMarketplace is Marketplace {
|
|
constructor()
|
|
Marketplace(
|
|
MarketplaceConfig(
|
|
CollateralConfig(10, 5, 3, 10),
|
|
ProofConfig(10, 5, 64, "", 67),
|
|
SlotReservationsConfig(20)
|
|
),
|
|
new TestToken(),
|
|
new TestVerifier()
|
|
)
|
|
// solhint-disable-next-line no-empty-blocks
|
|
{
|
|
|
|
}
|
|
|
|
// Properties to be tested through fuzzing
|
|
|
|
MarketplaceTotals private _lastSeenTotals;
|
|
|
|
function neverDecreaseTotals() public {
|
|
assert(_marketplaceTotals.received >= _lastSeenTotals.received);
|
|
assert(_marketplaceTotals.sent >= _lastSeenTotals.sent);
|
|
_lastSeenTotals = _marketplaceTotals;
|
|
}
|
|
|
|
function neverLoseFunds() public view {
|
|
uint256 total = _marketplaceTotals.received - _marketplaceTotals.sent;
|
|
assert(token().balanceOf(address(this)) >= total);
|
|
}
|
|
}
|