diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-09-11 03:02:16 +0800 |
---|---|---|
committer | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-09-11 03:02:16 +0800 |
commit | 62bbf8a09e7304611f57fb7eea92911cf52e6229 (patch) | |
tree | 28df8021441aedf31fa76646e81b024e0cf9d099 /rlp/encode_test.go | |
parent | 90f1fe0ed2399f90f01c09e61e244121ef7d148a (diff) | |
parent | fc8b246109760714a838f4be163cca1dbb998163 (diff) | |
download | dexon-62bbf8a09e7304611f57fb7eea92911cf52e6229.tar dexon-62bbf8a09e7304611f57fb7eea92911cf52e6229.tar.gz dexon-62bbf8a09e7304611f57fb7eea92911cf52e6229.tar.bz2 dexon-62bbf8a09e7304611f57fb7eea92911cf52e6229.tar.lz dexon-62bbf8a09e7304611f57fb7eea92911cf52e6229.tar.xz dexon-62bbf8a09e7304611f57fb7eea92911cf52e6229.tar.zst dexon-62bbf8a09e7304611f57fb7eea92911cf52e6229.zip |
Merge pull request #1778 from fjl/rlp-trie-changes
rlp: precursor changes for trie, p2p
Diffstat (limited to 'rlp/encode_test.go')
-rw-r--r-- | rlp/encode_test.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/rlp/encode_test.go b/rlp/encode_test.go index 60bd95692..a3f30d804 100644 --- a/rlp/encode_test.go +++ b/rlp/encode_test.go @@ -23,6 +23,7 @@ import ( "io" "io/ioutil" "math/big" + "sync" "testing" ) @@ -203,6 +204,11 @@ var encTests = []encTest{ output: "F90200CF84617364668471776572847A786376CF84617364668471776572847A786376CF84617364668471776572847A786376CF84617364668471776572847A786376CF84617364668471776572847A786376CF84617364668471776572847A786376CF84617364668471776572847A786376CF84617364668471776572847A786376CF84617364668471776572847A786376CF84617364668471776572847A786376CF84617364668471776572847A786376CF84617364668471776572847A786376CF84617364668471776572847A786376CF84617364668471776572847A786376CF84617364668471776572847A786376CF84617364668471776572847A786376CF84617364668471776572847A786376CF84617364668471776572847A786376CF84617364668471776572847A786376CF84617364668471776572847A786376CF84617364668471776572847A786376CF84617364668471776572847A786376CF84617364668471776572847A786376CF84617364668471776572847A786376CF84617364668471776572847A786376CF84617364668471776572847A786376CF84617364668471776572847A786376CF84617364668471776572847A786376CF84617364668471776572847A786376CF84617364668471776572847A786376CF84617364668471776572847A786376CF84617364668471776572847A786376", }, + // RawValue + {val: RawValue(unhex("01")), output: "01"}, + {val: RawValue(unhex("82FFFF")), output: "82FFFF"}, + {val: []RawValue{unhex("01"), unhex("02")}, output: "C20102"}, + // structs {val: simplestruct{}, output: "C28080"}, {val: simplestruct{A: 3, B: "foo"}, output: "C50383666F6F"}, @@ -306,3 +312,25 @@ func TestEncodeToReaderPiecewise(t *testing.T) { return output, nil }) } + +// This is a regression test verifying that encReader +// returns its encbuf to the pool only once. +func TestEncodeToReaderReturnToPool(t *testing.T) { + buf := make([]byte, 50) + wg := new(sync.WaitGroup) + for i := 0; i < 5; i++ { + wg.Add(1) + go func() { + for i := 0; i < 1000; i++ { + _, r, _ := EncodeToReader("foo") + ioutil.ReadAll(r) + r.Read(buf) + r.Read(buf) + r.Read(buf) + r.Read(buf) + } + wg.Done() + }() + } + wg.Wait() +} |