From e1edfe0689966d5b5fcee530a96c31dd28aea95c Mon Sep 17 00:00:00 2001 From: lash Date: Fri, 21 Dec 2018 06:22:11 +0100 Subject: p2p/simulation: Test snapshot correctness and minimal benchmark (#18287) * p2p/simulation: WIP minimal snapshot test * p2p/simulation: Add snapshot create, load and verify to snapshot test * build: add test tag for tests * p2p/simulations, build: Revert travis change, build test sym always * p2p/simulations: Add comments, timeout check on additional events * p2p/simulation: Add benchmark template for minimal peer protocol init * p2p/simulations: Remove unused code * p2p/simulation: Correct timer reset * p2p/simulations: Put snapshot check events in buffer and call blocking * p2p/simulations: TestSnapshot fail if Load function returns early * p2p/simulations: TestSnapshot wait for all connections before returning * p2p/simulation: Revert to before wait for snap load (5e75594) * p2p/simulations: add "conns after load" subtest to TestSnapshot and nudge --- swarm/network/simulation/simulation_test.go | 35 ++++++++--------------------- 1 file changed, 9 insertions(+), 26 deletions(-) (limited to 'swarm/network') diff --git a/swarm/network/simulation/simulation_test.go b/swarm/network/simulation/simulation_test.go index ca8599d7c..4667a2abc 100644 --- a/swarm/network/simulation/simulation_test.go +++ b/swarm/network/simulation/simulation_test.go @@ -26,9 +26,8 @@ import ( "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/node" - "github.com/ethereum/go-ethereum/p2p" + "github.com/ethereum/go-ethereum/p2p/simulations" "github.com/ethereum/go-ethereum/p2p/simulations/adapters" - "github.com/ethereum/go-ethereum/rpc" colorable "github.com/mattn/go-colorable" ) @@ -182,39 +181,23 @@ func noopServiceFunc(ctx *adapters.ServiceContext, b *sync.Map) (node.Service, f return newNoopService(), nil, nil } -// noopService is the service that does not do anything -// but implements node.Service interface. -type noopService struct{} - func newNoopService() node.Service { return &noopService{} } -func (t *noopService) Protocols() []p2p.Protocol { - return []p2p.Protocol{} -} - -func (t *noopService) APIs() []rpc.API { - return []rpc.API{} -} - -func (t *noopService) Start(server *p2p.Server) error { - return nil -} - -func (t *noopService) Stop() error { - return nil -} - -// a helper function for most basic noop service -// of a different type then noopService to test +// a helper function for most basic Noop service +// of a different type then NoopService to test // multiple services on one node. func noopService2Func(ctx *adapters.ServiceContext, b *sync.Map) (node.Service, func(), error) { return new(noopService2), nil, nil } -// noopService2 is the service that does not do anything +// NoopService2 is the service that does not do anything // but implements node.Service interface. type noopService2 struct { - noopService + simulations.NoopService +} + +type noopService struct { + simulations.NoopService } -- cgit v1.2.3