mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-01-05 23:13:09 +00:00
Merge branch 'master' into fix/nat
This commit is contained in:
commit
f1433ffbd8
@ -478,6 +478,23 @@ proc initSalesApi(node: CodexNodeRef, router: var RestRouter) =
|
|||||||
Http422, "Total size must be larger then zero", headers = headers
|
Http422, "Total size must be larger then zero", headers = headers
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if restAv.duration == 0:
|
||||||
|
return RestApiResponse.error(
|
||||||
|
Http422, "duration must be larger then zero", headers = headers
|
||||||
|
)
|
||||||
|
|
||||||
|
if restAv.minPricePerBytePerSecond == 0:
|
||||||
|
return RestApiResponse.error(
|
||||||
|
Http422,
|
||||||
|
"minPricePerBytePerSecond must be larger then zero",
|
||||||
|
headers = headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
if restAv.totalCollateral == 0:
|
||||||
|
return RestApiResponse.error(
|
||||||
|
Http422, "totalCollateral must be larger then zero", headers = headers
|
||||||
|
)
|
||||||
|
|
||||||
if not reservations.hasAvailable(restAv.totalSize):
|
if not reservations.hasAvailable(restAv.totalSize):
|
||||||
return
|
return
|
||||||
RestApiResponse.error(Http422, "Not enough storage quota", headers = headers)
|
RestApiResponse.error(Http422, "Not enough storage quota", headers = headers)
|
||||||
|
|||||||
@ -205,6 +205,7 @@ components:
|
|||||||
required:
|
required:
|
||||||
- id
|
- id
|
||||||
- totalRemainingCollateral
|
- totalRemainingCollateral
|
||||||
|
- freeSize
|
||||||
allOf:
|
allOf:
|
||||||
- $ref: "#/components/schemas/SalesAvailability"
|
- $ref: "#/components/schemas/SalesAvailability"
|
||||||
- type: object
|
- type: object
|
||||||
|
|||||||
@ -380,5 +380,44 @@ asyncchecksuite "Rest API validation":
|
|||||||
response.status == 422
|
response.status == 422
|
||||||
(await response.body) == "Cannot set until to a negative value"
|
(await response.body) == "Cannot set until to a negative value"
|
||||||
|
|
||||||
|
test "creating availability fails when duration is zero":
|
||||||
|
let response = await client.postAvailabilityRaw(
|
||||||
|
totalSize = 12.uint64,
|
||||||
|
duration = 0.uint64,
|
||||||
|
minPricePerBytePerSecond = 1.u256,
|
||||||
|
totalCollateral = 22.u256,
|
||||||
|
until = -1.SecondsSince1970.some,
|
||||||
|
)
|
||||||
|
|
||||||
|
check:
|
||||||
|
response.status == 422
|
||||||
|
(await response.body) == "duration must be larger then zero"
|
||||||
|
|
||||||
|
test "creating availability fails when minPricePerBytePerSecond is zero":
|
||||||
|
let response = await client.postAvailabilityRaw(
|
||||||
|
totalSize = 12.uint64,
|
||||||
|
duration = 1.uint64,
|
||||||
|
minPricePerBytePerSecond = 0.u256,
|
||||||
|
totalCollateral = 22.u256,
|
||||||
|
until = -1.SecondsSince1970.some,
|
||||||
|
)
|
||||||
|
|
||||||
|
check:
|
||||||
|
response.status == 422
|
||||||
|
(await response.body) == "minPricePerBytePerSecond must be larger then zero"
|
||||||
|
|
||||||
|
test "creating availability fails when totalCollateral is zero":
|
||||||
|
let response = await client.postAvailabilityRaw(
|
||||||
|
totalSize = 12.uint64,
|
||||||
|
duration = 1.uint64,
|
||||||
|
minPricePerBytePerSecond = 2.u256,
|
||||||
|
totalCollateral = 0.u256,
|
||||||
|
until = -1.SecondsSince1970.some,
|
||||||
|
)
|
||||||
|
|
||||||
|
check:
|
||||||
|
response.status == 422
|
||||||
|
(await response.body) == "totalCollateral must be larger then zero"
|
||||||
|
|
||||||
waitFor node.stop()
|
waitFor node.stop()
|
||||||
node.removeDataDir()
|
node.removeDataDir()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user