prysm-pulse/sharding/observer/service_test.go
Preston Van Loon 68eba02cc2 Remove most of the remaining geth code and set up bazel (#235)
* Remove most of the remaining geth code and set up bazel for this

* chmod +x

* Add flake check

* better flake detection


Former-commit-id: 5c332ecbf2923943f646f1fe40befa95be883329 [formerly 99590fc354514584700e5ce8d7d30a8a7d541f29]
Former-commit-id: e5f919b553fe698e98090965d34eb721990b5693
2018-07-07 13:23:19 -04:00

61 lines
1.6 KiB
Go

package observer
import (
"testing"
"github.com/ethereum/go-ethereum/log"
"github.com/prysmaticlabs/geth-sharding/sharding"
"github.com/prysmaticlabs/geth-sharding/sharding/database"
"github.com/prysmaticlabs/geth-sharding/sharding/internal"
"github.com/prysmaticlabs/geth-sharding/sharding/mainchain"
"github.com/prysmaticlabs/geth-sharding/sharding/p2p"
"github.com/prysmaticlabs/geth-sharding/sharding/params"
"github.com/prysmaticlabs/geth-sharding/sharding/syncer"
)
// 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
client := &mainchain.SMCClient{}
syncer, err := syncer.NewSyncer(params.DefaultConfig, client, server, shardChainDB, shardID)
if err != nil {
t.Fatalf("Unable to setup sync service: %v", err)
}
observer, err := NewObserver(server, shardChainDB, shardID, syncer, client)
if err != nil {
t.Fatalf("Unable to set up observer service: %v", err)
}
observer.sync.Start()
h.VerifyLogMsg("Starting sync service")
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")
}
}