mirror of
https://github.com/status-im/nim-dagger.git
synced 2025-02-09 05:15:46 +00:00
71cd35112b
* [docs] fix two client scenario: add missing collateral * [integration] separate step to wait for node to be started * [cli] add option to specify ethereum private key * Remove unused imports * Fix warnings * [integration] move type definitions to correct place * [integration] wait a bit longer for a node to start in debug mode When e.g. running against Taiko test net rpc, the node start takes longer * [integration] simplify handling of codex node and client * [integration] add Taiko integration test * [contracts] await token approval confirmation before next tx * [contracts] deployment address of marketplace on Taiko * [cli] --eth-private-key now takes a file name Instead of supplying the private key on the command line, expect the private key to be in a file with the correct permissions. * [utils] Fixes undeclared `activeChroniclesStream` on Windows * [build] update nim-ethers to include PR #52 Co-authored-by: Eric Mastro <eric.mastro@gmail.com> * [cli] Better error messages when reading eth private key Co-authored-by: Eric Mastro <eric.mastro@gmail.com> * [integration] simplify reading of cmd line arguments Co-authored-by: Eric Mastro <eric.mastro@gmail.com> * [build] update to latest version of nim-ethers * [contracts] updated contract address for Taiko L2 * [build] update codex contracts to latest version --------- Co-authored-by: Eric Mastro <eric.mastro@gmail.com>
73 lines
1.7 KiB
Nim
73 lines
1.7 KiB
Nim
import std/os
|
|
import std/httpclient
|
|
from std/net import TimeoutError
|
|
|
|
import pkg/chronos
|
|
import ../ethertest
|
|
import ./nodes
|
|
|
|
ethersuite "Node block expiration tests":
|
|
var node: NodeProcess
|
|
var baseurl: string
|
|
|
|
let dataDir = getTempDir() / "Codex1"
|
|
let content = "test file content"
|
|
|
|
setup:
|
|
baseurl = "http://localhost:8080/api/codex/v1"
|
|
|
|
teardown:
|
|
node.stop()
|
|
|
|
dataDir.removeDir()
|
|
|
|
proc startTestNode(blockTtlSeconds: int) =
|
|
node = startNode([
|
|
"--api-port=8080",
|
|
"--data-dir=" & dataDir,
|
|
"--nat=127.0.0.1",
|
|
"--disc-ip=127.0.0.1",
|
|
"--disc-port=8090",
|
|
"--block-ttl=" & $blockTtlSeconds,
|
|
"--block-mi=1",
|
|
"--block-mn=10"
|
|
], debug = false)
|
|
node.waitUntilStarted()
|
|
|
|
proc uploadTestFile(): string =
|
|
let client = newHttpClient()
|
|
let uploadUrl = baseurl & "/upload"
|
|
let uploadResponse = client.post(uploadUrl, content)
|
|
check uploadResponse.status == "200 OK"
|
|
client.close()
|
|
uploadResponse.body
|
|
|
|
proc downloadTestFile(contentId: string): Response =
|
|
let client = newHttpClient(timeout=3000)
|
|
let downloadUrl = baseurl & "/download/" & contentId
|
|
let content = client.get(downloadUrl)
|
|
client.close()
|
|
content
|
|
|
|
test "node retains not-expired file":
|
|
startTestNode(blockTtlSeconds = 10)
|
|
|
|
let contentId = uploadTestFile()
|
|
|
|
await sleepAsync(2.seconds)
|
|
|
|
let response = downloadTestFile(contentId)
|
|
check:
|
|
response.status == "200 OK"
|
|
response.body == content
|
|
|
|
test "node deletes expired file":
|
|
startTestNode(blockTtlSeconds = 1)
|
|
|
|
let contentId = uploadTestFile()
|
|
|
|
await sleepAsync(3.seconds)
|
|
|
|
expect TimeoutError:
|
|
discard downloadTestFile(contentId)
|