-
Notifications
You must be signed in to change notification settings - Fork 1k
/
handshake_test.go
35 lines (29 loc) · 974 Bytes
/
handshake_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
package observer
import (
"context"
"github.com/ledgerwatch/erigon/crypto"
"github.com/ledgerwatch/erigon/eth/protocols/eth"
"github.com/ledgerwatch/erigon/p2p/enode"
"github.com/ledgerwatch/erigon/params"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
)
func TestHandshake(t *testing.T) {
t.Skip("only for dev")
// grep 'self=enode' the log, and paste it here
// url := "enode://..."
url := params.MainnetBootnodes[0]
node := enode.MustParseV4(url)
myPrivateKey, _ := crypto.GenerateKey()
ctx := context.Background()
hello, status, err := Handshake(ctx, node.IP(), node.TCP(), node.Pubkey(), myPrivateKey)
require.Nil(t, err)
require.NotNil(t, hello)
assert.Equal(t, uint64(5), hello.Version)
assert.NotEmpty(t, hello.ClientID)
assert.Contains(t, hello.ClientID, "erigon")
require.NotNil(t, status)
assert.Equal(t, uint32(eth.ETH66), status.ProtocolVersion)
assert.Equal(t, uint64(1), status.NetworkID)
}