-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhandlers_test.go
55 lines (49 loc) · 1.34 KB
/
handlers_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
54
55
package hypersyncgo
import (
"context"
"github.com/enviodev/hypersync-client-go/options"
"github.com/enviodev/hypersync-client-go/utils"
"github.com/ethereum/go-ethereum/common"
"github.com/stretchr/testify/require"
"go.uber.org/zap"
"math/big"
"testing"
)
func TestGetHeight(t *testing.T) {
testCases := []struct {
name string
opts options.Options
networkId utils.NetworkID
addresses []common.Address
}{{
name: "Test Ethereum Client",
opts: options.Options{
LogLevel: zap.DebugLevel,
Blockchains: []options.Node{
{
Type: utils.EthereumNetwork,
NetworkId: utils.EthereumNetworkID,
Endpoint: "https://eth.hypersync.xyz",
RpcEndpoint: "https://eth.rpc.hypersync.xyz",
},
},
},
networkId: utils.EthereumNetworkID,
}}
for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
hsClient, err := NewHyper(ctx, testCase.opts)
require.NoError(t, err)
require.NotNil(t, hsClient)
client, found := hsClient.GetClient(testCase.networkId)
require.True(t, found)
require.NotNil(t, client)
height, err := client.GetHeight(ctx)
require.NoError(t, err)
t.Logf("Discovered current height: %d", height)
require.Greater(t, height.Uint64(), big.NewInt(0).Uint64())
})
}
}