Skip to content

Commit 39c1dd1

Browse files
committed
rlp/rlpgen: add test for package name clash
1 parent e9242f8 commit 39c1dd1

File tree

3 files changed

+96
-1
lines changed

3 files changed

+96
-1
lines changed

rlp/rlpgen/gen_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func init() {
4747
}
4848
}
4949

50-
var tests = []string{"uints", "nil", "rawvalue", "optional", "bigint", "uint256"}
50+
var tests = []string{"uints", "nil", "rawvalue", "optional", "bigint", "uint256", "pkgclash"}
5151

5252
func TestOutput(t *testing.T) {
5353
for _, test := range tests {
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// -*- mode: go -*-
2+
3+
package test
4+
5+
import (
6+
eth1 "github.com/ethereum/go-ethereum/eth"
7+
eth2 "github.com/ethereum/go-ethereum/eth/protocols/eth"
8+
)
9+
10+
type Test struct {
11+
A eth1.MinerAPI
12+
B eth2.GetReceiptsPacket
13+
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
package test
2+
3+
import "github.com/ethereum/go-ethereum/common"
4+
import "github.com/ethereum/go-ethereum/eth"
5+
import "github.com/ethereum/go-ethereum/rlp"
6+
import "io"
7+
import eth1 "github.com/ethereum/go-ethereum/eth/protocols/eth"
8+
9+
func (obj *Test) EncodeRLP(_w io.Writer) error {
10+
w := rlp.NewEncoderBuffer(_w)
11+
_tmp0 := w.List()
12+
_tmp1 := w.List()
13+
w.ListEnd(_tmp1)
14+
_tmp2 := w.List()
15+
w.WriteUint64(obj.B.RequestId)
16+
_tmp3 := w.List()
17+
for _, _tmp4 := range obj.B.GetReceiptsRequest {
18+
w.WriteBytes(_tmp4[:])
19+
}
20+
w.ListEnd(_tmp3)
21+
w.ListEnd(_tmp2)
22+
w.ListEnd(_tmp0)
23+
return w.Flush()
24+
}
25+
26+
func (obj *Test) DecodeRLP(dec *rlp.Stream) error {
27+
var _tmp0 Test
28+
{
29+
if _, err := dec.List(); err != nil {
30+
return err
31+
}
32+
// A:
33+
var _tmp1 eth.MinerAPI
34+
{
35+
if _, err := dec.List(); err != nil {
36+
return err
37+
}
38+
if err := dec.ListEnd(); err != nil {
39+
return err
40+
}
41+
}
42+
_tmp0.A = _tmp1
43+
// B:
44+
var _tmp2 eth1.GetReceiptsPacket
45+
{
46+
if _, err := dec.List(); err != nil {
47+
return err
48+
}
49+
// RequestId:
50+
_tmp3, err := dec.Uint64()
51+
if err != nil {
52+
return err
53+
}
54+
_tmp2.RequestId = _tmp3
55+
// GetReceiptsRequest:
56+
var _tmp4 []common.Hash
57+
if _, err := dec.List(); err != nil {
58+
return err
59+
}
60+
for dec.MoreDataInList() {
61+
var _tmp5 common.Hash
62+
if err := dec.ReadBytes(_tmp5[:]); err != nil {
63+
return err
64+
}
65+
_tmp4 = append(_tmp4, _tmp5)
66+
}
67+
if err := dec.ListEnd(); err != nil {
68+
return err
69+
}
70+
_tmp2.GetReceiptsRequest = _tmp4
71+
if err := dec.ListEnd(); err != nil {
72+
return err
73+
}
74+
}
75+
_tmp0.B = _tmp2
76+
if err := dec.ListEnd(); err != nil {
77+
return err
78+
}
79+
}
80+
*obj = _tmp0
81+
return nil
82+
}

0 commit comments

Comments
 (0)