logos-storage-nim/tests/examples.nim
E M 7fdb0b5942
refactor!: remove unused modules
Removed modules:
- sales (including reservations, slot queue, marketplace abstractions, state machines, etc)
- purchasing
- erasure coding
- contract interactions
- prover
- slot builder
- block exchange payments
- sales/purchasing from REST api
- removed persistence command and all config params from cli configuration
- CI workflows (devnet, dist tests, cirdl build, start eth node, contracts version reporting)
- unused modules from tests
- marketplace integration tests, and starting provider/validator/hardhat nodes
- unused manifest properties
- integration tests using the above

# Conflicts:
#	.github/workflows/ci-reusable.yml
#	.github/workflows/docker.yml
#	build.nims
#	codex/blockexchange/engine/payments.nim
#	codex/codex.nim
#	codex/conf.nim
#	codex/contracts/Readme.md
#	codex/erasure.nim
#	codex/erasure/backend.nim
#	codex/erasure/backends/leopard.nim
#	codex/erasure/erasure.nim
#	codex/rest/api.nim
#	codex/sales.nim
#	codex/sales/reservations.nim
#	codex/sales/states/filled.nim
#	codex/sales/states/preparing.nim
#	codex/sales/states/provingsimulated.nim
#	codex/slots/builder/builder.nim
#	codex/slots/converters.nim
#	codex/slots/proofs/backends/circomcompat.nim
#	codex/slots/proofs/backends/converters.nim
#	codex/slots/proofs/prover.nim
#	codex/slots/sampler/sampler.nim
#	codex/slots/sampler/utils.nim
#	codex/slots/types.nim
#	tests/integration/5_minutes/testrestapivalidation.nim
#	tests/integration/hardhatprocess.nim
#	tests/integration/multinodes.nim
#	tools/cirdl/cirdl.nim
2025-12-20 11:57:13 +11:00

56 lines
1.5 KiB
Nim

import std/random
import std/sequtils
import std/times
import std/typetraits
import pkg/codex/rng
import pkg/codex/stores
import pkg/codex/units
import pkg/chronos
import pkg/stew/byteutils
import pkg/stint
import ./codex/helpers/randomchunker
export randomchunker
export units
proc exampleString*(length: int): string =
let chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
result = newString(length) # Create a new empty string with a given length
for i in 0 ..< length:
result[i] = chars[rand(chars.len - 1)]
# Generate a random index and set the string's character
proc example*[T: SomeInteger](_: type T): T =
rand(T)
proc example*[T, N](_: type array[N, T]): array[N, T] =
for item in result.mitems:
item = T.example
proc example*[T](_: type seq[T]): seq[T] =
let length = uint8.example.int
newSeqWith(length, T.example)
proc example*(_: type UInt256): UInt256 =
UInt256.fromBytesBE(array[32, byte].example)
proc example*[T: distinct](_: type T): T =
type baseType = T.distinctBase
T(baseType.example)
proc example*(_: type RandomChunker, blocks: int): Future[seq[byte]] {.async.} =
let rng = Rng.instance()
let chunker = RandomChunker.new(
rng, size = DefaultBlockSize * blocks.NBytes, chunkSize = DefaultBlockSize
)
var data: seq[byte]
while (let moar = await chunker.getBytes(); moar != []):
data.add moar
return data
proc example*(_: type RandomChunker): Future[string] {.async.} =
await RandomChunker.example(3)