nim-ethers/testmodule/examples.nim

25 lines
589 B
Nim
Raw Permalink Normal View History

2022-01-24 13:40:47 +00:00
import std/random
import std/sequtils
import pkg/ethers
randomize()
2022-01-25 09:25:09 +00:00
proc example*[N](_: type array[N, byte]): array[N, byte] =
var a: array[N, byte]
for b in a.mitems:
2022-01-24 13:40:47 +00:00
b = rand(byte)
2022-01-25 09:25:09 +00:00
a
2022-01-24 13:40:47 +00:00
proc example*(_: type seq[byte]): seq[byte] =
let length = rand(0..<20)
newSeqWith(length, rand(byte))
2022-01-25 09:25:09 +00:00
proc example*(_: type Address): Address =
Address.init(array[20, byte].example)
proc example*(_: type UInt256): UInt256 =
UInt256.fromBytesBE(array[32, byte].example)
2022-01-24 13:40:47 +00:00
proc example*(_: type Transaction): Transaction =
Transaction(to: Address.example, data: seq[byte].example)