mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-10 03:31:20 +00:00
346b9ae8aa
sharding: random transaction generator Former-commit-id: b41891c474372ab54cbf1e3fa34dc7399f42c6d4 [formerly 69b7da173694490fa44748fe3cb3b2aa84f36b46] Former-commit-id: b642be5e1b7b4aad59011983bacda4a9b1166463
47 lines
1.0 KiB
Go
47 lines
1.0 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 := database.NewShardKV()
|
|
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")
|
|
}
|
|
}
|