mirror of
https://github.com/codex-storage/nim-codex.git
synced 2025-01-09 12:35:51 +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>
75 lines
2.0 KiB
Nim
75 lines
2.0 KiB
Nim
import std/times
|
|
import std/os
|
|
import std/json
|
|
import std/tempfiles
|
|
import pkg/asynctest
|
|
import pkg/chronos
|
|
import pkg/stint
|
|
import pkg/questionable
|
|
import pkg/questionable/results
|
|
import ./integration/nodes
|
|
|
|
suite "Taiko L2 Integration Tests":
|
|
|
|
var node1, node2: NodeProcess
|
|
|
|
setup:
|
|
doAssert existsEnv("CODEX_ETH_PRIVATE_KEY"), "Key for Taiko account missing"
|
|
|
|
node1 = startNode([
|
|
"--data-dir=" & createTempDir("", ""),
|
|
"--api-port=8080",
|
|
"--nat=127.0.0.1",
|
|
"--disc-ip=127.0.0.1",
|
|
"--disc-port=8090",
|
|
"--persistence",
|
|
"--eth-provider=https://rpc.test.taiko.xyz"
|
|
])
|
|
node1.waitUntilStarted()
|
|
|
|
let bootstrap = node1.client.info()["spr"].getStr()
|
|
|
|
node2 = startNode([
|
|
"--data-dir=" & createTempDir("", ""),
|
|
"--api-port=8081",
|
|
"--nat=127.0.0.1",
|
|
"--disc-ip=127.0.0.1",
|
|
"--disc-port=8091",
|
|
"--bootstrap-node=" & bootstrap,
|
|
"--persistence",
|
|
"--eth-provider=https://rpc.test.taiko.xyz"
|
|
])
|
|
node2.waitUntilStarted()
|
|
|
|
teardown:
|
|
node1.stop()
|
|
node2.stop()
|
|
node1.removeDataDir()
|
|
node2.removeDataDir()
|
|
|
|
test "node 1 buys storage from node 2":
|
|
discard node2.client.postAvailability(
|
|
size=0xFFFFF.u256,
|
|
duration=200.u256,
|
|
minPrice=300.u256,
|
|
maxCollateral=300.u256
|
|
)
|
|
let cid = !node1.client.upload("some file contents")
|
|
|
|
echo " - requesting storage, expires in 5 minutes"
|
|
let expiry = getTime().toUnix().uint64 + 5 * 60
|
|
let purchase = !node1.client.requestStorage(
|
|
cid,
|
|
duration=30.u256,
|
|
reward=400.u256,
|
|
proofProbability=3.u256,
|
|
collateral=200.u256,
|
|
expiry=expiry.u256
|
|
)
|
|
|
|
echo " - waiting for request to start, timeout 5 minutes"
|
|
check eventually(node1.client.getPurchase(purchase).?state == success "started", timeout = 5 * 60 * 1000)
|
|
|
|
echo " - waiting for request to finish, timeout 1 minute"
|
|
check eventually(node1.client.getPurchase(purchase).?state == success "finished", timeout = 1 * 60 * 1000)
|