[sales] Availability.new -> Availability.init

This commit is contained in:
Mark Spanbroek 2022-03-30 17:07:03 +02:00 committed by markspanbroek
parent 291c506e0b
commit 76be728f61
3 changed files with 7 additions and 7 deletions

View File

@ -22,7 +22,7 @@ type
func new*(_: type Sales, market: Market): Sales =
Sales(market: market)
proc new*(_: type Availability,
proc init*(_: type Availability,
size: uint64,
duration: uint64,
minPrice: UInt256): Availability =

View File

@ -54,4 +54,4 @@ proc example*(_: type Cid): Cid =
Block.example.cid
proc example*(_: type Availability): Availability =
Availability.new(uint16.example, uint16.example, uint64.example.u256)
Availability.init(uint16.example, uint16.example, uint64.example.u256)

View File

@ -32,12 +32,12 @@ suite "Sales":
check sales.available.len == 0
test "generates unique ids for storage availability":
let availability1 = Availability.new(size=1, duration=2, minPrice=3.u256)
let availability2 = Availability.new(size=1, duration=2, minPrice=3.u256)
let availability1 = Availability.init(size=1, duration=2, minPrice=3.u256)
let availability2 = Availability.init(size=1, duration=2, minPrice=3.u256)
check availability1.id != availability2.id
test "offers available storage when matching request comes in":
let availability = Availability.new(size=100, duration=60, minPrice=42.u256)
let availability = Availability.init(size=100, duration=60, minPrice=42.u256)
sales.add(availability)
sales.start()
let request = StorageRequest(duration:60.u256, size:100.u256, maxPrice:42.u256)
@ -47,7 +47,7 @@ suite "Sales":
sales.stop()
test "ignores request when no matching storage is available":
let availability = Availability.new(size=99, duration=60, minPrice=42.u256)
let availability = Availability.init(size=99, duration=60, minPrice=42.u256)
sales.add(availability)
sales.start()
let request = StorageRequest(duration:60.u256, size:100.u256, maxPrice:42.u256)
@ -56,7 +56,7 @@ suite "Sales":
sales.stop()
test "makes storage unavailable when offer is submitted":
let availability = Availability.new(size=100, duration=60, minPrice=42.u256)
let availability = Availability.init(size=100, duration=60, minPrice=42.u256)
sales.add(availability)
sales.start()
let request = StorageRequest(duration:60.u256, size:100.u256, maxPrice:42.u256)