Workaround enum serialization

This commit is contained in:
Yuriy Glukhov 2018-05-18 11:48:37 +03:00 committed by zah
parent e47708b0bd
commit 078aa161dd
2 changed files with 11 additions and 4 deletions

View File

@ -276,7 +276,7 @@ proc read*(rlp: var Rlp, T: type Integer): Integer =
rlp.skipElem
proc read*(rlp: var Rlp, T: typedesc[enum]): T =
result = T(rlp.toInt(int))
result = type(result)(rlp.toInt(int))
rlp.skipElem
proc read*[R, E](rlp: var Rlp, T: type array[R, E]): T =

View File

@ -33,13 +33,20 @@ test "you cannot finish a list without appending enough elements":
proc withNewLines(x: string): string = x & "\n"
test "encode/decode object":
type MyObj = object
a: array[3, char]
b: int
type
MyEnum = enum
foo,
bar
MyObj = object
a: array[3, char]
b: int
c: MyEnum
var input: MyObj
input.a = ['e', 't', 'h']
input.b = 63
input.c = bar
var writer = initRlpWriter()
writer.append(input)