logos-storage-nim/tests/integration/testblockexpiration.nim
Giuliano Mega 54177e9fbf
feat(integration): use async client instead of standard Nim HTTP client (#1159)
* WiP: migrating CodexClient to chronos http client

* fix(api): fixes #1163

* feat: fully working API integration tests

* convert most of the tests in testupdownload

* feat: working updownload tests on async client

* feat: make testsales work with async codexclient

* feat: make testpurchasing work with async codexclient

* feat: make testblockexpiration work with async codexclient

* feat: make marketplacesuite work with async codexclient

* make testproofs work with async codexclient

* chore: refactor client to express higher level in terms of lower level operations

* fix: set correct content-length for erasure-coded datasets

* feat: make testecbug work with async client

* feat: make testvalidator work with async client

* refactor: simplify request aliases, add close operation

* wire back client.close at node shutdown

* refactor: remove unused exception

* fix: use await instead of waitFor on async call sites
2025-03-17 20:08:24 +00:00

51 lines
1.2 KiB
Nim

import ../examples
import ./multinodes
multinodesuite "Node block expiration tests":
var content: seq[byte]
setup:
content = await RandomChunker.example(blocks = 8)
test "node retains not-expired file",
NodeConfigs(
clients: CodexConfigs
.init(nodes = 1)
.withBlockTtl(0, 10)
.withBlockMaintenanceInterval(0, 1).some,
providers: CodexConfigs.none,
):
let client = clients()[0]
let clientApi = client.client
let contentId = (await clientApi.upload(content)).get
await sleepAsync(2.seconds)
let download = await clientApi.download(contentId, local = true)
check:
download.isOk
download.get == string.fromBytes(content)
test "node deletes expired file",
NodeConfigs(
clients: CodexConfigs
.init(nodes = 1)
.withBlockTtl(0, 1)
.withBlockMaintenanceInterval(0, 1).some,
providers: CodexConfigs.none,
):
let client = clients()[0]
let clientApi = client.client
let contentId = (await clientApi.upload(content)).get
await sleepAsync(3.seconds)
let download = await clientApi.download(contentId, local = true)
check:
download.isFailure
download.error.msg == "404"