-
Notifications
You must be signed in to change notification settings - Fork 163
/
l1_beacon_client_test.go
53 lines (41 loc) · 1.67 KB
/
l1_beacon_client_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package op_e2e
import (
"context"
"testing"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/fakebeacon"
"github.com/ethereum-optimism/optimism/op-service/client"
"github.com/ethereum-optimism/optimism/op-service/eth"
"github.com/ethereum-optimism/optimism/op-service/sources"
"github.com/ethereum-optimism/optimism/op-service/testlog"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/log"
"github.com/stretchr/testify/require"
)
func TestGetVersion(t *testing.T) {
InitParallel(t)
l := testlog.Logger(t, log.LevelInfo)
beaconApi := fakebeacon.NewBeacon(l, t.TempDir(), uint64(0), uint64(0))
t.Cleanup(func() {
_ = beaconApi.Close()
})
require.NoError(t, beaconApi.Start("127.0.0.1:0"))
beaconCfg := sources.L1BeaconClientConfig{FetchAllSidecars: false}
cl := sources.NewL1BeaconClient(sources.NewBeaconHTTPClient(client.NewBasicHTTPClient(beaconApi.BeaconAddr(), l)), beaconCfg)
version, err := cl.GetVersion(context.Background())
require.NoError(t, err)
require.Equal(t, "fakebeacon 1.2.3", version)
}
func Test404NotFound(t *testing.T) {
InitParallel(t)
l := testlog.Logger(t, log.LevelInfo)
beaconApi := fakebeacon.NewBeacon(l, t.TempDir(), uint64(0), uint64(12))
t.Cleanup(func() {
_ = beaconApi.Close()
})
require.NoError(t, beaconApi.Start("127.0.0.1:0"))
beaconCfg := sources.L1BeaconClientConfig{FetchAllSidecars: false}
cl := sources.NewL1BeaconClient(sources.NewBeaconHTTPClient(client.NewBasicHTTPClient(beaconApi.BeaconAddr(), l)), beaconCfg)
hashes := []eth.IndexedBlobHash{{Index: 1}}
_, err := cl.GetBlobs(context.Background(), eth.L1BlockRef{Number: 10, Time: 120}, hashes)
require.ErrorIs(t, err, ethereum.NotFound)
}