mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-01-02 13:33:10 +00:00
fix(availabilities): use totalRemainingCollateral instead of totalCollateral for comparaison (#1229)
* Use totalRemainingCollateral instead of totalCollateral to compare the availability changes * Update test to use totalRemainingCollateral instead of totalCollateral when testing OnAvailabilitySaved * Reduce poll interval * Fix flaky test * Fix format
This commit is contained in:
parent
e43872d0b8
commit
ca869f6dce
@ -351,7 +351,8 @@ proc updateAvailability(
|
||||
|
||||
if oldAvailability.freeSize < obj.freeSize or oldAvailability.duration < obj.duration or
|
||||
oldAvailability.minPricePerBytePerSecond < obj.minPricePerBytePerSecond or
|
||||
oldAvailability.totalCollateral < obj.totalCollateral: # availability updated
|
||||
oldAvailability.totalRemainingCollateral < obj.totalRemainingCollateral:
|
||||
# availability updated
|
||||
# inform subscribers that Availability has been modified (with increased
|
||||
# size)
|
||||
if OnAvailabilitySaved =? self.OnAvailabilitySaved:
|
||||
|
||||
@ -427,22 +427,24 @@ asyncchecksuite "Reservations module":
|
||||
|
||||
check not called
|
||||
|
||||
test "OnAvailabilitySaved called when availability totalCollateral is increased":
|
||||
test "OnAvailabilitySaved called when availability totalRemainingCollateral is increased":
|
||||
var availability = createAvailability()
|
||||
var added: Availability
|
||||
reservations.OnAvailabilitySaved = proc(a: Availability) {.async: (raises: []).} =
|
||||
added = a
|
||||
availability.totalCollateral = availability.totalCollateral + 1.u256
|
||||
availability.totalRemainingCollateral =
|
||||
availability.totalRemainingCollateral + 1.u256
|
||||
discard await reservations.update(availability)
|
||||
|
||||
check added == availability
|
||||
|
||||
test "OnAvailabilitySaved is not called when availability totalCollateral is decreased":
|
||||
test "OnAvailabilitySaved is not called when availability totalRemainingCollateral is decreased":
|
||||
var availability = createAvailability()
|
||||
var called = false
|
||||
reservations.OnAvailabilitySaved = proc(a: Availability) {.async: (raises: []).} =
|
||||
called = true
|
||||
availability.totalCollateral = availability.totalCollateral - 1.u256
|
||||
availability.totalRemainingCollateral =
|
||||
availability.totalRemainingCollateral - 1.u256
|
||||
discard await reservations.update(availability)
|
||||
|
||||
check not called
|
||||
|
||||
@ -575,7 +575,7 @@ ethersuite "On-Chain Market":
|
||||
switchAccount(host)
|
||||
await market.reserveSlot(request.id, 0.uint64)
|
||||
await market.fillSlot(request.id, 0.uint64, proof, request.ask.collateralPerSlot)
|
||||
let filledAt = (await ethProvider.currentTime())
|
||||
let filledAt = await ethProvider.blockTime(BlockTag.latest)
|
||||
|
||||
for slotIndex in 1 ..< request.ask.slots:
|
||||
await market.reserveSlot(request.id, slotIndex.uint64)
|
||||
|
||||
@ -290,9 +290,7 @@ marketplacesuite "Marketplace payouts":
|
||||
await ethProvider.advanceTime(expiry.u256)
|
||||
|
||||
check eventually(
|
||||
await providerApi.saleStateIs(slotId, "SaleCancelled"),
|
||||
timeout = 5 * 1000,
|
||||
pollInterval = 200,
|
||||
await providerApi.saleStateIs(slotId, "SaleCancelled"), pollInterval = 100
|
||||
)
|
||||
|
||||
await advanceToNextPeriod()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user