aboutsummaryrefslogtreecommitdiffstats
path: root/rlp/encode_test.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2015-01-16 06:21:41 +0800
committerFelix Lange <fjl@twurst.com>2015-01-16 06:35:26 +0800
commitfc92abec2cc6e27e7e56a6a05850ad4ebbf63d7e (patch)
treef8ba38e7c5ad3be52fc22c09600b619e1f968c53 /rlp/encode_test.go
parent29c46cdf3405d6462deb2cb5cef87b1b4fb2bdc7 (diff)
downloadgo-tangerine-fc92abec2cc6e27e7e56a6a05850ad4ebbf63d7e.tar
go-tangerine-fc92abec2cc6e27e7e56a6a05850ad4ebbf63d7e.tar.gz
go-tangerine-fc92abec2cc6e27e7e56a6a05850ad4ebbf63d7e.tar.bz2
go-tangerine-fc92abec2cc6e27e7e56a6a05850ad4ebbf63d7e.tar.lz
go-tangerine-fc92abec2cc6e27e7e56a6a05850ad4ebbf63d7e.tar.xz
go-tangerine-fc92abec2cc6e27e7e56a6a05850ad4ebbf63d7e.tar.zst
go-tangerine-fc92abec2cc6e27e7e56a6a05850ad4ebbf63d7e.zip
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.
Diffstat (limited to 'rlp/encode_test.go')
-rw-r--r--rlp/encode_test.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/rlp/encode_test.go b/rlp/encode_test.go
index 8dba3671b..18b843737 100644
--- a/rlp/encode_test.go
+++ b/rlp/encode_test.go
@@ -32,9 +32,19 @@ func (e byteEncoder) EncodeRLP(w io.Writer) error {
return nil
}
+type encodableReader struct {
+ A, B uint
+}
+
+func (e *encodableReader) Read(b []byte) (int, error) {
+ panic("called")
+}
+
var (
_ = Encoder(&testEncoder{})
_ = Encoder(byteEncoder(0))
+
+ reader io.Reader = &encodableReader{1, 2}
)
type encTest struct {
@@ -176,6 +186,9 @@ var encTests = []encTest{
{val: (*[]struct{ uint })(nil), output: "C0"},
{val: (*interface{})(nil), output: "C0"},
+ // interfaces
+ {val: []io.Reader{reader}, output: "C3C20102"}, // the contained value is a struct
+
// Encoder
{val: (*testEncoder)(nil), output: "00000000"},
{val: &testEncoder{}, output: "00010001000100010001"},