rlp: allow encoding non-empty interface values

This needs to be supported because []someInterface does occur sometimes.

Funny enough, the fix involves changes to the decoder. makeDecoder
cannot return an error for non-empty interfaces anymore because the type
cache builds both decoder and writer. Do the check at 'runtime' instead.
This commit is contained in:
Felix Lange
2015-01-15 23:21:41 +01:00
parent 29c46cdf34
commit fc92abec2c
4 changed files with 23 additions and 3 deletions

View File

@ -325,6 +325,11 @@ var decodeTests = []decodeTest{
{input: "850505050505", ptr: new(interface{}), value: []byte{5, 5, 5, 5, 5}},
{input: "C0", ptr: new(interface{}), value: []interface{}{}},
{input: "C50183040404", ptr: new(interface{}), value: []interface{}{[]byte{1}, []byte{4, 4, 4}}},
{
input: "C3010203",
ptr: new([]io.Reader),
error: "rlp: type io.Reader is not RLP-serializable",
},
}
func uintp(i uint) *uint { return &i }