mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-10 03:31:20 +00:00
f3f5b8e5a6
sharding: simplify service registry to prevent nil pointer errors Former-commit-id: ba4833c385e5212723932491810baad62e3ff0f9 [formerly c550c6d0837999f46a6de55a36fb1ae92d2ecd6f] Former-commit-id: 80e9e13bc811444b461dad6bdf9eec633b911bec
50 lines
1.1 KiB
Go
50 lines
1.1 KiB
Go
package observer
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/ethereum/go-ethereum/log"
|
|
"github.com/ethereum/go-ethereum/sharding"
|
|
"github.com/ethereum/go-ethereum/sharding/database"
|
|
internal "github.com/ethereum/go-ethereum/sharding/internal"
|
|
"github.com/ethereum/go-ethereum/sharding/p2p"
|
|
)
|
|
|
|
// Verifies that Observer implements the Actor interface.
|
|
var _ = sharding.Actor(&Observer{})
|
|
|
|
func TestStartStop(t *testing.T) {
|
|
h := internal.NewLogHandler(t)
|
|
log.Root().SetHandler(h)
|
|
|
|
server, err := p2p.NewServer()
|
|
if err != nil {
|
|
t.Fatalf("Unable to setup p2p server: %v", err)
|
|
}
|
|
shardChainDB, err := database.NewShardDB("", "", true)
|
|
if err != nil {
|
|
t.Fatalf("Unable to setup db: %v", err)
|
|
}
|
|
shardID := 0
|
|
|
|
observer, err := NewObserver(server, shardChainDB, shardID)
|
|
if err != nil {
|
|
t.Fatalf("Unable to set up observer service: %v", err)
|
|
}
|
|
|
|
observer.Start()
|
|
|
|
h.VerifyLogMsg("Starting observer service")
|
|
|
|
err = observer.Stop()
|
|
if err != nil {
|
|
t.Fatalf("Unable to stop observer service: %v", err)
|
|
}
|
|
|
|
h.VerifyLogMsg("Stopping observer service")
|
|
|
|
if observer.ctx.Err() == nil {
|
|
t.Errorf("Context was not cancelled")
|
|
}
|
|
}
|