diff options
author | Péter Szilágyi <peterke@gmail.com> | 2017-08-24 18:10:50 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2017-08-24 18:10:50 +0800 |
commit | 63246e25426df51143d5fb06861d418753267ab1 (patch) | |
tree | 711774deb70cb5763ca5fac9d453a5a772ef67b5 /rlp/decode_test.go | |
parent | 3c48a25762dfab9382791c33a2f5832466077ac3 (diff) | |
download | dexon-63246e25426df51143d5fb06861d418753267ab1.tar dexon-63246e25426df51143d5fb06861d418753267ab1.tar.gz dexon-63246e25426df51143d5fb06861d418753267ab1.tar.bz2 dexon-63246e25426df51143d5fb06861d418753267ab1.tar.lz dexon-63246e25426df51143d5fb06861d418753267ab1.tar.xz dexon-63246e25426df51143d5fb06861d418753267ab1.tar.zst dexon-63246e25426df51143d5fb06861d418753267ab1.zip |
rlp: fix decoding long strings into RawValue types
Diffstat (limited to 'rlp/decode_test.go')
-rw-r--r-- | rlp/decode_test.go | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/rlp/decode_test.go b/rlp/decode_test.go index d762e195d..4d8abd001 100644 --- a/rlp/decode_test.go +++ b/rlp/decode_test.go @@ -256,16 +256,31 @@ func TestStreamList(t *testing.T) { } func TestStreamRaw(t *testing.T) { - s := NewStream(bytes.NewReader(unhex("C58401010101")), 0) - s.List() - - want := unhex("8401010101") - raw, err := s.Raw() - if err != nil { - t.Fatal(err) - } - if !bytes.Equal(want, raw) { - t.Errorf("raw mismatch: got %x, want %x", raw, want) + tests := []struct { + input string + output string + }{ + { + "C58401010101", + "8401010101", + }, + { + "F842B84001010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101", + "B84001010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101", + }, + } + for i, tt := range tests { + s := NewStream(bytes.NewReader(unhex(tt.input)), 0) + s.List() + + want := unhex(tt.output) + raw, err := s.Raw() + if err != nil { + t.Fatal(err) + } + if !bytes.Equal(want, raw) { + t.Errorf("test %d: raw mismatch: got %x, want %x", i, raw, want) + } } } |