mirror of
https://github.com/status-im/nim-codex.git
synced 2025-01-09 10:32:11 +00:00
0157ca4c57
* Avoid cancelling states when slot is filled * improve logging Improves logging for situations where a Sale should be ignored instead of being considered an error, including when reservation is not allowed and when a slot was filled by another host. * remove onSlotFilled unit tests from states
27 lines
725 B
Nim
27 lines
725 B
Nim
import std/unittest
|
|
import pkg/questionable
|
|
import pkg/codex/contracts/requests
|
|
import pkg/codex/sales/states/filling
|
|
import pkg/codex/sales/states/cancelled
|
|
import pkg/codex/sales/states/failed
|
|
import pkg/codex/sales/states/filled
|
|
import ../../examples
|
|
import ../../helpers
|
|
|
|
checksuite "sales state 'filling'":
|
|
|
|
let request = StorageRequest.example
|
|
let slotIndex = (request.ask.slots div 2).u256
|
|
var state: SaleFilling
|
|
|
|
setup:
|
|
state = SaleFilling.new()
|
|
|
|
test "switches to cancelled state when request expires":
|
|
let next = state.onCancelled(request)
|
|
check !next of SaleCancelled
|
|
|
|
test "switches to failed state when request fails":
|
|
let next = state.onFailed(request)
|
|
check !next of SaleFailed
|