mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 13:46:43 +00:00
rlp/rlpgen: add test for package name clash
This commit is contained in:
parent
e9242f8de2
commit
39c1dd1f61
3 changed files with 96 additions and 1 deletions
|
|
@ -47,7 +47,7 @@ func init() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var tests = []string{"uints", "nil", "rawvalue", "optional", "bigint", "uint256"}
|
var tests = []string{"uints", "nil", "rawvalue", "optional", "bigint", "uint256", "pkgclash"}
|
||||||
|
|
||||||
func TestOutput(t *testing.T) {
|
func TestOutput(t *testing.T) {
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
|
|
|
||||||
13
rlp/rlpgen/testdata/pkgclash.in.txt
vendored
Normal file
13
rlp/rlpgen/testdata/pkgclash.in.txt
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
// -*- mode: go -*-
|
||||||
|
|
||||||
|
package test
|
||||||
|
|
||||||
|
import (
|
||||||
|
eth1 "github.com/ethereum/go-ethereum/eth"
|
||||||
|
eth2 "github.com/ethereum/go-ethereum/eth/protocols/eth"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Test struct {
|
||||||
|
A eth1.MinerAPI
|
||||||
|
B eth2.GetReceiptsPacket
|
||||||
|
}
|
||||||
82
rlp/rlpgen/testdata/pkgclash.out.txt
vendored
Normal file
82
rlp/rlpgen/testdata/pkgclash.out.txt
vendored
Normal file
|
|
@ -0,0 +1,82 @@
|
||||||
|
package test
|
||||||
|
|
||||||
|
import "github.com/ethereum/go-ethereum/common"
|
||||||
|
import "github.com/ethereum/go-ethereum/eth"
|
||||||
|
import "github.com/ethereum/go-ethereum/rlp"
|
||||||
|
import "io"
|
||||||
|
import eth1 "github.com/ethereum/go-ethereum/eth/protocols/eth"
|
||||||
|
|
||||||
|
func (obj *Test) EncodeRLP(_w io.Writer) error {
|
||||||
|
w := rlp.NewEncoderBuffer(_w)
|
||||||
|
_tmp0 := w.List()
|
||||||
|
_tmp1 := w.List()
|
||||||
|
w.ListEnd(_tmp1)
|
||||||
|
_tmp2 := w.List()
|
||||||
|
w.WriteUint64(obj.B.RequestId)
|
||||||
|
_tmp3 := w.List()
|
||||||
|
for _, _tmp4 := range obj.B.GetReceiptsRequest {
|
||||||
|
w.WriteBytes(_tmp4[:])
|
||||||
|
}
|
||||||
|
w.ListEnd(_tmp3)
|
||||||
|
w.ListEnd(_tmp2)
|
||||||
|
w.ListEnd(_tmp0)
|
||||||
|
return w.Flush()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (obj *Test) DecodeRLP(dec *rlp.Stream) error {
|
||||||
|
var _tmp0 Test
|
||||||
|
{
|
||||||
|
if _, err := dec.List(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// A:
|
||||||
|
var _tmp1 eth.MinerAPI
|
||||||
|
{
|
||||||
|
if _, err := dec.List(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := dec.ListEnd(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_tmp0.A = _tmp1
|
||||||
|
// B:
|
||||||
|
var _tmp2 eth1.GetReceiptsPacket
|
||||||
|
{
|
||||||
|
if _, err := dec.List(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// RequestId:
|
||||||
|
_tmp3, err := dec.Uint64()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp2.RequestId = _tmp3
|
||||||
|
// GetReceiptsRequest:
|
||||||
|
var _tmp4 []common.Hash
|
||||||
|
if _, err := dec.List(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for dec.MoreDataInList() {
|
||||||
|
var _tmp5 common.Hash
|
||||||
|
if err := dec.ReadBytes(_tmp5[:]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp4 = append(_tmp4, _tmp5)
|
||||||
|
}
|
||||||
|
if err := dec.ListEnd(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp2.GetReceiptsRequest = _tmp4
|
||||||
|
if err := dec.ListEnd(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_tmp0.B = _tmp2
|
||||||
|
if err := dec.ListEnd(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*obj = _tmp0
|
||||||
|
return nil
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue