mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 07:28:06 -05:00
Random transaction generator (#171)
sharding: random transaction generator Former-commit-id: b41891c474372ab54cbf1e3fa34dc7399f42c6d4 [formerly 69b7da173694490fa44748fe3cb3b2aa84f36b46] Former-commit-id: b642be5e1b7b4aad59011983bacda4a9b1166463
This commit is contained in:
committed by
terence tsao
parent
ad291e93f6
commit
346b9ae8aa
@@ -1,6 +1,46 @@
|
||||
package observer
|
||||
|
||||
import "github.com/ethereum/go-ethereum/sharding"
|
||||
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")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user