rlp: add functions for encoding

I'm reasonably confident that the encoding matches the output of
ethutil.Encode for values that it supports. Some of the tests have been
adpated from the Ethereum testing repository.

There are still TODOs in the code.
This commit is contained in:
Felix Lange
2014-12-30 11:40:32 +01:00
parent bb55307a9d
commit 552f5b2693
6 changed files with 861 additions and 18 deletions

View File

@ -509,7 +509,7 @@ func ExampleStream() {
}
func BenchmarkDecode(b *testing.B) {
enc := encTest(90000)
enc := encodeTestSlice(90000)
b.SetBytes(int64(len(enc)))
b.ReportAllocs()
b.ResetTimer()
@ -524,7 +524,7 @@ func BenchmarkDecode(b *testing.B) {
}
func BenchmarkDecodeIntSliceReuse(b *testing.B) {
enc := encTest(100000)
enc := encodeTestSlice(100000)
b.SetBytes(int64(len(enc)))
b.ReportAllocs()
b.ResetTimer()
@ -538,7 +538,7 @@ func BenchmarkDecodeIntSliceReuse(b *testing.B) {
}
}
func encTest(n int) []byte {
func encodeTestSlice(n int) []byte {
s := make([]interface{}, n)
for i := 0; i < n; i++ {
s[i] = i