erigon-pulse/node/node_test.go

404 lines
12 KiB
Go
Raw Normal View History

// Copyright 2015 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
// The go-ethereum library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// The go-ethereum library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
package node
import (
"context"
"errors"
"reflect"
2021-06-18 03:35:11 +00:00
"runtime"
"testing"
2022-11-20 03:41:30 +00:00
"github.com/ledgerwatch/erigon-lib/common/datadir"
2021-07-29 11:53:13 +00:00
"github.com/ledgerwatch/erigon-lib/kv"
"github.com/ledgerwatch/erigon/crypto"
2022-05-26 05:27:44 +00:00
"github.com/ledgerwatch/erigon/node/nodecfg"
"github.com/ledgerwatch/erigon/p2p"
"github.com/ledgerwatch/log/v3"
"github.com/stretchr/testify/require"
)
var (
testNodeKey, _ = crypto.GenerateKey()
)
2022-05-26 05:27:44 +00:00
func testNodeConfig(t *testing.T) *nodecfg.Config {
2022-06-07 04:54:04 +00:00
return &nodecfg.Config{
Name: "test node",
P2P: p2p.Config{PrivateKey: testNodeKey},
Dirs: datadir.New(t.TempDir()),
}
}
node: refactor package node (#21105) This PR significantly changes the APIs for instantiating Ethereum nodes in a Go program. The new APIs are not backwards-compatible, but we feel that this is made up for by the much simpler way of registering services on node.Node. You can find more information and rationale in the design document: https://gist.github.com/renaynay/5bec2de19fde66f4d04c535fd24f0775. There is also a new feature in Node's Go API: it is now possible to register arbitrary handlers on the user-facing HTTP server. In geth, this facility is used to enable GraphQL. There is a single minor change relevant for geth users in this PR: The GraphQL API is no longer available separately from the JSON-RPC HTTP server. If you want GraphQL, you need to enable it using the ./geth --http --graphql flag combination. The --graphql.port and --graphql.addr flags are no longer available. # Conflicts: # cmd/faucet/faucet.go # cmd/geth/chaincmd.go # cmd/geth/config.go # cmd/geth/consolecmd.go # cmd/geth/main.go # cmd/utils/flags.go # cmd/wnode/main.go # core/rawdb/freezer.go # eth/api_backend.go # eth/backend.go # ethclient/ethclient_test.go # ethstats/ethstats.go # graphql/service.go # internal/ethapi/backend.go # les/api_backend.go # les/api_test.go # les/checkpointoracle/oracle.go # les/client.go # les/commons.go # les/server.go # miner/stresstest/stress_clique.go # miner/stresstest/stress_ethash.go # mobile/geth.go # node/api.go # node/node.go # node/node_example_test.go # node/node_test.go # node/rpcstack.go # node/rpcstack_test.go # node/service.go # node/service_test.go # node/utils_test.go # p2p/simulations/examples/ping-pong.go # p2p/testing/peerpool.go # p2p/testing/protocolsession.go # p2p/testing/protocoltester.go # whisper/mailserver/server_test.go # whisper/whisperv6/api_test.go # whisper/whisperv6/filter_test.go # whisper/whisperv6/whisper.go # whisper/whisperv6/whisper_test.go
2020-08-03 17:40:46 +00:00
// Tests that an empty protocol stack can be closed more than once.
func TestNodeCloseMultipleTimes(t *testing.T) {
2021-06-18 03:35:11 +00:00
if runtime.GOOS == "windows" {
t.Skip("fix me on win please")
}
stack, err := New(context.Background(), testNodeConfig(t), log.New())
if err != nil {
t.Fatalf("failed to create protocol stack: %v", err)
}
node: refactor package node (#21105) This PR significantly changes the APIs for instantiating Ethereum nodes in a Go program. The new APIs are not backwards-compatible, but we feel that this is made up for by the much simpler way of registering services on node.Node. You can find more information and rationale in the design document: https://gist.github.com/renaynay/5bec2de19fde66f4d04c535fd24f0775. There is also a new feature in Node's Go API: it is now possible to register arbitrary handlers on the user-facing HTTP server. In geth, this facility is used to enable GraphQL. There is a single minor change relevant for geth users in this PR: The GraphQL API is no longer available separately from the JSON-RPC HTTP server. If you want GraphQL, you need to enable it using the ./geth --http --graphql flag combination. The --graphql.port and --graphql.addr flags are no longer available. # Conflicts: # cmd/faucet/faucet.go # cmd/geth/chaincmd.go # cmd/geth/config.go # cmd/geth/consolecmd.go # cmd/geth/main.go # cmd/utils/flags.go # cmd/wnode/main.go # core/rawdb/freezer.go # eth/api_backend.go # eth/backend.go # ethclient/ethclient_test.go # ethstats/ethstats.go # graphql/service.go # internal/ethapi/backend.go # les/api_backend.go # les/api_test.go # les/checkpointoracle/oracle.go # les/client.go # les/commons.go # les/server.go # miner/stresstest/stress_clique.go # miner/stresstest/stress_ethash.go # mobile/geth.go # node/api.go # node/node.go # node/node_example_test.go # node/node_test.go # node/rpcstack.go # node/rpcstack_test.go # node/service.go # node/service_test.go # node/utils_test.go # p2p/simulations/examples/ping-pong.go # p2p/testing/peerpool.go # p2p/testing/protocolsession.go # p2p/testing/protocoltester.go # whisper/mailserver/server_test.go # whisper/whisperv6/api_test.go # whisper/whisperv6/filter_test.go # whisper/whisperv6/whisper.go # whisper/whisperv6/whisper_test.go
2020-08-03 17:40:46 +00:00
stack.Close()
// Ensure that a stopped node can be stopped again
for i := 0; i < 3; i++ {
2020-08-15 20:22:05 +00:00
if err := stack.Close(); !errors.Is(err, ErrNodeStopped) {
t.Fatalf("iter %d: stop failure mismatch: have %v, want %v", i, err, ErrNodeStopped)
}
}
node: refactor package node (#21105) This PR significantly changes the APIs for instantiating Ethereum nodes in a Go program. The new APIs are not backwards-compatible, but we feel that this is made up for by the much simpler way of registering services on node.Node. You can find more information and rationale in the design document: https://gist.github.com/renaynay/5bec2de19fde66f4d04c535fd24f0775. There is also a new feature in Node's Go API: it is now possible to register arbitrary handlers on the user-facing HTTP server. In geth, this facility is used to enable GraphQL. There is a single minor change relevant for geth users in this PR: The GraphQL API is no longer available separately from the JSON-RPC HTTP server. If you want GraphQL, you need to enable it using the ./geth --http --graphql flag combination. The --graphql.port and --graphql.addr flags are no longer available. # Conflicts: # cmd/faucet/faucet.go # cmd/geth/chaincmd.go # cmd/geth/config.go # cmd/geth/consolecmd.go # cmd/geth/main.go # cmd/utils/flags.go # cmd/wnode/main.go # core/rawdb/freezer.go # eth/api_backend.go # eth/backend.go # ethclient/ethclient_test.go # ethstats/ethstats.go # graphql/service.go # internal/ethapi/backend.go # les/api_backend.go # les/api_test.go # les/checkpointoracle/oracle.go # les/client.go # les/commons.go # les/server.go # miner/stresstest/stress_clique.go # miner/stresstest/stress_ethash.go # mobile/geth.go # node/api.go # node/node.go # node/node_example_test.go # node/node_test.go # node/rpcstack.go # node/rpcstack_test.go # node/service.go # node/service_test.go # node/utils_test.go # p2p/simulations/examples/ping-pong.go # p2p/testing/peerpool.go # p2p/testing/protocolsession.go # p2p/testing/protocoltester.go # whisper/mailserver/server_test.go # whisper/whisperv6/api_test.go # whisper/whisperv6/filter_test.go # whisper/whisperv6/whisper.go # whisper/whisperv6/whisper_test.go
2020-08-03 17:40:46 +00:00
}
func TestNodeStartMultipleTimes(t *testing.T) {
2021-06-18 03:35:11 +00:00
if runtime.GOOS == "windows" {
t.Skip("fix me on win please")
}
stack, err := New(context.Background(), testNodeConfig(t), log.New())
node: refactor package node (#21105) This PR significantly changes the APIs for instantiating Ethereum nodes in a Go program. The new APIs are not backwards-compatible, but we feel that this is made up for by the much simpler way of registering services on node.Node. You can find more information and rationale in the design document: https://gist.github.com/renaynay/5bec2de19fde66f4d04c535fd24f0775. There is also a new feature in Node's Go API: it is now possible to register arbitrary handlers on the user-facing HTTP server. In geth, this facility is used to enable GraphQL. There is a single minor change relevant for geth users in this PR: The GraphQL API is no longer available separately from the JSON-RPC HTTP server. If you want GraphQL, you need to enable it using the ./geth --http --graphql flag combination. The --graphql.port and --graphql.addr flags are no longer available. # Conflicts: # cmd/faucet/faucet.go # cmd/geth/chaincmd.go # cmd/geth/config.go # cmd/geth/consolecmd.go # cmd/geth/main.go # cmd/utils/flags.go # cmd/wnode/main.go # core/rawdb/freezer.go # eth/api_backend.go # eth/backend.go # ethclient/ethclient_test.go # ethstats/ethstats.go # graphql/service.go # internal/ethapi/backend.go # les/api_backend.go # les/api_test.go # les/checkpointoracle/oracle.go # les/client.go # les/commons.go # les/server.go # miner/stresstest/stress_clique.go # miner/stresstest/stress_ethash.go # mobile/geth.go # node/api.go # node/node.go # node/node_example_test.go # node/node_test.go # node/rpcstack.go # node/rpcstack_test.go # node/service.go # node/service_test.go # node/utils_test.go # p2p/simulations/examples/ping-pong.go # p2p/testing/peerpool.go # p2p/testing/protocolsession.go # p2p/testing/protocoltester.go # whisper/mailserver/server_test.go # whisper/whisperv6/api_test.go # whisper/whisperv6/filter_test.go # whisper/whisperv6/whisper.go # whisper/whisperv6/whisper_test.go
2020-08-03 17:40:46 +00:00
if err != nil {
t.Fatalf("failed to create protocol stack: %v", err)
}
// Ensure that a node can be successfully started, but only once
if err := stack.Start(); err != nil {
t.Fatalf("failed to start node: %v", err)
}
2020-08-15 20:22:05 +00:00
if err := stack.Start(); !errors.Is(err, ErrNodeRunning) {
t.Fatalf("start failure mismatch: have %v, want %v ", err, ErrNodeRunning)
}
// Ensure that a node can be stopped, but only once
node: refactor package node (#21105) This PR significantly changes the APIs for instantiating Ethereum nodes in a Go program. The new APIs are not backwards-compatible, but we feel that this is made up for by the much simpler way of registering services on node.Node. You can find more information and rationale in the design document: https://gist.github.com/renaynay/5bec2de19fde66f4d04c535fd24f0775. There is also a new feature in Node's Go API: it is now possible to register arbitrary handlers on the user-facing HTTP server. In geth, this facility is used to enable GraphQL. There is a single minor change relevant for geth users in this PR: The GraphQL API is no longer available separately from the JSON-RPC HTTP server. If you want GraphQL, you need to enable it using the ./geth --http --graphql flag combination. The --graphql.port and --graphql.addr flags are no longer available. # Conflicts: # cmd/faucet/faucet.go # cmd/geth/chaincmd.go # cmd/geth/config.go # cmd/geth/consolecmd.go # cmd/geth/main.go # cmd/utils/flags.go # cmd/wnode/main.go # core/rawdb/freezer.go # eth/api_backend.go # eth/backend.go # ethclient/ethclient_test.go # ethstats/ethstats.go # graphql/service.go # internal/ethapi/backend.go # les/api_backend.go # les/api_test.go # les/checkpointoracle/oracle.go # les/client.go # les/commons.go # les/server.go # miner/stresstest/stress_clique.go # miner/stresstest/stress_ethash.go # mobile/geth.go # node/api.go # node/node.go # node/node_example_test.go # node/node_test.go # node/rpcstack.go # node/rpcstack_test.go # node/service.go # node/service_test.go # node/utils_test.go # p2p/simulations/examples/ping-pong.go # p2p/testing/peerpool.go # p2p/testing/protocolsession.go # p2p/testing/protocoltester.go # whisper/mailserver/server_test.go # whisper/whisperv6/api_test.go # whisper/whisperv6/filter_test.go # whisper/whisperv6/whisper.go # whisper/whisperv6/whisper_test.go
2020-08-03 17:40:46 +00:00
if err := stack.Close(); err != nil {
t.Fatalf("failed to stop node: %v", err)
}
2020-08-15 20:22:05 +00:00
if err := stack.Close(); !errors.Is(err, ErrNodeStopped) {
t.Fatalf("stop failure mismatch: have %v, want %v ", err, ErrNodeStopped)
}
}
// Tests that if the data dir is already in use, an appropriate error is returned.
func TestNodeUsedDataDir(t *testing.T) {
2021-06-18 03:35:11 +00:00
if runtime.GOOS == "windows" {
t.Skip("fix me on win please")
}
// Create a temporary folder to use as the data directory
2021-05-18 12:13:16 +00:00
dir := t.TempDir()
// Create a new node based on the data directory
original, originalErr := New(context.Background(), &nodecfg.Config{Dirs: datadir.New(dir)}, log.New())
if originalErr != nil {
t.Fatalf("failed to create original protocol stack: %v", originalErr)
}
defer original.Close()
if err := original.Start(); err != nil {
t.Fatalf("failed to start original protocol stack: %v", err)
}
// Create a second node based on the same data directory and ensure failure
if _, err := New(context.Background(), &nodecfg.Config{Dirs: datadir.New(dir)}, log.New()); !errors.Is(err, datadir.ErrDataDirLocked) {
t.Fatalf("duplicate datadir failure mismatch: have %v, want %v", err, datadir.ErrDataDirLocked)
}
}
node: refactor package node (#21105) This PR significantly changes the APIs for instantiating Ethereum nodes in a Go program. The new APIs are not backwards-compatible, but we feel that this is made up for by the much simpler way of registering services on node.Node. You can find more information and rationale in the design document: https://gist.github.com/renaynay/5bec2de19fde66f4d04c535fd24f0775. There is also a new feature in Node's Go API: it is now possible to register arbitrary handlers on the user-facing HTTP server. In geth, this facility is used to enable GraphQL. There is a single minor change relevant for geth users in this PR: The GraphQL API is no longer available separately from the JSON-RPC HTTP server. If you want GraphQL, you need to enable it using the ./geth --http --graphql flag combination. The --graphql.port and --graphql.addr flags are no longer available. # Conflicts: # cmd/faucet/faucet.go # cmd/geth/chaincmd.go # cmd/geth/config.go # cmd/geth/consolecmd.go # cmd/geth/main.go # cmd/utils/flags.go # cmd/wnode/main.go # core/rawdb/freezer.go # eth/api_backend.go # eth/backend.go # ethclient/ethclient_test.go # ethstats/ethstats.go # graphql/service.go # internal/ethapi/backend.go # les/api_backend.go # les/api_test.go # les/checkpointoracle/oracle.go # les/client.go # les/commons.go # les/server.go # miner/stresstest/stress_clique.go # miner/stresstest/stress_ethash.go # mobile/geth.go # node/api.go # node/node.go # node/node_example_test.go # node/node_test.go # node/rpcstack.go # node/rpcstack_test.go # node/service.go # node/service_test.go # node/utils_test.go # p2p/simulations/examples/ping-pong.go # p2p/testing/peerpool.go # p2p/testing/protocolsession.go # p2p/testing/protocoltester.go # whisper/mailserver/server_test.go # whisper/whisperv6/api_test.go # whisper/whisperv6/filter_test.go # whisper/whisperv6/whisper.go # whisper/whisperv6/whisper_test.go
2020-08-03 17:40:46 +00:00
// Tests whether a Lifecycle can be registered.
func TestLifecycleRegistry_Successful(t *testing.T) {
stack, err := New(context.Background(), testNodeConfig(t), log.New())
if err != nil {
t.Fatalf("failed to create protocol stack: %v", err)
}
defer stack.Close()
node: refactor package node (#21105) This PR significantly changes the APIs for instantiating Ethereum nodes in a Go program. The new APIs are not backwards-compatible, but we feel that this is made up for by the much simpler way of registering services on node.Node. You can find more information and rationale in the design document: https://gist.github.com/renaynay/5bec2de19fde66f4d04c535fd24f0775. There is also a new feature in Node's Go API: it is now possible to register arbitrary handlers on the user-facing HTTP server. In geth, this facility is used to enable GraphQL. There is a single minor change relevant for geth users in this PR: The GraphQL API is no longer available separately from the JSON-RPC HTTP server. If you want GraphQL, you need to enable it using the ./geth --http --graphql flag combination. The --graphql.port and --graphql.addr flags are no longer available. # Conflicts: # cmd/faucet/faucet.go # cmd/geth/chaincmd.go # cmd/geth/config.go # cmd/geth/consolecmd.go # cmd/geth/main.go # cmd/utils/flags.go # cmd/wnode/main.go # core/rawdb/freezer.go # eth/api_backend.go # eth/backend.go # ethclient/ethclient_test.go # ethstats/ethstats.go # graphql/service.go # internal/ethapi/backend.go # les/api_backend.go # les/api_test.go # les/checkpointoracle/oracle.go # les/client.go # les/commons.go # les/server.go # miner/stresstest/stress_clique.go # miner/stresstest/stress_ethash.go # mobile/geth.go # node/api.go # node/node.go # node/node_example_test.go # node/node_test.go # node/rpcstack.go # node/rpcstack_test.go # node/service.go # node/service_test.go # node/utils_test.go # p2p/simulations/examples/ping-pong.go # p2p/testing/peerpool.go # p2p/testing/protocolsession.go # p2p/testing/protocoltester.go # whisper/mailserver/server_test.go # whisper/whisperv6/api_test.go # whisper/whisperv6/filter_test.go # whisper/whisperv6/whisper.go # whisper/whisperv6/whisper_test.go
2020-08-03 17:40:46 +00:00
noop := NewNoop()
stack.RegisterLifecycle(noop)
if !containsLifecycle(stack.lifecycles, noop) {
t.Fatalf("lifecycle was not properly registered on the node, %v", err)
}
}
node: refactor package node (#21105) This PR significantly changes the APIs for instantiating Ethereum nodes in a Go program. The new APIs are not backwards-compatible, but we feel that this is made up for by the much simpler way of registering services on node.Node. You can find more information and rationale in the design document: https://gist.github.com/renaynay/5bec2de19fde66f4d04c535fd24f0775. There is also a new feature in Node's Go API: it is now possible to register arbitrary handlers on the user-facing HTTP server. In geth, this facility is used to enable GraphQL. There is a single minor change relevant for geth users in this PR: The GraphQL API is no longer available separately from the JSON-RPC HTTP server. If you want GraphQL, you need to enable it using the ./geth --http --graphql flag combination. The --graphql.port and --graphql.addr flags are no longer available. # Conflicts: # cmd/faucet/faucet.go # cmd/geth/chaincmd.go # cmd/geth/config.go # cmd/geth/consolecmd.go # cmd/geth/main.go # cmd/utils/flags.go # cmd/wnode/main.go # core/rawdb/freezer.go # eth/api_backend.go # eth/backend.go # ethclient/ethclient_test.go # ethstats/ethstats.go # graphql/service.go # internal/ethapi/backend.go # les/api_backend.go # les/api_test.go # les/checkpointoracle/oracle.go # les/client.go # les/commons.go # les/server.go # miner/stresstest/stress_clique.go # miner/stresstest/stress_ethash.go # mobile/geth.go # node/api.go # node/node.go # node/node_example_test.go # node/node_test.go # node/rpcstack.go # node/rpcstack_test.go # node/service.go # node/service_test.go # node/utils_test.go # p2p/simulations/examples/ping-pong.go # p2p/testing/peerpool.go # p2p/testing/protocolsession.go # p2p/testing/protocoltester.go # whisper/mailserver/server_test.go # whisper/whisperv6/api_test.go # whisper/whisperv6/filter_test.go # whisper/whisperv6/whisper.go # whisper/whisperv6/whisper_test.go
2020-08-03 17:40:46 +00:00
// Tests whether a service's protocols can be registered properly on the node's p2p server.
func TestRegisterProtocols(t *testing.T) {
t.Skip("adjust to p2p sentry")
// TODO
}
node: refactor package node (#21105) This PR significantly changes the APIs for instantiating Ethereum nodes in a Go program. The new APIs are not backwards-compatible, but we feel that this is made up for by the much simpler way of registering services on node.Node. You can find more information and rationale in the design document: https://gist.github.com/renaynay/5bec2de19fde66f4d04c535fd24f0775. There is also a new feature in Node's Go API: it is now possible to register arbitrary handlers on the user-facing HTTP server. In geth, this facility is used to enable GraphQL. There is a single minor change relevant for geth users in this PR: The GraphQL API is no longer available separately from the JSON-RPC HTTP server. If you want GraphQL, you need to enable it using the ./geth --http --graphql flag combination. The --graphql.port and --graphql.addr flags are no longer available. # Conflicts: # cmd/faucet/faucet.go # cmd/geth/chaincmd.go # cmd/geth/config.go # cmd/geth/consolecmd.go # cmd/geth/main.go # cmd/utils/flags.go # cmd/wnode/main.go # core/rawdb/freezer.go # eth/api_backend.go # eth/backend.go # ethclient/ethclient_test.go # ethstats/ethstats.go # graphql/service.go # internal/ethapi/backend.go # les/api_backend.go # les/api_test.go # les/checkpointoracle/oracle.go # les/client.go # les/commons.go # les/server.go # miner/stresstest/stress_clique.go # miner/stresstest/stress_ethash.go # mobile/geth.go # node/api.go # node/node.go # node/node_example_test.go # node/node_test.go # node/rpcstack.go # node/rpcstack_test.go # node/service.go # node/service_test.go # node/utils_test.go # p2p/simulations/examples/ping-pong.go # p2p/testing/peerpool.go # p2p/testing/protocolsession.go # p2p/testing/protocoltester.go # whisper/mailserver/server_test.go # whisper/whisperv6/api_test.go # whisper/whisperv6/filter_test.go # whisper/whisperv6/whisper.go # whisper/whisperv6/whisper_test.go
2020-08-03 17:40:46 +00:00
// This test checks that open databases are closed with node.
func TestNodeCloseClosesDB(t *testing.T) {
2021-06-18 03:35:11 +00:00
if runtime.GOOS == "windows" {
t.Skip("fix me on win please")
}
logger := log.New()
stack, _ := New(context.Background(), testNodeConfig(t), logger)
defer stack.Close()
db, err := OpenDatabase(context.Background(), stack.Config(), kv.SentryDB, "", false, logger)
node: refactor package node (#21105) This PR significantly changes the APIs for instantiating Ethereum nodes in a Go program. The new APIs are not backwards-compatible, but we feel that this is made up for by the much simpler way of registering services on node.Node. You can find more information and rationale in the design document: https://gist.github.com/renaynay/5bec2de19fde66f4d04c535fd24f0775. There is also a new feature in Node's Go API: it is now possible to register arbitrary handlers on the user-facing HTTP server. In geth, this facility is used to enable GraphQL. There is a single minor change relevant for geth users in this PR: The GraphQL API is no longer available separately from the JSON-RPC HTTP server. If you want GraphQL, you need to enable it using the ./geth --http --graphql flag combination. The --graphql.port and --graphql.addr flags are no longer available. # Conflicts: # cmd/faucet/faucet.go # cmd/geth/chaincmd.go # cmd/geth/config.go # cmd/geth/consolecmd.go # cmd/geth/main.go # cmd/utils/flags.go # cmd/wnode/main.go # core/rawdb/freezer.go # eth/api_backend.go # eth/backend.go # ethclient/ethclient_test.go # ethstats/ethstats.go # graphql/service.go # internal/ethapi/backend.go # les/api_backend.go # les/api_test.go # les/checkpointoracle/oracle.go # les/client.go # les/commons.go # les/server.go # miner/stresstest/stress_clique.go # miner/stresstest/stress_ethash.go # mobile/geth.go # node/api.go # node/node.go # node/node_example_test.go # node/node_test.go # node/rpcstack.go # node/rpcstack_test.go # node/service.go # node/service_test.go # node/utils_test.go # p2p/simulations/examples/ping-pong.go # p2p/testing/peerpool.go # p2p/testing/protocolsession.go # p2p/testing/protocoltester.go # whisper/mailserver/server_test.go # whisper/whisperv6/api_test.go # whisper/whisperv6/filter_test.go # whisper/whisperv6/whisper.go # whisper/whisperv6/whisper_test.go
2020-08-03 17:40:46 +00:00
if err != nil {
t.Fatal("can't open DB:", err)
}
if err = db.Update(context.Background(), func(tx kv.RwTx) error {
return tx.Put(kv.HashedAccounts, []byte("testK"), []byte{})
}); err != nil {
node: refactor package node (#21105) This PR significantly changes the APIs for instantiating Ethereum nodes in a Go program. The new APIs are not backwards-compatible, but we feel that this is made up for by the much simpler way of registering services on node.Node. You can find more information and rationale in the design document: https://gist.github.com/renaynay/5bec2de19fde66f4d04c535fd24f0775. There is also a new feature in Node's Go API: it is now possible to register arbitrary handlers on the user-facing HTTP server. In geth, this facility is used to enable GraphQL. There is a single minor change relevant for geth users in this PR: The GraphQL API is no longer available separately from the JSON-RPC HTTP server. If you want GraphQL, you need to enable it using the ./geth --http --graphql flag combination. The --graphql.port and --graphql.addr flags are no longer available. # Conflicts: # cmd/faucet/faucet.go # cmd/geth/chaincmd.go # cmd/geth/config.go # cmd/geth/consolecmd.go # cmd/geth/main.go # cmd/utils/flags.go # cmd/wnode/main.go # core/rawdb/freezer.go # eth/api_backend.go # eth/backend.go # ethclient/ethclient_test.go # ethstats/ethstats.go # graphql/service.go # internal/ethapi/backend.go # les/api_backend.go # les/api_test.go # les/checkpointoracle/oracle.go # les/client.go # les/commons.go # les/server.go # miner/stresstest/stress_clique.go # miner/stresstest/stress_ethash.go # mobile/geth.go # node/api.go # node/node.go # node/node_example_test.go # node/node_test.go # node/rpcstack.go # node/rpcstack_test.go # node/service.go # node/service_test.go # node/utils_test.go # p2p/simulations/examples/ping-pong.go # p2p/testing/peerpool.go # p2p/testing/protocolsession.go # p2p/testing/protocoltester.go # whisper/mailserver/server_test.go # whisper/whisperv6/api_test.go # whisper/whisperv6/filter_test.go # whisper/whisperv6/whisper.go # whisper/whisperv6/whisper_test.go
2020-08-03 17:40:46 +00:00
t.Fatal("can't Put on open DB:", err)
}
node: refactor package node (#21105) This PR significantly changes the APIs for instantiating Ethereum nodes in a Go program. The new APIs are not backwards-compatible, but we feel that this is made up for by the much simpler way of registering services on node.Node. You can find more information and rationale in the design document: https://gist.github.com/renaynay/5bec2de19fde66f4d04c535fd24f0775. There is also a new feature in Node's Go API: it is now possible to register arbitrary handlers on the user-facing HTTP server. In geth, this facility is used to enable GraphQL. There is a single minor change relevant for geth users in this PR: The GraphQL API is no longer available separately from the JSON-RPC HTTP server. If you want GraphQL, you need to enable it using the ./geth --http --graphql flag combination. The --graphql.port and --graphql.addr flags are no longer available. # Conflicts: # cmd/faucet/faucet.go # cmd/geth/chaincmd.go # cmd/geth/config.go # cmd/geth/consolecmd.go # cmd/geth/main.go # cmd/utils/flags.go # cmd/wnode/main.go # core/rawdb/freezer.go # eth/api_backend.go # eth/backend.go # ethclient/ethclient_test.go # ethstats/ethstats.go # graphql/service.go # internal/ethapi/backend.go # les/api_backend.go # les/api_test.go # les/checkpointoracle/oracle.go # les/client.go # les/commons.go # les/server.go # miner/stresstest/stress_clique.go # miner/stresstest/stress_ethash.go # mobile/geth.go # node/api.go # node/node.go # node/node_example_test.go # node/node_test.go # node/rpcstack.go # node/rpcstack_test.go # node/service.go # node/service_test.go # node/utils_test.go # p2p/simulations/examples/ping-pong.go # p2p/testing/peerpool.go # p2p/testing/protocolsession.go # p2p/testing/protocoltester.go # whisper/mailserver/server_test.go # whisper/whisperv6/api_test.go # whisper/whisperv6/filter_test.go # whisper/whisperv6/whisper.go # whisper/whisperv6/whisper_test.go
2020-08-03 17:40:46 +00:00
stack.Close()
//if err = db.Update(context.Background(), func(tx kv.RwTx) error {
// return tx.Put(kv.HashedAccounts, []byte("testK"), []byte{})
//}); err == nil {
// t.Fatal("Put succeeded after node is closed")
//}
}
node: refactor package node (#21105) This PR significantly changes the APIs for instantiating Ethereum nodes in a Go program. The new APIs are not backwards-compatible, but we feel that this is made up for by the much simpler way of registering services on node.Node. You can find more information and rationale in the design document: https://gist.github.com/renaynay/5bec2de19fde66f4d04c535fd24f0775. There is also a new feature in Node's Go API: it is now possible to register arbitrary handlers on the user-facing HTTP server. In geth, this facility is used to enable GraphQL. There is a single minor change relevant for geth users in this PR: The GraphQL API is no longer available separately from the JSON-RPC HTTP server. If you want GraphQL, you need to enable it using the ./geth --http --graphql flag combination. The --graphql.port and --graphql.addr flags are no longer available. # Conflicts: # cmd/faucet/faucet.go # cmd/geth/chaincmd.go # cmd/geth/config.go # cmd/geth/consolecmd.go # cmd/geth/main.go # cmd/utils/flags.go # cmd/wnode/main.go # core/rawdb/freezer.go # eth/api_backend.go # eth/backend.go # ethclient/ethclient_test.go # ethstats/ethstats.go # graphql/service.go # internal/ethapi/backend.go # les/api_backend.go # les/api_test.go # les/checkpointoracle/oracle.go # les/client.go # les/commons.go # les/server.go # miner/stresstest/stress_clique.go # miner/stresstest/stress_ethash.go # mobile/geth.go # node/api.go # node/node.go # node/node_example_test.go # node/node_test.go # node/rpcstack.go # node/rpcstack_test.go # node/service.go # node/service_test.go # node/utils_test.go # p2p/simulations/examples/ping-pong.go # p2p/testing/peerpool.go # p2p/testing/protocolsession.go # p2p/testing/protocoltester.go # whisper/mailserver/server_test.go # whisper/whisperv6/api_test.go # whisper/whisperv6/filter_test.go # whisper/whisperv6/whisper.go # whisper/whisperv6/whisper_test.go
2020-08-03 17:40:46 +00:00
// This test checks that OpenDatabase can be used from within a Lifecycle Start method.
func TestNodeOpenDatabaseFromLifecycleStart(t *testing.T) {
2021-06-18 03:35:11 +00:00
if runtime.GOOS == "windows" {
t.Skip("fix me on win please")
}
logger := log.New()
stack, err := New(context.Background(), testNodeConfig(t), logger)
require.NoError(t, err)
node: refactor package node (#21105) This PR significantly changes the APIs for instantiating Ethereum nodes in a Go program. The new APIs are not backwards-compatible, but we feel that this is made up for by the much simpler way of registering services on node.Node. You can find more information and rationale in the design document: https://gist.github.com/renaynay/5bec2de19fde66f4d04c535fd24f0775. There is also a new feature in Node's Go API: it is now possible to register arbitrary handlers on the user-facing HTTP server. In geth, this facility is used to enable GraphQL. There is a single minor change relevant for geth users in this PR: The GraphQL API is no longer available separately from the JSON-RPC HTTP server. If you want GraphQL, you need to enable it using the ./geth --http --graphql flag combination. The --graphql.port and --graphql.addr flags are no longer available. # Conflicts: # cmd/faucet/faucet.go # cmd/geth/chaincmd.go # cmd/geth/config.go # cmd/geth/consolecmd.go # cmd/geth/main.go # cmd/utils/flags.go # cmd/wnode/main.go # core/rawdb/freezer.go # eth/api_backend.go # eth/backend.go # ethclient/ethclient_test.go # ethstats/ethstats.go # graphql/service.go # internal/ethapi/backend.go # les/api_backend.go # les/api_test.go # les/checkpointoracle/oracle.go # les/client.go # les/commons.go # les/server.go # miner/stresstest/stress_clique.go # miner/stresstest/stress_ethash.go # mobile/geth.go # node/api.go # node/node.go # node/node_example_test.go # node/node_test.go # node/rpcstack.go # node/rpcstack_test.go # node/service.go # node/service_test.go # node/utils_test.go # p2p/simulations/examples/ping-pong.go # p2p/testing/peerpool.go # p2p/testing/protocolsession.go # p2p/testing/protocoltester.go # whisper/mailserver/server_test.go # whisper/whisperv6/api_test.go # whisper/whisperv6/filter_test.go # whisper/whisperv6/whisper.go # whisper/whisperv6/whisper_test.go
2020-08-03 17:40:46 +00:00
defer stack.Close()
var db kv.RwDB
node: refactor package node (#21105) This PR significantly changes the APIs for instantiating Ethereum nodes in a Go program. The new APIs are not backwards-compatible, but we feel that this is made up for by the much simpler way of registering services on node.Node. You can find more information and rationale in the design document: https://gist.github.com/renaynay/5bec2de19fde66f4d04c535fd24f0775. There is also a new feature in Node's Go API: it is now possible to register arbitrary handlers on the user-facing HTTP server. In geth, this facility is used to enable GraphQL. There is a single minor change relevant for geth users in this PR: The GraphQL API is no longer available separately from the JSON-RPC HTTP server. If you want GraphQL, you need to enable it using the ./geth --http --graphql flag combination. The --graphql.port and --graphql.addr flags are no longer available. # Conflicts: # cmd/faucet/faucet.go # cmd/geth/chaincmd.go # cmd/geth/config.go # cmd/geth/consolecmd.go # cmd/geth/main.go # cmd/utils/flags.go # cmd/wnode/main.go # core/rawdb/freezer.go # eth/api_backend.go # eth/backend.go # ethclient/ethclient_test.go # ethstats/ethstats.go # graphql/service.go # internal/ethapi/backend.go # les/api_backend.go # les/api_test.go # les/checkpointoracle/oracle.go # les/client.go # les/commons.go # les/server.go # miner/stresstest/stress_clique.go # miner/stresstest/stress_ethash.go # mobile/geth.go # node/api.go # node/node.go # node/node_example_test.go # node/node_test.go # node/rpcstack.go # node/rpcstack_test.go # node/service.go # node/service_test.go # node/utils_test.go # p2p/simulations/examples/ping-pong.go # p2p/testing/peerpool.go # p2p/testing/protocolsession.go # p2p/testing/protocoltester.go # whisper/mailserver/server_test.go # whisper/whisperv6/api_test.go # whisper/whisperv6/filter_test.go # whisper/whisperv6/whisper.go # whisper/whisperv6/whisper_test.go
2020-08-03 17:40:46 +00:00
stack.RegisterLifecycle(&InstrumentedService{
startHook: func() {
db, err = OpenDatabase(context.Background(), stack.Config(), kv.SentryDB, "", false, logger)
node: refactor package node (#21105) This PR significantly changes the APIs for instantiating Ethereum nodes in a Go program. The new APIs are not backwards-compatible, but we feel that this is made up for by the much simpler way of registering services on node.Node. You can find more information and rationale in the design document: https://gist.github.com/renaynay/5bec2de19fde66f4d04c535fd24f0775. There is also a new feature in Node's Go API: it is now possible to register arbitrary handlers on the user-facing HTTP server. In geth, this facility is used to enable GraphQL. There is a single minor change relevant for geth users in this PR: The GraphQL API is no longer available separately from the JSON-RPC HTTP server. If you want GraphQL, you need to enable it using the ./geth --http --graphql flag combination. The --graphql.port and --graphql.addr flags are no longer available. # Conflicts: # cmd/faucet/faucet.go # cmd/geth/chaincmd.go # cmd/geth/config.go # cmd/geth/consolecmd.go # cmd/geth/main.go # cmd/utils/flags.go # cmd/wnode/main.go # core/rawdb/freezer.go # eth/api_backend.go # eth/backend.go # ethclient/ethclient_test.go # ethstats/ethstats.go # graphql/service.go # internal/ethapi/backend.go # les/api_backend.go # les/api_test.go # les/checkpointoracle/oracle.go # les/client.go # les/commons.go # les/server.go # miner/stresstest/stress_clique.go # miner/stresstest/stress_ethash.go # mobile/geth.go # node/api.go # node/node.go # node/node_example_test.go # node/node_test.go # node/rpcstack.go # node/rpcstack_test.go # node/service.go # node/service_test.go # node/utils_test.go # p2p/simulations/examples/ping-pong.go # p2p/testing/peerpool.go # p2p/testing/protocolsession.go # p2p/testing/protocoltester.go # whisper/mailserver/server_test.go # whisper/whisperv6/api_test.go # whisper/whisperv6/filter_test.go # whisper/whisperv6/whisper.go # whisper/whisperv6/whisper_test.go
2020-08-03 17:40:46 +00:00
if err != nil {
t.Fatal("can't open DB:", err)
}
},
stopHook: func() {
db.Close()
},
})
2020-08-15 20:17:38 +00:00
stack.Start() //nolint:errcheck
node: refactor package node (#21105) This PR significantly changes the APIs for instantiating Ethereum nodes in a Go program. The new APIs are not backwards-compatible, but we feel that this is made up for by the much simpler way of registering services on node.Node. You can find more information and rationale in the design document: https://gist.github.com/renaynay/5bec2de19fde66f4d04c535fd24f0775. There is also a new feature in Node's Go API: it is now possible to register arbitrary handlers on the user-facing HTTP server. In geth, this facility is used to enable GraphQL. There is a single minor change relevant for geth users in this PR: The GraphQL API is no longer available separately from the JSON-RPC HTTP server. If you want GraphQL, you need to enable it using the ./geth --http --graphql flag combination. The --graphql.port and --graphql.addr flags are no longer available. # Conflicts: # cmd/faucet/faucet.go # cmd/geth/chaincmd.go # cmd/geth/config.go # cmd/geth/consolecmd.go # cmd/geth/main.go # cmd/utils/flags.go # cmd/wnode/main.go # core/rawdb/freezer.go # eth/api_backend.go # eth/backend.go # ethclient/ethclient_test.go # ethstats/ethstats.go # graphql/service.go # internal/ethapi/backend.go # les/api_backend.go # les/api_test.go # les/checkpointoracle/oracle.go # les/client.go # les/commons.go # les/server.go # miner/stresstest/stress_clique.go # miner/stresstest/stress_ethash.go # mobile/geth.go # node/api.go # node/node.go # node/node_example_test.go # node/node_test.go # node/rpcstack.go # node/rpcstack_test.go # node/service.go # node/service_test.go # node/utils_test.go # p2p/simulations/examples/ping-pong.go # p2p/testing/peerpool.go # p2p/testing/protocolsession.go # p2p/testing/protocoltester.go # whisper/mailserver/server_test.go # whisper/whisperv6/api_test.go # whisper/whisperv6/filter_test.go # whisper/whisperv6/whisper.go # whisper/whisperv6/whisper_test.go
2020-08-03 17:40:46 +00:00
stack.Close()
}
// This test checks that OpenDatabase can be used from within a Lifecycle Stop method.
func TestNodeOpenDatabaseFromLifecycleStop(t *testing.T) {
2021-06-18 03:35:11 +00:00
if runtime.GOOS == "windows" {
t.Skip("fix me on win please")
}
logger := log.New()
stack, _ := New(context.Background(), testNodeConfig(t), logger)
node: refactor package node (#21105) This PR significantly changes the APIs for instantiating Ethereum nodes in a Go program. The new APIs are not backwards-compatible, but we feel that this is made up for by the much simpler way of registering services on node.Node. You can find more information and rationale in the design document: https://gist.github.com/renaynay/5bec2de19fde66f4d04c535fd24f0775. There is also a new feature in Node's Go API: it is now possible to register arbitrary handlers on the user-facing HTTP server. In geth, this facility is used to enable GraphQL. There is a single minor change relevant for geth users in this PR: The GraphQL API is no longer available separately from the JSON-RPC HTTP server. If you want GraphQL, you need to enable it using the ./geth --http --graphql flag combination. The --graphql.port and --graphql.addr flags are no longer available. # Conflicts: # cmd/faucet/faucet.go # cmd/geth/chaincmd.go # cmd/geth/config.go # cmd/geth/consolecmd.go # cmd/geth/main.go # cmd/utils/flags.go # cmd/wnode/main.go # core/rawdb/freezer.go # eth/api_backend.go # eth/backend.go # ethclient/ethclient_test.go # ethstats/ethstats.go # graphql/service.go # internal/ethapi/backend.go # les/api_backend.go # les/api_test.go # les/checkpointoracle/oracle.go # les/client.go # les/commons.go # les/server.go # miner/stresstest/stress_clique.go # miner/stresstest/stress_ethash.go # mobile/geth.go # node/api.go # node/node.go # node/node_example_test.go # node/node_test.go # node/rpcstack.go # node/rpcstack_test.go # node/service.go # node/service_test.go # node/utils_test.go # p2p/simulations/examples/ping-pong.go # p2p/testing/peerpool.go # p2p/testing/protocolsession.go # p2p/testing/protocoltester.go # whisper/mailserver/server_test.go # whisper/whisperv6/api_test.go # whisper/whisperv6/filter_test.go # whisper/whisperv6/whisper.go # whisper/whisperv6/whisper_test.go
2020-08-03 17:40:46 +00:00
defer stack.Close()
stack.RegisterLifecycle(&InstrumentedService{
stopHook: func() {
db, err := OpenDatabase(context.Background(), stack.Config(), kv.ChainDB, "", false, logger)
node: refactor package node (#21105) This PR significantly changes the APIs for instantiating Ethereum nodes in a Go program. The new APIs are not backwards-compatible, but we feel that this is made up for by the much simpler way of registering services on node.Node. You can find more information and rationale in the design document: https://gist.github.com/renaynay/5bec2de19fde66f4d04c535fd24f0775. There is also a new feature in Node's Go API: it is now possible to register arbitrary handlers on the user-facing HTTP server. In geth, this facility is used to enable GraphQL. There is a single minor change relevant for geth users in this PR: The GraphQL API is no longer available separately from the JSON-RPC HTTP server. If you want GraphQL, you need to enable it using the ./geth --http --graphql flag combination. The --graphql.port and --graphql.addr flags are no longer available. # Conflicts: # cmd/faucet/faucet.go # cmd/geth/chaincmd.go # cmd/geth/config.go # cmd/geth/consolecmd.go # cmd/geth/main.go # cmd/utils/flags.go # cmd/wnode/main.go # core/rawdb/freezer.go # eth/api_backend.go # eth/backend.go # ethclient/ethclient_test.go # ethstats/ethstats.go # graphql/service.go # internal/ethapi/backend.go # les/api_backend.go # les/api_test.go # les/checkpointoracle/oracle.go # les/client.go # les/commons.go # les/server.go # miner/stresstest/stress_clique.go # miner/stresstest/stress_ethash.go # mobile/geth.go # node/api.go # node/node.go # node/node_example_test.go # node/node_test.go # node/rpcstack.go # node/rpcstack_test.go # node/service.go # node/service_test.go # node/utils_test.go # p2p/simulations/examples/ping-pong.go # p2p/testing/peerpool.go # p2p/testing/protocolsession.go # p2p/testing/protocoltester.go # whisper/mailserver/server_test.go # whisper/whisperv6/api_test.go # whisper/whisperv6/filter_test.go # whisper/whisperv6/whisper.go # whisper/whisperv6/whisper_test.go
2020-08-03 17:40:46 +00:00
if err != nil {
t.Fatal("can't open DB:", err)
}
db.Close()
},
})
2020-08-15 20:17:38 +00:00
stack.Start() //nolint:errcheck
node: refactor package node (#21105) This PR significantly changes the APIs for instantiating Ethereum nodes in a Go program. The new APIs are not backwards-compatible, but we feel that this is made up for by the much simpler way of registering services on node.Node. You can find more information and rationale in the design document: https://gist.github.com/renaynay/5bec2de19fde66f4d04c535fd24f0775. There is also a new feature in Node's Go API: it is now possible to register arbitrary handlers on the user-facing HTTP server. In geth, this facility is used to enable GraphQL. There is a single minor change relevant for geth users in this PR: The GraphQL API is no longer available separately from the JSON-RPC HTTP server. If you want GraphQL, you need to enable it using the ./geth --http --graphql flag combination. The --graphql.port and --graphql.addr flags are no longer available. # Conflicts: # cmd/faucet/faucet.go # cmd/geth/chaincmd.go # cmd/geth/config.go # cmd/geth/consolecmd.go # cmd/geth/main.go # cmd/utils/flags.go # cmd/wnode/main.go # core/rawdb/freezer.go # eth/api_backend.go # eth/backend.go # ethclient/ethclient_test.go # ethstats/ethstats.go # graphql/service.go # internal/ethapi/backend.go # les/api_backend.go # les/api_test.go # les/checkpointoracle/oracle.go # les/client.go # les/commons.go # les/server.go # miner/stresstest/stress_clique.go # miner/stresstest/stress_ethash.go # mobile/geth.go # node/api.go # node/node.go # node/node_example_test.go # node/node_test.go # node/rpcstack.go # node/rpcstack_test.go # node/service.go # node/service_test.go # node/utils_test.go # p2p/simulations/examples/ping-pong.go # p2p/testing/peerpool.go # p2p/testing/protocolsession.go # p2p/testing/protocoltester.go # whisper/mailserver/server_test.go # whisper/whisperv6/api_test.go # whisper/whisperv6/filter_test.go # whisper/whisperv6/whisper.go # whisper/whisperv6/whisper_test.go
2020-08-03 17:40:46 +00:00
stack.Close()
}
// Tests that registered Lifecycles get started and stopped correctly.
func TestLifecycleLifeCycle(t *testing.T) {
stack, _ := New(context.Background(), testNodeConfig(t), log.New())
defer stack.Close()
started := make(map[string]bool)
node: refactor package node (#21105) This PR significantly changes the APIs for instantiating Ethereum nodes in a Go program. The new APIs are not backwards-compatible, but we feel that this is made up for by the much simpler way of registering services on node.Node. You can find more information and rationale in the design document: https://gist.github.com/renaynay/5bec2de19fde66f4d04c535fd24f0775. There is also a new feature in Node's Go API: it is now possible to register arbitrary handlers on the user-facing HTTP server. In geth, this facility is used to enable GraphQL. There is a single minor change relevant for geth users in this PR: The GraphQL API is no longer available separately from the JSON-RPC HTTP server. If you want GraphQL, you need to enable it using the ./geth --http --graphql flag combination. The --graphql.port and --graphql.addr flags are no longer available. # Conflicts: # cmd/faucet/faucet.go # cmd/geth/chaincmd.go # cmd/geth/config.go # cmd/geth/consolecmd.go # cmd/geth/main.go # cmd/utils/flags.go # cmd/wnode/main.go # core/rawdb/freezer.go # eth/api_backend.go # eth/backend.go # ethclient/ethclient_test.go # ethstats/ethstats.go # graphql/service.go # internal/ethapi/backend.go # les/api_backend.go # les/api_test.go # les/checkpointoracle/oracle.go # les/client.go # les/commons.go # les/server.go # miner/stresstest/stress_clique.go # miner/stresstest/stress_ethash.go # mobile/geth.go # node/api.go # node/node.go # node/node_example_test.go # node/node_test.go # node/rpcstack.go # node/rpcstack_test.go # node/service.go # node/service_test.go # node/utils_test.go # p2p/simulations/examples/ping-pong.go # p2p/testing/peerpool.go # p2p/testing/protocolsession.go # p2p/testing/protocoltester.go # whisper/mailserver/server_test.go # whisper/whisperv6/api_test.go # whisper/whisperv6/filter_test.go # whisper/whisperv6/whisper.go # whisper/whisperv6/whisper_test.go
2020-08-03 17:40:46 +00:00
stopped := make(map[string]bool)
// Create a batch of instrumented services
lifecycles := map[string]Lifecycle{
"A": &InstrumentedService{
startHook: func() { started["A"] = true },
stopHook: func() { stopped["A"] = true },
},
"B": &InstrumentedService{
startHook: func() { started["B"] = true },
stopHook: func() { stopped["B"] = true },
},
"C": &InstrumentedService{
startHook: func() { started["C"] = true },
stopHook: func() { stopped["C"] = true },
},
}
// register lifecycles on node
for _, lifecycle := range lifecycles {
stack.RegisterLifecycle(lifecycle)
}
// Start the node and check that all services are running
if err := stack.Start(); err != nil {
t.Fatalf("failed to start protocol stack: %v", err)
}
for id := range lifecycles {
if !started[id] {
t.Fatalf("service %s: freshly started service not running", id)
}
node: refactor package node (#21105) This PR significantly changes the APIs for instantiating Ethereum nodes in a Go program. The new APIs are not backwards-compatible, but we feel that this is made up for by the much simpler way of registering services on node.Node. You can find more information and rationale in the design document: https://gist.github.com/renaynay/5bec2de19fde66f4d04c535fd24f0775. There is also a new feature in Node's Go API: it is now possible to register arbitrary handlers on the user-facing HTTP server. In geth, this facility is used to enable GraphQL. There is a single minor change relevant for geth users in this PR: The GraphQL API is no longer available separately from the JSON-RPC HTTP server. If you want GraphQL, you need to enable it using the ./geth --http --graphql flag combination. The --graphql.port and --graphql.addr flags are no longer available. # Conflicts: # cmd/faucet/faucet.go # cmd/geth/chaincmd.go # cmd/geth/config.go # cmd/geth/consolecmd.go # cmd/geth/main.go # cmd/utils/flags.go # cmd/wnode/main.go # core/rawdb/freezer.go # eth/api_backend.go # eth/backend.go # ethclient/ethclient_test.go # ethstats/ethstats.go # graphql/service.go # internal/ethapi/backend.go # les/api_backend.go # les/api_test.go # les/checkpointoracle/oracle.go # les/client.go # les/commons.go # les/server.go # miner/stresstest/stress_clique.go # miner/stresstest/stress_ethash.go # mobile/geth.go # node/api.go # node/node.go # node/node_example_test.go # node/node_test.go # node/rpcstack.go # node/rpcstack_test.go # node/service.go # node/service_test.go # node/utils_test.go # p2p/simulations/examples/ping-pong.go # p2p/testing/peerpool.go # p2p/testing/protocolsession.go # p2p/testing/protocoltester.go # whisper/mailserver/server_test.go # whisper/whisperv6/api_test.go # whisper/whisperv6/filter_test.go # whisper/whisperv6/whisper.go # whisper/whisperv6/whisper_test.go
2020-08-03 17:40:46 +00:00
if stopped[id] {
t.Fatalf("service %s: freshly started service already stopped", id)
}
}
node: refactor package node (#21105) This PR significantly changes the APIs for instantiating Ethereum nodes in a Go program. The new APIs are not backwards-compatible, but we feel that this is made up for by the much simpler way of registering services on node.Node. You can find more information and rationale in the design document: https://gist.github.com/renaynay/5bec2de19fde66f4d04c535fd24f0775. There is also a new feature in Node's Go API: it is now possible to register arbitrary handlers on the user-facing HTTP server. In geth, this facility is used to enable GraphQL. There is a single minor change relevant for geth users in this PR: The GraphQL API is no longer available separately from the JSON-RPC HTTP server. If you want GraphQL, you need to enable it using the ./geth --http --graphql flag combination. The --graphql.port and --graphql.addr flags are no longer available. # Conflicts: # cmd/faucet/faucet.go # cmd/geth/chaincmd.go # cmd/geth/config.go # cmd/geth/consolecmd.go # cmd/geth/main.go # cmd/utils/flags.go # cmd/wnode/main.go # core/rawdb/freezer.go # eth/api_backend.go # eth/backend.go # ethclient/ethclient_test.go # ethstats/ethstats.go # graphql/service.go # internal/ethapi/backend.go # les/api_backend.go # les/api_test.go # les/checkpointoracle/oracle.go # les/client.go # les/commons.go # les/server.go # miner/stresstest/stress_clique.go # miner/stresstest/stress_ethash.go # mobile/geth.go # node/api.go # node/node.go # node/node_example_test.go # node/node_test.go # node/rpcstack.go # node/rpcstack_test.go # node/service.go # node/service_test.go # node/utils_test.go # p2p/simulations/examples/ping-pong.go # p2p/testing/peerpool.go # p2p/testing/protocolsession.go # p2p/testing/protocoltester.go # whisper/mailserver/server_test.go # whisper/whisperv6/api_test.go # whisper/whisperv6/filter_test.go # whisper/whisperv6/whisper.go # whisper/whisperv6/whisper_test.go
2020-08-03 17:40:46 +00:00
// Stop the node and check that all services have been stopped
if err := stack.Close(); err != nil {
t.Fatalf("failed to stop protocol stack: %v", err)
}
node: refactor package node (#21105) This PR significantly changes the APIs for instantiating Ethereum nodes in a Go program. The new APIs are not backwards-compatible, but we feel that this is made up for by the much simpler way of registering services on node.Node. You can find more information and rationale in the design document: https://gist.github.com/renaynay/5bec2de19fde66f4d04c535fd24f0775. There is also a new feature in Node's Go API: it is now possible to register arbitrary handlers on the user-facing HTTP server. In geth, this facility is used to enable GraphQL. There is a single minor change relevant for geth users in this PR: The GraphQL API is no longer available separately from the JSON-RPC HTTP server. If you want GraphQL, you need to enable it using the ./geth --http --graphql flag combination. The --graphql.port and --graphql.addr flags are no longer available. # Conflicts: # cmd/faucet/faucet.go # cmd/geth/chaincmd.go # cmd/geth/config.go # cmd/geth/consolecmd.go # cmd/geth/main.go # cmd/utils/flags.go # cmd/wnode/main.go # core/rawdb/freezer.go # eth/api_backend.go # eth/backend.go # ethclient/ethclient_test.go # ethstats/ethstats.go # graphql/service.go # internal/ethapi/backend.go # les/api_backend.go # les/api_test.go # les/checkpointoracle/oracle.go # les/client.go # les/commons.go # les/server.go # miner/stresstest/stress_clique.go # miner/stresstest/stress_ethash.go # mobile/geth.go # node/api.go # node/node.go # node/node_example_test.go # node/node_test.go # node/rpcstack.go # node/rpcstack_test.go # node/service.go # node/service_test.go # node/utils_test.go # p2p/simulations/examples/ping-pong.go # p2p/testing/peerpool.go # p2p/testing/protocolsession.go # p2p/testing/protocoltester.go # whisper/mailserver/server_test.go # whisper/whisperv6/api_test.go # whisper/whisperv6/filter_test.go # whisper/whisperv6/whisper.go # whisper/whisperv6/whisper_test.go
2020-08-03 17:40:46 +00:00
for id := range lifecycles {
if !stopped[id] {
t.Fatalf("service %s: freshly terminated service still running", id)
}
}
}
node: refactor package node (#21105) This PR significantly changes the APIs for instantiating Ethereum nodes in a Go program. The new APIs are not backwards-compatible, but we feel that this is made up for by the much simpler way of registering services on node.Node. You can find more information and rationale in the design document: https://gist.github.com/renaynay/5bec2de19fde66f4d04c535fd24f0775. There is also a new feature in Node's Go API: it is now possible to register arbitrary handlers on the user-facing HTTP server. In geth, this facility is used to enable GraphQL. There is a single minor change relevant for geth users in this PR: The GraphQL API is no longer available separately from the JSON-RPC HTTP server. If you want GraphQL, you need to enable it using the ./geth --http --graphql flag combination. The --graphql.port and --graphql.addr flags are no longer available. # Conflicts: # cmd/faucet/faucet.go # cmd/geth/chaincmd.go # cmd/geth/config.go # cmd/geth/consolecmd.go # cmd/geth/main.go # cmd/utils/flags.go # cmd/wnode/main.go # core/rawdb/freezer.go # eth/api_backend.go # eth/backend.go # ethclient/ethclient_test.go # ethstats/ethstats.go # graphql/service.go # internal/ethapi/backend.go # les/api_backend.go # les/api_test.go # les/checkpointoracle/oracle.go # les/client.go # les/commons.go # les/server.go # miner/stresstest/stress_clique.go # miner/stresstest/stress_ethash.go # mobile/geth.go # node/api.go # node/node.go # node/node_example_test.go # node/node_test.go # node/rpcstack.go # node/rpcstack_test.go # node/service.go # node/service_test.go # node/utils_test.go # p2p/simulations/examples/ping-pong.go # p2p/testing/peerpool.go # p2p/testing/protocolsession.go # p2p/testing/protocoltester.go # whisper/mailserver/server_test.go # whisper/whisperv6/api_test.go # whisper/whisperv6/filter_test.go # whisper/whisperv6/whisper.go # whisper/whisperv6/whisper_test.go
2020-08-03 17:40:46 +00:00
// Tests that if a Lifecycle fails to start, all others started before it will be
// shut down.
node: refactor package node (#21105) This PR significantly changes the APIs for instantiating Ethereum nodes in a Go program. The new APIs are not backwards-compatible, but we feel that this is made up for by the much simpler way of registering services on node.Node. You can find more information and rationale in the design document: https://gist.github.com/renaynay/5bec2de19fde66f4d04c535fd24f0775. There is also a new feature in Node's Go API: it is now possible to register arbitrary handlers on the user-facing HTTP server. In geth, this facility is used to enable GraphQL. There is a single minor change relevant for geth users in this PR: The GraphQL API is no longer available separately from the JSON-RPC HTTP server. If you want GraphQL, you need to enable it using the ./geth --http --graphql flag combination. The --graphql.port and --graphql.addr flags are no longer available. # Conflicts: # cmd/faucet/faucet.go # cmd/geth/chaincmd.go # cmd/geth/config.go # cmd/geth/consolecmd.go # cmd/geth/main.go # cmd/utils/flags.go # cmd/wnode/main.go # core/rawdb/freezer.go # eth/api_backend.go # eth/backend.go # ethclient/ethclient_test.go # ethstats/ethstats.go # graphql/service.go # internal/ethapi/backend.go # les/api_backend.go # les/api_test.go # les/checkpointoracle/oracle.go # les/client.go # les/commons.go # les/server.go # miner/stresstest/stress_clique.go # miner/stresstest/stress_ethash.go # mobile/geth.go # node/api.go # node/node.go # node/node_example_test.go # node/node_test.go # node/rpcstack.go # node/rpcstack_test.go # node/service.go # node/service_test.go # node/utils_test.go # p2p/simulations/examples/ping-pong.go # p2p/testing/peerpool.go # p2p/testing/protocolsession.go # p2p/testing/protocoltester.go # whisper/mailserver/server_test.go # whisper/whisperv6/api_test.go # whisper/whisperv6/filter_test.go # whisper/whisperv6/whisper.go # whisper/whisperv6/whisper_test.go
2020-08-03 17:40:46 +00:00
func TestLifecycleStartupError(t *testing.T) {
2021-06-18 03:35:11 +00:00
if runtime.GOOS == "windows" {
t.Skip("fix me on win please")
}
stack, err := New(context.Background(), testNodeConfig(t), log.New())
if err != nil {
t.Fatalf("failed to create protocol stack: %v", err)
}
defer stack.Close()
started := make(map[string]bool)
stopped := make(map[string]bool)
node: refactor package node (#21105) This PR significantly changes the APIs for instantiating Ethereum nodes in a Go program. The new APIs are not backwards-compatible, but we feel that this is made up for by the much simpler way of registering services on node.Node. You can find more information and rationale in the design document: https://gist.github.com/renaynay/5bec2de19fde66f4d04c535fd24f0775. There is also a new feature in Node's Go API: it is now possible to register arbitrary handlers on the user-facing HTTP server. In geth, this facility is used to enable GraphQL. There is a single minor change relevant for geth users in this PR: The GraphQL API is no longer available separately from the JSON-RPC HTTP server. If you want GraphQL, you need to enable it using the ./geth --http --graphql flag combination. The --graphql.port and --graphql.addr flags are no longer available. # Conflicts: # cmd/faucet/faucet.go # cmd/geth/chaincmd.go # cmd/geth/config.go # cmd/geth/consolecmd.go # cmd/geth/main.go # cmd/utils/flags.go # cmd/wnode/main.go # core/rawdb/freezer.go # eth/api_backend.go # eth/backend.go # ethclient/ethclient_test.go # ethstats/ethstats.go # graphql/service.go # internal/ethapi/backend.go # les/api_backend.go # les/api_test.go # les/checkpointoracle/oracle.go # les/client.go # les/commons.go # les/server.go # miner/stresstest/stress_clique.go # miner/stresstest/stress_ethash.go # mobile/geth.go # node/api.go # node/node.go # node/node_example_test.go # node/node_test.go # node/rpcstack.go # node/rpcstack_test.go # node/service.go # node/service_test.go # node/utils_test.go # p2p/simulations/examples/ping-pong.go # p2p/testing/peerpool.go # p2p/testing/protocolsession.go # p2p/testing/protocoltester.go # whisper/mailserver/server_test.go # whisper/whisperv6/api_test.go # whisper/whisperv6/filter_test.go # whisper/whisperv6/whisper.go # whisper/whisperv6/whisper_test.go
2020-08-03 17:40:46 +00:00
// Create a batch of instrumented services
lifecycles := map[string]Lifecycle{
"A": &InstrumentedService{
startHook: func() { started["A"] = true },
stopHook: func() { stopped["A"] = true },
},
"B": &InstrumentedService{
startHook: func() { started["B"] = true },
stopHook: func() { stopped["B"] = true },
},
"C": &InstrumentedService{
startHook: func() { started["C"] = true },
stopHook: func() { stopped["C"] = true },
},
}
// register lifecycles on node
for _, lifecycle := range lifecycles {
stack.RegisterLifecycle(lifecycle)
}
node: refactor package node (#21105) This PR significantly changes the APIs for instantiating Ethereum nodes in a Go program. The new APIs are not backwards-compatible, but we feel that this is made up for by the much simpler way of registering services on node.Node. You can find more information and rationale in the design document: https://gist.github.com/renaynay/5bec2de19fde66f4d04c535fd24f0775. There is also a new feature in Node's Go API: it is now possible to register arbitrary handlers on the user-facing HTTP server. In geth, this facility is used to enable GraphQL. There is a single minor change relevant for geth users in this PR: The GraphQL API is no longer available separately from the JSON-RPC HTTP server. If you want GraphQL, you need to enable it using the ./geth --http --graphql flag combination. The --graphql.port and --graphql.addr flags are no longer available. # Conflicts: # cmd/faucet/faucet.go # cmd/geth/chaincmd.go # cmd/geth/config.go # cmd/geth/consolecmd.go # cmd/geth/main.go # cmd/utils/flags.go # cmd/wnode/main.go # core/rawdb/freezer.go # eth/api_backend.go # eth/backend.go # ethclient/ethclient_test.go # ethstats/ethstats.go # graphql/service.go # internal/ethapi/backend.go # les/api_backend.go # les/api_test.go # les/checkpointoracle/oracle.go # les/client.go # les/commons.go # les/server.go # miner/stresstest/stress_clique.go # miner/stresstest/stress_ethash.go # mobile/geth.go # node/api.go # node/node.go # node/node_example_test.go # node/node_test.go # node/rpcstack.go # node/rpcstack_test.go # node/service.go # node/service_test.go # node/utils_test.go # p2p/simulations/examples/ping-pong.go # p2p/testing/peerpool.go # p2p/testing/protocolsession.go # p2p/testing/protocoltester.go # whisper/mailserver/server_test.go # whisper/whisperv6/api_test.go # whisper/whisperv6/filter_test.go # whisper/whisperv6/whisper.go # whisper/whisperv6/whisper_test.go
2020-08-03 17:40:46 +00:00
// Register a service that fails to construct itself
failure := errors.New("fail")
node: refactor package node (#21105) This PR significantly changes the APIs for instantiating Ethereum nodes in a Go program. The new APIs are not backwards-compatible, but we feel that this is made up for by the much simpler way of registering services on node.Node. You can find more information and rationale in the design document: https://gist.github.com/renaynay/5bec2de19fde66f4d04c535fd24f0775. There is also a new feature in Node's Go API: it is now possible to register arbitrary handlers on the user-facing HTTP server. In geth, this facility is used to enable GraphQL. There is a single minor change relevant for geth users in this PR: The GraphQL API is no longer available separately from the JSON-RPC HTTP server. If you want GraphQL, you need to enable it using the ./geth --http --graphql flag combination. The --graphql.port and --graphql.addr flags are no longer available. # Conflicts: # cmd/faucet/faucet.go # cmd/geth/chaincmd.go # cmd/geth/config.go # cmd/geth/consolecmd.go # cmd/geth/main.go # cmd/utils/flags.go # cmd/wnode/main.go # core/rawdb/freezer.go # eth/api_backend.go # eth/backend.go # ethclient/ethclient_test.go # ethstats/ethstats.go # graphql/service.go # internal/ethapi/backend.go # les/api_backend.go # les/api_test.go # les/checkpointoracle/oracle.go # les/client.go # les/commons.go # les/server.go # miner/stresstest/stress_clique.go # miner/stresstest/stress_ethash.go # mobile/geth.go # node/api.go # node/node.go # node/node_example_test.go # node/node_test.go # node/rpcstack.go # node/rpcstack_test.go # node/service.go # node/service_test.go # node/utils_test.go # p2p/simulations/examples/ping-pong.go # p2p/testing/peerpool.go # p2p/testing/protocolsession.go # p2p/testing/protocoltester.go # whisper/mailserver/server_test.go # whisper/whisperv6/api_test.go # whisper/whisperv6/filter_test.go # whisper/whisperv6/whisper.go # whisper/whisperv6/whisper_test.go
2020-08-03 17:40:46 +00:00
failer := &InstrumentedService{start: failure}
stack.RegisterLifecycle(failer)
// Start the protocol stack and ensure all started services stop
2020-08-15 20:22:05 +00:00
if err := stack.Start(); !errors.Is(err, failure) {
node: refactor package node (#21105) This PR significantly changes the APIs for instantiating Ethereum nodes in a Go program. The new APIs are not backwards-compatible, but we feel that this is made up for by the much simpler way of registering services on node.Node. You can find more information and rationale in the design document: https://gist.github.com/renaynay/5bec2de19fde66f4d04c535fd24f0775. There is also a new feature in Node's Go API: it is now possible to register arbitrary handlers on the user-facing HTTP server. In geth, this facility is used to enable GraphQL. There is a single minor change relevant for geth users in this PR: The GraphQL API is no longer available separately from the JSON-RPC HTTP server. If you want GraphQL, you need to enable it using the ./geth --http --graphql flag combination. The --graphql.port and --graphql.addr flags are no longer available. # Conflicts: # cmd/faucet/faucet.go # cmd/geth/chaincmd.go # cmd/geth/config.go # cmd/geth/consolecmd.go # cmd/geth/main.go # cmd/utils/flags.go # cmd/wnode/main.go # core/rawdb/freezer.go # eth/api_backend.go # eth/backend.go # ethclient/ethclient_test.go # ethstats/ethstats.go # graphql/service.go # internal/ethapi/backend.go # les/api_backend.go # les/api_test.go # les/checkpointoracle/oracle.go # les/client.go # les/commons.go # les/server.go # miner/stresstest/stress_clique.go # miner/stresstest/stress_ethash.go # mobile/geth.go # node/api.go # node/node.go # node/node_example_test.go # node/node_test.go # node/rpcstack.go # node/rpcstack_test.go # node/service.go # node/service_test.go # node/utils_test.go # p2p/simulations/examples/ping-pong.go # p2p/testing/peerpool.go # p2p/testing/protocolsession.go # p2p/testing/protocoltester.go # whisper/mailserver/server_test.go # whisper/whisperv6/api_test.go # whisper/whisperv6/filter_test.go # whisper/whisperv6/whisper.go # whisper/whisperv6/whisper_test.go
2020-08-03 17:40:46 +00:00
t.Fatalf("stack startup failure mismatch: have %v, want %v", err, failure)
}
for id := range lifecycles {
if started[id] && !stopped[id] {
t.Fatalf("service %s: started but not stopped", id)
}
node: refactor package node (#21105) This PR significantly changes the APIs for instantiating Ethereum nodes in a Go program. The new APIs are not backwards-compatible, but we feel that this is made up for by the much simpler way of registering services on node.Node. You can find more information and rationale in the design document: https://gist.github.com/renaynay/5bec2de19fde66f4d04c535fd24f0775. There is also a new feature in Node's Go API: it is now possible to register arbitrary handlers on the user-facing HTTP server. In geth, this facility is used to enable GraphQL. There is a single minor change relevant for geth users in this PR: The GraphQL API is no longer available separately from the JSON-RPC HTTP server. If you want GraphQL, you need to enable it using the ./geth --http --graphql flag combination. The --graphql.port and --graphql.addr flags are no longer available. # Conflicts: # cmd/faucet/faucet.go # cmd/geth/chaincmd.go # cmd/geth/config.go # cmd/geth/consolecmd.go # cmd/geth/main.go # cmd/utils/flags.go # cmd/wnode/main.go # core/rawdb/freezer.go # eth/api_backend.go # eth/backend.go # ethclient/ethclient_test.go # ethstats/ethstats.go # graphql/service.go # internal/ethapi/backend.go # les/api_backend.go # les/api_test.go # les/checkpointoracle/oracle.go # les/client.go # les/commons.go # les/server.go # miner/stresstest/stress_clique.go # miner/stresstest/stress_ethash.go # mobile/geth.go # node/api.go # node/node.go # node/node_example_test.go # node/node_test.go # node/rpcstack.go # node/rpcstack_test.go # node/service.go # node/service_test.go # node/utils_test.go # p2p/simulations/examples/ping-pong.go # p2p/testing/peerpool.go # p2p/testing/protocolsession.go # p2p/testing/protocoltester.go # whisper/mailserver/server_test.go # whisper/whisperv6/api_test.go # whisper/whisperv6/filter_test.go # whisper/whisperv6/whisper.go # whisper/whisperv6/whisper_test.go
2020-08-03 17:40:46 +00:00
delete(started, id)
delete(stopped, id)
}
}
node: refactor package node (#21105) This PR significantly changes the APIs for instantiating Ethereum nodes in a Go program. The new APIs are not backwards-compatible, but we feel that this is made up for by the much simpler way of registering services on node.Node. You can find more information and rationale in the design document: https://gist.github.com/renaynay/5bec2de19fde66f4d04c535fd24f0775. There is also a new feature in Node's Go API: it is now possible to register arbitrary handlers on the user-facing HTTP server. In geth, this facility is used to enable GraphQL. There is a single minor change relevant for geth users in this PR: The GraphQL API is no longer available separately from the JSON-RPC HTTP server. If you want GraphQL, you need to enable it using the ./geth --http --graphql flag combination. The --graphql.port and --graphql.addr flags are no longer available. # Conflicts: # cmd/faucet/faucet.go # cmd/geth/chaincmd.go # cmd/geth/config.go # cmd/geth/consolecmd.go # cmd/geth/main.go # cmd/utils/flags.go # cmd/wnode/main.go # core/rawdb/freezer.go # eth/api_backend.go # eth/backend.go # ethclient/ethclient_test.go # ethstats/ethstats.go # graphql/service.go # internal/ethapi/backend.go # les/api_backend.go # les/api_test.go # les/checkpointoracle/oracle.go # les/client.go # les/commons.go # les/server.go # miner/stresstest/stress_clique.go # miner/stresstest/stress_ethash.go # mobile/geth.go # node/api.go # node/node.go # node/node_example_test.go # node/node_test.go # node/rpcstack.go # node/rpcstack_test.go # node/service.go # node/service_test.go # node/utils_test.go # p2p/simulations/examples/ping-pong.go # p2p/testing/peerpool.go # p2p/testing/protocolsession.go # p2p/testing/protocoltester.go # whisper/mailserver/server_test.go # whisper/whisperv6/api_test.go # whisper/whisperv6/filter_test.go # whisper/whisperv6/whisper.go # whisper/whisperv6/whisper_test.go
2020-08-03 17:40:46 +00:00
// Tests that even if a registered Lifecycle fails to shut down cleanly, it does
// not influence the rest of the shutdown invocations.
node: refactor package node (#21105) This PR significantly changes the APIs for instantiating Ethereum nodes in a Go program. The new APIs are not backwards-compatible, but we feel that this is made up for by the much simpler way of registering services on node.Node. You can find more information and rationale in the design document: https://gist.github.com/renaynay/5bec2de19fde66f4d04c535fd24f0775. There is also a new feature in Node's Go API: it is now possible to register arbitrary handlers on the user-facing HTTP server. In geth, this facility is used to enable GraphQL. There is a single minor change relevant for geth users in this PR: The GraphQL API is no longer available separately from the JSON-RPC HTTP server. If you want GraphQL, you need to enable it using the ./geth --http --graphql flag combination. The --graphql.port and --graphql.addr flags are no longer available. # Conflicts: # cmd/faucet/faucet.go # cmd/geth/chaincmd.go # cmd/geth/config.go # cmd/geth/consolecmd.go # cmd/geth/main.go # cmd/utils/flags.go # cmd/wnode/main.go # core/rawdb/freezer.go # eth/api_backend.go # eth/backend.go # ethclient/ethclient_test.go # ethstats/ethstats.go # graphql/service.go # internal/ethapi/backend.go # les/api_backend.go # les/api_test.go # les/checkpointoracle/oracle.go # les/client.go # les/commons.go # les/server.go # miner/stresstest/stress_clique.go # miner/stresstest/stress_ethash.go # mobile/geth.go # node/api.go # node/node.go # node/node_example_test.go # node/node_test.go # node/rpcstack.go # node/rpcstack_test.go # node/service.go # node/service_test.go # node/utils_test.go # p2p/simulations/examples/ping-pong.go # p2p/testing/peerpool.go # p2p/testing/protocolsession.go # p2p/testing/protocoltester.go # whisper/mailserver/server_test.go # whisper/whisperv6/api_test.go # whisper/whisperv6/filter_test.go # whisper/whisperv6/whisper.go # whisper/whisperv6/whisper_test.go
2020-08-03 17:40:46 +00:00
func TestLifecycleTerminationGuarantee(t *testing.T) {
stack, err := New(context.Background(), testNodeConfig(t), log.New())
if err != nil {
t.Fatalf("failed to create protocol stack: %v", err)
}
defer stack.Close()
started := make(map[string]bool)
stopped := make(map[string]bool)
node: refactor package node (#21105) This PR significantly changes the APIs for instantiating Ethereum nodes in a Go program. The new APIs are not backwards-compatible, but we feel that this is made up for by the much simpler way of registering services on node.Node. You can find more information and rationale in the design document: https://gist.github.com/renaynay/5bec2de19fde66f4d04c535fd24f0775. There is also a new feature in Node's Go API: it is now possible to register arbitrary handlers on the user-facing HTTP server. In geth, this facility is used to enable GraphQL. There is a single minor change relevant for geth users in this PR: The GraphQL API is no longer available separately from the JSON-RPC HTTP server. If you want GraphQL, you need to enable it using the ./geth --http --graphql flag combination. The --graphql.port and --graphql.addr flags are no longer available. # Conflicts: # cmd/faucet/faucet.go # cmd/geth/chaincmd.go # cmd/geth/config.go # cmd/geth/consolecmd.go # cmd/geth/main.go # cmd/utils/flags.go # cmd/wnode/main.go # core/rawdb/freezer.go # eth/api_backend.go # eth/backend.go # ethclient/ethclient_test.go # ethstats/ethstats.go # graphql/service.go # internal/ethapi/backend.go # les/api_backend.go # les/api_test.go # les/checkpointoracle/oracle.go # les/client.go # les/commons.go # les/server.go # miner/stresstest/stress_clique.go # miner/stresstest/stress_ethash.go # mobile/geth.go # node/api.go # node/node.go # node/node_example_test.go # node/node_test.go # node/rpcstack.go # node/rpcstack_test.go # node/service.go # node/service_test.go # node/utils_test.go # p2p/simulations/examples/ping-pong.go # p2p/testing/peerpool.go # p2p/testing/protocolsession.go # p2p/testing/protocoltester.go # whisper/mailserver/server_test.go # whisper/whisperv6/api_test.go # whisper/whisperv6/filter_test.go # whisper/whisperv6/whisper.go # whisper/whisperv6/whisper_test.go
2020-08-03 17:40:46 +00:00
// Create a batch of instrumented services
lifecycles := map[string]Lifecycle{
"A": &InstrumentedService{
startHook: func() { started["A"] = true },
stopHook: func() { stopped["A"] = true },
},
"B": &InstrumentedService{
startHook: func() { started["B"] = true },
stopHook: func() { stopped["B"] = true },
},
"C": &InstrumentedService{
startHook: func() { started["C"] = true },
stopHook: func() { stopped["C"] = true },
},
}
// register lifecycles on node
for _, lifecycle := range lifecycles {
stack.RegisterLifecycle(lifecycle)
}
node: refactor package node (#21105) This PR significantly changes the APIs for instantiating Ethereum nodes in a Go program. The new APIs are not backwards-compatible, but we feel that this is made up for by the much simpler way of registering services on node.Node. You can find more information and rationale in the design document: https://gist.github.com/renaynay/5bec2de19fde66f4d04c535fd24f0775. There is also a new feature in Node's Go API: it is now possible to register arbitrary handlers on the user-facing HTTP server. In geth, this facility is used to enable GraphQL. There is a single minor change relevant for geth users in this PR: The GraphQL API is no longer available separately from the JSON-RPC HTTP server. If you want GraphQL, you need to enable it using the ./geth --http --graphql flag combination. The --graphql.port and --graphql.addr flags are no longer available. # Conflicts: # cmd/faucet/faucet.go # cmd/geth/chaincmd.go # cmd/geth/config.go # cmd/geth/consolecmd.go # cmd/geth/main.go # cmd/utils/flags.go # cmd/wnode/main.go # core/rawdb/freezer.go # eth/api_backend.go # eth/backend.go # ethclient/ethclient_test.go # ethstats/ethstats.go # graphql/service.go # internal/ethapi/backend.go # les/api_backend.go # les/api_test.go # les/checkpointoracle/oracle.go # les/client.go # les/commons.go # les/server.go # miner/stresstest/stress_clique.go # miner/stresstest/stress_ethash.go # mobile/geth.go # node/api.go # node/node.go # node/node_example_test.go # node/node_test.go # node/rpcstack.go # node/rpcstack_test.go # node/service.go # node/service_test.go # node/utils_test.go # p2p/simulations/examples/ping-pong.go # p2p/testing/peerpool.go # p2p/testing/protocolsession.go # p2p/testing/protocoltester.go # whisper/mailserver/server_test.go # whisper/whisperv6/api_test.go # whisper/whisperv6/filter_test.go # whisper/whisperv6/whisper.go # whisper/whisperv6/whisper_test.go
2020-08-03 17:40:46 +00:00
// Register a service that fails to shot down cleanly
failure := errors.New("fail")
node: refactor package node (#21105) This PR significantly changes the APIs for instantiating Ethereum nodes in a Go program. The new APIs are not backwards-compatible, but we feel that this is made up for by the much simpler way of registering services on node.Node. You can find more information and rationale in the design document: https://gist.github.com/renaynay/5bec2de19fde66f4d04c535fd24f0775. There is also a new feature in Node's Go API: it is now possible to register arbitrary handlers on the user-facing HTTP server. In geth, this facility is used to enable GraphQL. There is a single minor change relevant for geth users in this PR: The GraphQL API is no longer available separately from the JSON-RPC HTTP server. If you want GraphQL, you need to enable it using the ./geth --http --graphql flag combination. The --graphql.port and --graphql.addr flags are no longer available. # Conflicts: # cmd/faucet/faucet.go # cmd/geth/chaincmd.go # cmd/geth/config.go # cmd/geth/consolecmd.go # cmd/geth/main.go # cmd/utils/flags.go # cmd/wnode/main.go # core/rawdb/freezer.go # eth/api_backend.go # eth/backend.go # ethclient/ethclient_test.go # ethstats/ethstats.go # graphql/service.go # internal/ethapi/backend.go # les/api_backend.go # les/api_test.go # les/checkpointoracle/oracle.go # les/client.go # les/commons.go # les/server.go # miner/stresstest/stress_clique.go # miner/stresstest/stress_ethash.go # mobile/geth.go # node/api.go # node/node.go # node/node_example_test.go # node/node_test.go # node/rpcstack.go # node/rpcstack_test.go # node/service.go # node/service_test.go # node/utils_test.go # p2p/simulations/examples/ping-pong.go # p2p/testing/peerpool.go # p2p/testing/protocolsession.go # p2p/testing/protocoltester.go # whisper/mailserver/server_test.go # whisper/whisperv6/api_test.go # whisper/whisperv6/filter_test.go # whisper/whisperv6/whisper.go # whisper/whisperv6/whisper_test.go
2020-08-03 17:40:46 +00:00
failer := &InstrumentedService{stop: failure}
stack.RegisterLifecycle(failer)
// Start the protocol stack, and ensure that a failing shut down terminates all
node: refactor package node (#21105) This PR significantly changes the APIs for instantiating Ethereum nodes in a Go program. The new APIs are not backwards-compatible, but we feel that this is made up for by the much simpler way of registering services on node.Node. You can find more information and rationale in the design document: https://gist.github.com/renaynay/5bec2de19fde66f4d04c535fd24f0775. There is also a new feature in Node's Go API: it is now possible to register arbitrary handlers on the user-facing HTTP server. In geth, this facility is used to enable GraphQL. There is a single minor change relevant for geth users in this PR: The GraphQL API is no longer available separately from the JSON-RPC HTTP server. If you want GraphQL, you need to enable it using the ./geth --http --graphql flag combination. The --graphql.port and --graphql.addr flags are no longer available. # Conflicts: # cmd/faucet/faucet.go # cmd/geth/chaincmd.go # cmd/geth/config.go # cmd/geth/consolecmd.go # cmd/geth/main.go # cmd/utils/flags.go # cmd/wnode/main.go # core/rawdb/freezer.go # eth/api_backend.go # eth/backend.go # ethclient/ethclient_test.go # ethstats/ethstats.go # graphql/service.go # internal/ethapi/backend.go # les/api_backend.go # les/api_test.go # les/checkpointoracle/oracle.go # les/client.go # les/commons.go # les/server.go # miner/stresstest/stress_clique.go # miner/stresstest/stress_ethash.go # mobile/geth.go # node/api.go # node/node.go # node/node_example_test.go # node/node_test.go # node/rpcstack.go # node/rpcstack_test.go # node/service.go # node/service_test.go # node/utils_test.go # p2p/simulations/examples/ping-pong.go # p2p/testing/peerpool.go # p2p/testing/protocolsession.go # p2p/testing/protocoltester.go # whisper/mailserver/server_test.go # whisper/whisperv6/api_test.go # whisper/whisperv6/filter_test.go # whisper/whisperv6/whisper.go # whisper/whisperv6/whisper_test.go
2020-08-03 17:40:46 +00:00
// Start the stack and make sure all is online
2020-08-15 20:22:05 +00:00
if err1 := stack.Start(); err != nil {
t.Fatalf("failed to start protocol stack: %v", err1)
node: refactor package node (#21105) This PR significantly changes the APIs for instantiating Ethereum nodes in a Go program. The new APIs are not backwards-compatible, but we feel that this is made up for by the much simpler way of registering services on node.Node. You can find more information and rationale in the design document: https://gist.github.com/renaynay/5bec2de19fde66f4d04c535fd24f0775. There is also a new feature in Node's Go API: it is now possible to register arbitrary handlers on the user-facing HTTP server. In geth, this facility is used to enable GraphQL. There is a single minor change relevant for geth users in this PR: The GraphQL API is no longer available separately from the JSON-RPC HTTP server. If you want GraphQL, you need to enable it using the ./geth --http --graphql flag combination. The --graphql.port and --graphql.addr flags are no longer available. # Conflicts: # cmd/faucet/faucet.go # cmd/geth/chaincmd.go # cmd/geth/config.go # cmd/geth/consolecmd.go # cmd/geth/main.go # cmd/utils/flags.go # cmd/wnode/main.go # core/rawdb/freezer.go # eth/api_backend.go # eth/backend.go # ethclient/ethclient_test.go # ethstats/ethstats.go # graphql/service.go # internal/ethapi/backend.go # les/api_backend.go # les/api_test.go # les/checkpointoracle/oracle.go # les/client.go # les/commons.go # les/server.go # miner/stresstest/stress_clique.go # miner/stresstest/stress_ethash.go # mobile/geth.go # node/api.go # node/node.go # node/node_example_test.go # node/node_test.go # node/rpcstack.go # node/rpcstack_test.go # node/service.go # node/service_test.go # node/utils_test.go # p2p/simulations/examples/ping-pong.go # p2p/testing/peerpool.go # p2p/testing/protocolsession.go # p2p/testing/protocoltester.go # whisper/mailserver/server_test.go # whisper/whisperv6/api_test.go # whisper/whisperv6/filter_test.go # whisper/whisperv6/whisper.go # whisper/whisperv6/whisper_test.go
2020-08-03 17:40:46 +00:00
}
for id := range lifecycles {
if !started[id] {
t.Fatalf("service %s: service not running", id)
}
node: refactor package node (#21105) This PR significantly changes the APIs for instantiating Ethereum nodes in a Go program. The new APIs are not backwards-compatible, but we feel that this is made up for by the much simpler way of registering services on node.Node. You can find more information and rationale in the design document: https://gist.github.com/renaynay/5bec2de19fde66f4d04c535fd24f0775. There is also a new feature in Node's Go API: it is now possible to register arbitrary handlers on the user-facing HTTP server. In geth, this facility is used to enable GraphQL. There is a single minor change relevant for geth users in this PR: The GraphQL API is no longer available separately from the JSON-RPC HTTP server. If you want GraphQL, you need to enable it using the ./geth --http --graphql flag combination. The --graphql.port and --graphql.addr flags are no longer available. # Conflicts: # cmd/faucet/faucet.go # cmd/geth/chaincmd.go # cmd/geth/config.go # cmd/geth/consolecmd.go # cmd/geth/main.go # cmd/utils/flags.go # cmd/wnode/main.go # core/rawdb/freezer.go # eth/api_backend.go # eth/backend.go # ethclient/ethclient_test.go # ethstats/ethstats.go # graphql/service.go # internal/ethapi/backend.go # les/api_backend.go # les/api_test.go # les/checkpointoracle/oracle.go # les/client.go # les/commons.go # les/server.go # miner/stresstest/stress_clique.go # miner/stresstest/stress_ethash.go # mobile/geth.go # node/api.go # node/node.go # node/node_example_test.go # node/node_test.go # node/rpcstack.go # node/rpcstack_test.go # node/service.go # node/service_test.go # node/utils_test.go # p2p/simulations/examples/ping-pong.go # p2p/testing/peerpool.go # p2p/testing/protocolsession.go # p2p/testing/protocoltester.go # whisper/mailserver/server_test.go # whisper/whisperv6/api_test.go # whisper/whisperv6/filter_test.go # whisper/whisperv6/whisper.go # whisper/whisperv6/whisper_test.go
2020-08-03 17:40:46 +00:00
if stopped[id] {
t.Fatalf("service %s: service already stopped", id)
}
node: refactor package node (#21105) This PR significantly changes the APIs for instantiating Ethereum nodes in a Go program. The new APIs are not backwards-compatible, but we feel that this is made up for by the much simpler way of registering services on node.Node. You can find more information and rationale in the design document: https://gist.github.com/renaynay/5bec2de19fde66f4d04c535fd24f0775. There is also a new feature in Node's Go API: it is now possible to register arbitrary handlers on the user-facing HTTP server. In geth, this facility is used to enable GraphQL. There is a single minor change relevant for geth users in this PR: The GraphQL API is no longer available separately from the JSON-RPC HTTP server. If you want GraphQL, you need to enable it using the ./geth --http --graphql flag combination. The --graphql.port and --graphql.addr flags are no longer available. # Conflicts: # cmd/faucet/faucet.go # cmd/geth/chaincmd.go # cmd/geth/config.go # cmd/geth/consolecmd.go # cmd/geth/main.go # cmd/utils/flags.go # cmd/wnode/main.go # core/rawdb/freezer.go # eth/api_backend.go # eth/backend.go # ethclient/ethclient_test.go # ethstats/ethstats.go # graphql/service.go # internal/ethapi/backend.go # les/api_backend.go # les/api_test.go # les/checkpointoracle/oracle.go # les/client.go # les/commons.go # les/server.go # miner/stresstest/stress_clique.go # miner/stresstest/stress_ethash.go # mobile/geth.go # node/api.go # node/node.go # node/node_example_test.go # node/node_test.go # node/rpcstack.go # node/rpcstack_test.go # node/service.go # node/service_test.go # node/utils_test.go # p2p/simulations/examples/ping-pong.go # p2p/testing/peerpool.go # p2p/testing/protocolsession.go # p2p/testing/protocoltester.go # whisper/mailserver/server_test.go # whisper/whisperv6/api_test.go # whisper/whisperv6/filter_test.go # whisper/whisperv6/whisper.go # whisper/whisperv6/whisper_test.go
2020-08-03 17:40:46 +00:00
}
// Stop the stack, verify failure and check all terminations
err = stack.Close()
if err, ok := err.(*StopError); !ok {
t.Fatalf("termination failure mismatch: have %v, want StopError", err)
} else {
failer := reflect.TypeOf(&InstrumentedService{})
2020-08-15 20:22:05 +00:00
if !errors.Is(err.Services[failer], failure) {
node: refactor package node (#21105) This PR significantly changes the APIs for instantiating Ethereum nodes in a Go program. The new APIs are not backwards-compatible, but we feel that this is made up for by the much simpler way of registering services on node.Node. You can find more information and rationale in the design document: https://gist.github.com/renaynay/5bec2de19fde66f4d04c535fd24f0775. There is also a new feature in Node's Go API: it is now possible to register arbitrary handlers on the user-facing HTTP server. In geth, this facility is used to enable GraphQL. There is a single minor change relevant for geth users in this PR: The GraphQL API is no longer available separately from the JSON-RPC HTTP server. If you want GraphQL, you need to enable it using the ./geth --http --graphql flag combination. The --graphql.port and --graphql.addr flags are no longer available. # Conflicts: # cmd/faucet/faucet.go # cmd/geth/chaincmd.go # cmd/geth/config.go # cmd/geth/consolecmd.go # cmd/geth/main.go # cmd/utils/flags.go # cmd/wnode/main.go # core/rawdb/freezer.go # eth/api_backend.go # eth/backend.go # ethclient/ethclient_test.go # ethstats/ethstats.go # graphql/service.go # internal/ethapi/backend.go # les/api_backend.go # les/api_test.go # les/checkpointoracle/oracle.go # les/client.go # les/commons.go # les/server.go # miner/stresstest/stress_clique.go # miner/stresstest/stress_ethash.go # mobile/geth.go # node/api.go # node/node.go # node/node_example_test.go # node/node_test.go # node/rpcstack.go # node/rpcstack_test.go # node/service.go # node/service_test.go # node/utils_test.go # p2p/simulations/examples/ping-pong.go # p2p/testing/peerpool.go # p2p/testing/protocolsession.go # p2p/testing/protocoltester.go # whisper/mailserver/server_test.go # whisper/whisperv6/api_test.go # whisper/whisperv6/filter_test.go # whisper/whisperv6/whisper.go # whisper/whisperv6/whisper_test.go
2020-08-03 17:40:46 +00:00
t.Fatalf("failer termination failure mismatch: have %v, want %v", err.Services[failer], failure)
}
node: refactor package node (#21105) This PR significantly changes the APIs for instantiating Ethereum nodes in a Go program. The new APIs are not backwards-compatible, but we feel that this is made up for by the much simpler way of registering services on node.Node. You can find more information and rationale in the design document: https://gist.github.com/renaynay/5bec2de19fde66f4d04c535fd24f0775. There is also a new feature in Node's Go API: it is now possible to register arbitrary handlers on the user-facing HTTP server. In geth, this facility is used to enable GraphQL. There is a single minor change relevant for geth users in this PR: The GraphQL API is no longer available separately from the JSON-RPC HTTP server. If you want GraphQL, you need to enable it using the ./geth --http --graphql flag combination. The --graphql.port and --graphql.addr flags are no longer available. # Conflicts: # cmd/faucet/faucet.go # cmd/geth/chaincmd.go # cmd/geth/config.go # cmd/geth/consolecmd.go # cmd/geth/main.go # cmd/utils/flags.go # cmd/wnode/main.go # core/rawdb/freezer.go # eth/api_backend.go # eth/backend.go # ethclient/ethclient_test.go # ethstats/ethstats.go # graphql/service.go # internal/ethapi/backend.go # les/api_backend.go # les/api_test.go # les/checkpointoracle/oracle.go # les/client.go # les/commons.go # les/server.go # miner/stresstest/stress_clique.go # miner/stresstest/stress_ethash.go # mobile/geth.go # node/api.go # node/node.go # node/node_example_test.go # node/node_test.go # node/rpcstack.go # node/rpcstack_test.go # node/service.go # node/service_test.go # node/utils_test.go # p2p/simulations/examples/ping-pong.go # p2p/testing/peerpool.go # p2p/testing/protocolsession.go # p2p/testing/protocoltester.go # whisper/mailserver/server_test.go # whisper/whisperv6/api_test.go # whisper/whisperv6/filter_test.go # whisper/whisperv6/whisper.go # whisper/whisperv6/whisper_test.go
2020-08-03 17:40:46 +00:00
if len(err.Services) != 1 {
t.Fatalf("failure count mismatch: have %d, want %d", len(err.Services), 1)
}
}
node: refactor package node (#21105) This PR significantly changes the APIs for instantiating Ethereum nodes in a Go program. The new APIs are not backwards-compatible, but we feel that this is made up for by the much simpler way of registering services on node.Node. You can find more information and rationale in the design document: https://gist.github.com/renaynay/5bec2de19fde66f4d04c535fd24f0775. There is also a new feature in Node's Go API: it is now possible to register arbitrary handlers on the user-facing HTTP server. In geth, this facility is used to enable GraphQL. There is a single minor change relevant for geth users in this PR: The GraphQL API is no longer available separately from the JSON-RPC HTTP server. If you want GraphQL, you need to enable it using the ./geth --http --graphql flag combination. The --graphql.port and --graphql.addr flags are no longer available. # Conflicts: # cmd/faucet/faucet.go # cmd/geth/chaincmd.go # cmd/geth/config.go # cmd/geth/consolecmd.go # cmd/geth/main.go # cmd/utils/flags.go # cmd/wnode/main.go # core/rawdb/freezer.go # eth/api_backend.go # eth/backend.go # ethclient/ethclient_test.go # ethstats/ethstats.go # graphql/service.go # internal/ethapi/backend.go # les/api_backend.go # les/api_test.go # les/checkpointoracle/oracle.go # les/client.go # les/commons.go # les/server.go # miner/stresstest/stress_clique.go # miner/stresstest/stress_ethash.go # mobile/geth.go # node/api.go # node/node.go # node/node_example_test.go # node/node_test.go # node/rpcstack.go # node/rpcstack_test.go # node/service.go # node/service_test.go # node/utils_test.go # p2p/simulations/examples/ping-pong.go # p2p/testing/peerpool.go # p2p/testing/protocolsession.go # p2p/testing/protocoltester.go # whisper/mailserver/server_test.go # whisper/whisperv6/api_test.go # whisper/whisperv6/filter_test.go # whisper/whisperv6/whisper.go # whisper/whisperv6/whisper_test.go
2020-08-03 17:40:46 +00:00
for id := range lifecycles {
if !stopped[id] {
t.Fatalf("service %s: service not terminated", id)
}
delete(started, id)
delete(stopped, id)
}
}
node: refactor package node (#21105) This PR significantly changes the APIs for instantiating Ethereum nodes in a Go program. The new APIs are not backwards-compatible, but we feel that this is made up for by the much simpler way of registering services on node.Node. You can find more information and rationale in the design document: https://gist.github.com/renaynay/5bec2de19fde66f4d04c535fd24f0775. There is also a new feature in Node's Go API: it is now possible to register arbitrary handlers on the user-facing HTTP server. In geth, this facility is used to enable GraphQL. There is a single minor change relevant for geth users in this PR: The GraphQL API is no longer available separately from the JSON-RPC HTTP server. If you want GraphQL, you need to enable it using the ./geth --http --graphql flag combination. The --graphql.port and --graphql.addr flags are no longer available. # Conflicts: # cmd/faucet/faucet.go # cmd/geth/chaincmd.go # cmd/geth/config.go # cmd/geth/consolecmd.go # cmd/geth/main.go # cmd/utils/flags.go # cmd/wnode/main.go # core/rawdb/freezer.go # eth/api_backend.go # eth/backend.go # ethclient/ethclient_test.go # ethstats/ethstats.go # graphql/service.go # internal/ethapi/backend.go # les/api_backend.go # les/api_test.go # les/checkpointoracle/oracle.go # les/client.go # les/commons.go # les/server.go # miner/stresstest/stress_clique.go # miner/stresstest/stress_ethash.go # mobile/geth.go # node/api.go # node/node.go # node/node_example_test.go # node/node_test.go # node/rpcstack.go # node/rpcstack_test.go # node/service.go # node/service_test.go # node/utils_test.go # p2p/simulations/examples/ping-pong.go # p2p/testing/peerpool.go # p2p/testing/protocolsession.go # p2p/testing/protocoltester.go # whisper/mailserver/server_test.go # whisper/whisperv6/api_test.go # whisper/whisperv6/filter_test.go # whisper/whisperv6/whisper.go # whisper/whisperv6/whisper_test.go
2020-08-03 17:40:46 +00:00
func containsProtocol(stackProtocols []p2p.Protocol, protocol p2p.Protocol) bool {
for _, a := range stackProtocols {
if reflect.DeepEqual(a, protocol) {
return true
}
}
return false
}