26 lines
568 B
Nim
Raw Normal View History

2025-02-11 10:54:58 +01:00
import std/random
2025-03-19 15:25:17 +01:00
import std/typetraits
2025-02-11 10:54:58 +01:00
import pkg/stint
2025-03-19 15:25:17 +01:00
import pkg/stew/byteutils
2025-02-11 10:54:58 +01:00
import ../../codexcrawler/types
2025-03-19 15:25:17 +01:00
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*(_: type UInt256): UInt256 =
UInt256.fromBytes(array[32, byte].example)
proc example*[T: distinct](_: type T): T =
type baseType = T.distinctBase
T(baseType.example)
2025-02-11 10:54:58 +01:00
proc genNid*(): Nid =
Nid(rand(uint64).u256)
2025-03-19 15:25:17 +01:00
proc genRid*(): Rid =
Rid(array[32, byte].example)