2020-07-20 15:09:15 +00:00
|
|
|
import
|
|
|
|
testutils/fuzzing, chronicles,
|
2021-09-07 14:00:01 +00:00
|
|
|
../../../eth/rlp
|
2020-07-20 15:09:15 +00:00
|
|
|
|
|
|
|
type
|
|
|
|
TestEnum = enum
|
|
|
|
one = 1
|
|
|
|
two = 2
|
|
|
|
TestObject* = object
|
|
|
|
test1: uint32
|
|
|
|
test2: string
|
|
|
|
|
2021-12-20 12:14:50 +00:00
|
|
|
template testDecode(payload: openArray, T: type) =
|
2020-07-20 15:09:15 +00:00
|
|
|
try:
|
|
|
|
discard rlp.decode(payload, T)
|
|
|
|
except RlpError as e:
|
|
|
|
debug "Decode failed", err = e.msg
|
|
|
|
|
|
|
|
test:
|
|
|
|
testDecode(payload, string)
|
|
|
|
testDecode(payload, uint)
|
|
|
|
testDecode(payload, uint8)
|
|
|
|
testDecode(payload, uint16)
|
|
|
|
testDecode(payload, uint32)
|
|
|
|
testDecode(payload, uint64)
|
|
|
|
testDecode(payload, bool)
|
|
|
|
testDecode(payload, seq[byte])
|
2024-09-30 16:32:36 +00:00
|
|
|
testDecode(payload, (string, uint32))
|
2020-07-20 15:09:15 +00:00
|
|
|
testDecode(payload, TestEnum)
|
|
|
|
testDecode(payload, TestObject)
|