Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a109a14

Browse files
fjljonastheis
authored andcommittedJun 7, 2024
cmd/devp2p/internal/ethtest: update tests for eth/67 (ethereum#25306)
Conflicts: cmd/devp2p/internal/ethtest/chain_test.go cmd/devp2p/internal/ethtest/helpers.go cmd/devp2p/internal/ethtest/snapTypes.go cmd/devp2p/internal/ethtest/suite.go cmd/devp2p/internal/ethtest/types.go cmd/devp2p/rlpxcmd.go
1 parent 18181bc commit a109a14

File tree

8 files changed

+346
-774
lines changed

8 files changed

+346
-774
lines changed
 

‎cmd/devp2p/internal/ethtest/chain.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,12 @@ func (c *Chain) Head() *types.Block {
8989
return c.blocks[c.Len()-1]
9090
}
9191

92-
func (c *Chain) GetHeaders(req GetBlockHeaders) (BlockHeaders, error) {
92+
func (c *Chain) GetHeaders(req *GetBlockHeaders) ([]*types.Header, error) {
9393
if req.Amount < 1 {
9494
return nil, fmt.Errorf("no block headers requested")
9595
}
9696

97-
headers := make(BlockHeaders, req.Amount)
97+
headers := make([]*types.Header, req.Amount)
9898
var blockNumber uint64
9999

100100
// range over blocks to check if our chain has the requested header

‎cmd/devp2p/internal/ethtest/chain_test.go

+27-27
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
// Copyright 2020 The go-ethereum Authors
2-
// This file is part of the go-ethereum library.
2+
// This file is part of go-ethereum.
33
//
4-
// The go-ethereum library is free software: you can redistribute it and/or modify
5-
// it under the terms of the GNU Lesser General Public License as published by
4+
// go-ethereum is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
66
// the Free Software Foundation, either version 3 of the License, or
77
// (at your option) any later version.
88
//
9-
// The go-ethereum library is distributed in the hope that it will be useful,
9+
// go-ethereum is distributed in the hope that it will be useful,
1010
// but WITHOUT ANY WARRANTY; without even the implied warranty of
1111
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12-
// GNU Lesser General Public License for more details.
12+
// GNU General Public License for more details.
1313
//
14-
// You should have received a copy of the GNU Lesser General Public License
15-
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
14+
// You should have received a copy of the GNU General Public License
15+
// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
1616

1717
package ethtest
1818

@@ -141,18 +141,18 @@ func TestChain_GetHeaders(t *testing.T) {
141141

142142
var tests = []struct {
143143
req GetBlockHeaders
144-
expected BlockHeaders
144+
expected []*types.Header
145145
}{
146146
{
147147
req: GetBlockHeaders{
148-
Origin: eth.HashOrNumber{
149-
Number: uint64(2),
148+
GetBlockHeadersPacket: &eth.GetBlockHeadersPacket{
149+
Origin: eth.HashOrNumber{Number: uint64(2)},
150+
Amount: uint64(5),
151+
Skip: 1,
152+
Reverse: false,
150153
},
151-
Amount: uint64(5),
152-
Skip: 1,
153-
Reverse: false,
154154
},
155-
expected: BlockHeaders{
155+
expected: []*types.Header{
156156
chain.blocks[2].Header(),
157157
chain.blocks[4].Header(),
158158
chain.blocks[6].Header(),
@@ -162,37 +162,37 @@ func TestChain_GetHeaders(t *testing.T) {
162162
},
163163
{
164164
req: GetBlockHeaders{
165-
Origin: eth.HashOrNumber{
166-
Number: uint64(chain.Len() - 1),
165+
GetBlockHeadersPacket: &eth.GetBlockHeadersPacket{
166+
Origin: eth.HashOrNumber{Number: uint64(chain.Len() - 1)},
167+
Amount: uint64(3),
168+
Skip: 0,
169+
Reverse: true,
167170
},
168-
Amount: uint64(3),
169-
Skip: 0,
170-
Reverse: true,
171171
},
172-
expected: BlockHeaders{
172+
expected: []*types.Header{
173173
chain.blocks[chain.Len()-1].Header(),
174174
chain.blocks[chain.Len()-2].Header(),
175175
chain.blocks[chain.Len()-3].Header(),
176176
},
177177
},
178178
{
179179
req: GetBlockHeaders{
180-
Origin: eth.HashOrNumber{
181-
Hash: chain.Head().Hash(),
180+
GetBlockHeadersPacket: &eth.GetBlockHeadersPacket{
181+
Origin: eth.HashOrNumber{Hash: chain.Head().Hash()},
182+
Amount: uint64(1),
183+
Skip: 0,
184+
Reverse: false,
182185
},
183-
Amount: uint64(1),
184-
Skip: 0,
185-
Reverse: false,
186186
},
187-
expected: BlockHeaders{
187+
expected: []*types.Header{
188188
chain.Head().Header(),
189189
},
190190
},
191191
}
192192

193193
for i, tt := range tests {
194194
t.Run(strconv.Itoa(i), func(t *testing.T) {
195-
headers, err := chain.GetHeaders(tt.req)
195+
headers, err := chain.GetHeaders(&tt.req)
196196
if err != nil {
197197
t.Fatal(err)
198198
}

0 commit comments

Comments
 (0)
Please sign in to comment.