Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get receipts msg test #2

Merged
merged 33 commits into from
Dec 6, 2024
Merged
Changes from 32 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
9100431
tests: receipts tests draft
fkrause98 Nov 28, 2024
171d9eb
debug: add some logs
fkrause98 Nov 28, 2024
34b51cd
debug: more logs
fkrause98 Nov 28, 2024
3249440
chore: remove wrong logs
fkrause98 Nov 28, 2024
a5f7681
test: try to log response
fkrause98 Nov 29, 2024
cdef310
test: try to log response
fkrause98 Nov 29, 2024
61bb822
tests: fix message types
fkrause98 Nov 29, 2024
b33d361
tests: use proper packets
fkrause98 Nov 29, 2024
27cf7d6
tests: temporarily disable timeout
fkrause98 Nov 29, 2024
e268331
tests: log response
fkrause98 Nov 29, 2024
5ea6d77
tests: expect correct receipts packet
fkrause98 Nov 29, 2024
0720d5c
tests: fix build
fkrause98 Nov 29, 2024
a5ffaa4
tests: try with only one block
fkrause98 Nov 29, 2024
d8ca416
tests: restore multiple blocks
fkrause98 Nov 29, 2024
0eba6fb
tests: single block
fkrause98 Nov 29, 2024
3a5aa71
tests: print received
fkrause98 Dec 2, 2024
03dd421
tests: test print
fkrause98 Dec 2, 2024
089919b
tests: decode bytes
fkrause98 Dec 2, 2024
ec6972c
test: comment block
fkrause98 Dec 2, 2024
ebc79f3
test: print decoded receipt
fkrause98 Dec 2, 2024
e7983e6
tests: fix build
fkrause98 Dec 2, 2024
430a065
test: try with legacy receipt
fkrause98 Dec 3, 2024
637219c
test: restore with non-legacy tx
fkrause98 Dec 3, 2024
860b7ff
test: only legacy tx
fkrause98 Dec 3, 2024
e8dbcc3
test: test with more tx types
fkrause98 Dec 3, 2024
2d8fa2e
test: readd block 75
fkrause98 Dec 3, 2024
85a2d11
test: only block 75
fkrause98 Dec 4, 2024
d6ae021
test: multiple blocks
fkrause98 Dec 5, 2024
c757b92
test: remove logs, add comment
fkrause98 Dec 6, 2024
4c67008
chore: remove debugging
fkrause98 Dec 6, 2024
28bfbe9
chore: remove debugging
fkrause98 Dec 6, 2024
9372722
chore: restore block bodies p2p test
fkrause98 Dec 6, 2024
65c2da4
Update cmd/devp2p/internal/ethtest/suite.go
fkrause98 Dec 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions cmd/devp2p/internal/ethtest/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ func (s *Suite) EthTests() []utesting.Test {
{Name: "ZeroRequestID", Fn: s.TestZeroRequestID},
// get block bodies
{Name: "GetBlockBodies", Fn: s.TestGetBlockBodies},
// get block receipts
{Name: "GetBlockReceipts", Fn: s.TestGetBlockReceipts},
// // malicious handshakes + status
{Name: "MaliciousHandshake", Fn: s.TestMaliciousHandshake},
{Name: "MaliciousStatus", Fn: s.TestMaliciousStatus},
Expand Down Expand Up @@ -371,6 +373,46 @@ func (s *Suite) TestGetBlockBodies(t *utesting.T) {
}
}

// Test the get block receipts p2p message works
// as expected, heavily based on the test for Block Bodies.
func (s *Suite) TestGetBlockReceipts(t *utesting.T) {
t.Log(`This test sends block receipts requests to the node for known blocks in the test chain.`)

conn, err := s.dial()
if err != nil {
t.Fatalf("dial failed: %v", err)
}
defer conn.Close()
if err := conn.peer(s.chain, nil); err != nil {
t.Fatalf("peering failed: %v", err)
}
// Create block bodies request.
req := &eth.GetReceiptsPacket{
RequestId: 55,
GetReceiptsRequest: eth.GetReceiptsRequest{
s.chain.blocks[275].Hash(),
s.chain.blocks[276].Hash(),
s.chain.blocks[75].Hash(),
},
}

if err := conn.Write(ethProto, eth.GetReceiptsMsg, req); err != nil {
t.Fatalf("could not write to connection: %v", err)
}
// Wait for response.
resp := new(eth.ReceiptsPacket)
if err := conn.ReadMsg(ethProto, eth.ReceiptsMsg, &resp); err != nil {
t.Fatalf("error reading receipts msg: %v", err)
}
if got, want := resp.RequestId, req.RequestId; got != want {
t.Fatalf("unexpected request id in respond", got, want)
}
receipts := resp.ReceiptsResponse
if len(receipts) != len(req.GetReceiptsRequest) {
t.Fatalf("wrong bodies in response: expected %d bodies, got %d", len(req.GetReceiptsRequest), len(receipts))
fkrause98 marked this conversation as resolved.
Show resolved Hide resolved
}
}

// randBuf makes a random buffer size kilobytes large.
func randBuf(size int) []byte {
buf := make([]byte, size*1024)
Expand Down
Loading