Skip to content

Commit 63a1437

Browse files
authored
Merge pull request #45 from base/pectra-test
chore: add test for pectra support
2 parents 5753621 + 14d0371 commit 63a1437

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

api/service/api_test.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ func TestAPIService(t *testing.T) {
7373

7474
rootOne := common.HexToHash("0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef")
7575
rootTwo := common.HexToHash("0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890222222")
76+
rootThree := common.HexToHash("0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890333333")
7677

7778
blockOne := storage.BlobData{
7879
Header: storage.Header{
@@ -92,12 +93,25 @@ func TestAPIService(t *testing.T) {
9293
},
9394
}
9495

96+
// Pectra Block
97+
blockThree := storage.BlobData{
98+
Header: storage.Header{
99+
BeaconBlockHash: rootThree,
100+
},
101+
BlobSidecars: storage.BlobSidecars{
102+
Data: blobtest.NewBlobSidecars(t, 8), // More than 6 blobs
103+
},
104+
}
105+
95106
err := fs.WriteBlob(context.Background(), blockOne)
96107
require.NoError(t, err)
97108

98109
err = fs.WriteBlob(context.Background(), blockTwo)
99110
require.NoError(t, err)
100111

112+
err = fs.WriteBlob(context.Background(), blockThree)
113+
require.NoError(t, err)
114+
101115
beaconClient.Headers["finalized"] = &v1.BeaconBlockHeader{
102116
Root: phase0.Root(rootOne),
103117
}
@@ -241,6 +255,24 @@ func TestAPIService(t *testing.T) {
241255
path: "/eth/v1/",
242256
status: 404,
243257
},
258+
{
259+
name: "pectra: query all blobs",
260+
path: fmt.Sprintf("/eth/v1/beacon/blob_sidecars/%s", rootThree),
261+
status: 200,
262+
expected: &storage.BlobSidecars{
263+
Data: blockThree.BlobSidecars.Data,
264+
},
265+
},
266+
{
267+
name: "pectra: query blob greater than 6",
268+
path: fmt.Sprintf("/eth/v1/beacon/blob_sidecars/%s?indices=7", rootThree),
269+
status: 200,
270+
expected: &storage.BlobSidecars{
271+
Data: []*deneb.BlobSidecar{
272+
blockThree.BlobSidecars.Data[7],
273+
},
274+
},
275+
},
244276
}
245277

246278
responseFormat := []string{"application/json", "application/octet-stream"}

0 commit comments

Comments
 (0)