Add availability enabled parameter

This commit is contained in:
Arnaud 2025-01-29 17:20:02 +01:00
parent fc971feecf
commit 2dd0cb4e6a
No known key found for this signature in database
GPG Key ID: 69D6CE281FCAE663
4 changed files with 27 additions and 2 deletions

View File

@ -364,7 +364,7 @@ asyncchecksuite "Reservations module":
a: Availability
) {.gcsafe, async: (raises: []).} =
called = true
availability.freeSize -= 1.u256
availability.freeSize -= 1.uint64
discard await reservations.update(availability)
check not called

View File

@ -369,7 +369,7 @@ asyncchecksuite "Sales":
): Future[?!void] {.async.} =
slotIndex = slot
let blk = bt.Block.new(@[1.byte]).get
await onBatch(blk.repeat(request.ask.slotSize.truncate(int)))
await onBatch(blk.repeat(request.ask.slotSize))
let sold = newFuture[void]()
sales.onSale = proc(request: StorageRequest, slotIndex: uint64) =

View File

@ -42,6 +42,19 @@ twonodessuite "REST API":
space.quotaUsedBytes == 65592.NBytes
space.quotaReservedBytes == 12.NBytes
test "created correctly an availability when not enabled by default", twoNodesConfig:
let totalSize = 12.u256
let minPricePerBytePerSecond = 1.u256
let totalCollateral = totalSize * minPricePerBytePerSecond
let availability = client1.postAvailability(
totalSize = totalSize,
duration = 2.u256,
minPricePerBytePerSecond = minPricePerBytePerSecond,
totalCollateral = totalCollateral,
enabled = false.some,
).get
check availability.enabled == false
test "node lists local files", twoNodesConfig:
let content1 = "some file contents"
let content2 = "some other contents"

View File

@ -135,6 +135,18 @@ multinodesuite "Sales":
check updatedAvailability.totalSize == 100000
check updatedAvailability.freeSize == 100000
test "updating availability - updating enabled", salesConfig:
let availability = host.postAvailability(
totalSize = 140000.u256,
duration = 200.u256,
minPricePerBytePerSecond = 3.u256,
totalCollateral = 300.u256,
enabled = true.some,
).get
host.patchAvailability(availability.id, enabled = false.some)
let updatedAvailability = (host.getAvailabilities().get).findItem(availability).get
check updatedAvailability.enabled == false
test "updating availability - updating totalSize does not allow bellow utilized",
salesConfig:
let originalSize = 0xFFFFFF.uint64