mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-07 22:54:17 -05:00
* updating the goethereum dependency * fixing dependencies * reverting workspace * more fixes, work in progress * trying with upgraded geth version * fixing deprecated functions except for the time related ones on eth1 distance due to time issues * fixing time issues * gaz * fixing test and upgrading some dependencies and reverting others * Disable cgo in hid, delete old vendored usb library * changelog * rolling back dependencies * fixing go mod tidy * Geth v1.13.6 * fix tests * Add ping interval, set to 500ms for tests. This didnt work * Update to v1.14.8 * Spread it out to different bootnodes * Fix it * Remove Memsize * Update all out of date dependencies * Fix geth body change * Fix Test * Fix Build * Fix Tests * Fix Tests Again * Fix Tests Again * Fix Tests * Fix Test * Copy USB Package for HID * Push it up * Finally fix all tests with felix's changes * updating geth dependency * Update go-ethereum to v1.14.11 * fixing import * reverting blob change * fixing Implicit memory aliasing in for loop. * WIP changes * wip getting a little further on e2e runs * getting a little further * getting a little further * setting everything to capella * more partial fixes * more fixes but still WIP * fixing access list transactions" * some cleanup * making configs dynamic * reverting time * skip lower bound in builder * updating to geth v1.14.12 * fixing verify blob to pointer * go mod tidy * fixing linting * missed removing another terminal difficulty item * another missed update * updating more dependencies to fix cicd * fixing holiman dependency update * downgrading geth to 1.14.11 due to p2p loop issue * reverting builder middleware caused by downgrade * fixing more rollback issues * upgrading back to 1.14.12 after discussing with preston * mod tidy * gofmt * partial review feedback * trying to start e2e from bellatrix instead * reverting some changes --------- Co-authored-by: Preston Van Loon <preston@pvl.dev> Co-authored-by: nisdas <nishdas93@gmail.com>
84 lines
2.4 KiB
Go
84 lines
2.4 KiB
Go
package main
|
|
|
|
import (
|
|
"crypto/ecdsa"
|
|
"crypto/rand"
|
|
"fmt"
|
|
"io"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/ethereum/go-ethereum/p2p/discover"
|
|
"github.com/ethereum/go-ethereum/p2p/enode"
|
|
"github.com/libp2p/go-libp2p/core/crypto"
|
|
ecdsaprysm "github.com/prysmaticlabs/prysm/v5/crypto/ecdsa"
|
|
"github.com/prysmaticlabs/prysm/v5/network"
|
|
_ "github.com/prysmaticlabs/prysm/v5/runtime/maxprocs"
|
|
"github.com/prysmaticlabs/prysm/v5/testing/assert"
|
|
"github.com/prysmaticlabs/prysm/v5/testing/require"
|
|
"github.com/sirupsen/logrus"
|
|
)
|
|
|
|
func TestMain(m *testing.M) {
|
|
logrus.SetLevel(logrus.DebugLevel)
|
|
logrus.SetOutput(io.Discard)
|
|
|
|
m.Run()
|
|
}
|
|
|
|
func TestBootnode_OK(t *testing.T) {
|
|
ipAddr, err := network.ExternalIPv4()
|
|
require.NoError(t, err)
|
|
privKey := extractPrivateKey()
|
|
cfg := discover.Config{
|
|
PrivateKey: privKey,
|
|
PingInterval: 100 * time.Millisecond,
|
|
NoFindnodeLivenessCheck: true,
|
|
}
|
|
listener := createListener(ipAddr, 4000, cfg)
|
|
defer listener.Close()
|
|
time.Sleep(5 * time.Second)
|
|
|
|
cfg.PrivateKey = extractPrivateKey()
|
|
bootNode, err := enode.Parse(enode.ValidSchemes, listener.Self().String())
|
|
require.NoError(t, err)
|
|
cfg.Bootnodes = []*enode.Node{bootNode}
|
|
listener2 := createListener(ipAddr, 4001, cfg)
|
|
defer listener2.Close()
|
|
|
|
// test that both the nodes have the other peer stored in their local table.
|
|
listenerNode := listener.Self()
|
|
listenerNode2 := listener2.Self()
|
|
|
|
time.Sleep(1 * time.Second)
|
|
|
|
nodes := listener.Lookup(listenerNode2.ID())
|
|
assert.NotEqual(t, 0, len(nodes), "Length of nodes stored in table is not expected")
|
|
assert.Equal(t, listenerNode2.ID(), nodes[0].ID())
|
|
|
|
nodes = listener2.Lookup(listenerNode.ID())
|
|
assert.NotEqual(t, 0, len(nodes), "Length of nodes stored in table is not expected")
|
|
assert.Equal(t, listenerNode.ID(), nodes[0].ID())
|
|
}
|
|
|
|
func TestPrivateKey_ParsesCorrectly(t *testing.T) {
|
|
privKey, _, err := crypto.GenerateSecp256k1Key(rand.Reader)
|
|
require.NoError(t, err)
|
|
|
|
pk, err := privKey.Raw()
|
|
require.NoError(t, err)
|
|
*privateKey = fmt.Sprintf("%x", pk)
|
|
|
|
extractedKey := extractPrivateKey()
|
|
|
|
rawKey, err := ecdsaprysm.ConvertFromInterfacePrivKey(privKey)
|
|
require.NoError(t, err)
|
|
|
|
r, s, err := ecdsa.Sign(rand.Reader, extractedKey, []byte{'t', 'e', 's', 't'})
|
|
require.NoError(t, err)
|
|
|
|
isVerified := ecdsa.Verify(&rawKey.PublicKey, []byte{'t', 'e', 's', 't'}, r, s)
|
|
assert.Equal(t, true, isVerified, "Unmarshalled key is not the same as the key that was given to the function")
|
|
*privateKey = ""
|
|
}
|