-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathpublish_test.go
64 lines (52 loc) · 1.43 KB
/
publish_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package app_test
import (
"context"
"testing"
"time"
logging "github.com/ipfs/go-log"
application "github.com/pravahio/go-mesh/application"
cfg "github.com/pravahio/go-mesh/config"
driver "github.com/pravahio/go-mesh/driver/eth"
fpubsub "github.com/pravahio/go-mesh/pubsub"
bootservice "github.com/pravahio/go-mesh/service/bootstrap"
pubservice "github.com/pravahio/go-mesh/service/publisher"
)
func TestPublish(t *testing.T) {
logging.SetLogLevel("svc-bootstrap", "DEBUG")
logging.SetLogLevel("application", "DEBUG")
logging.SetLogLevel("svc-publisher", "DEBUG")
logging.SetLogLevel("fpubsub", "DEBUG")
logging.SetLogLevel("pubsub", "DEBUG")
logging.SetLogLevel("eth-driver", "DEBUG")
app, err := application.NewApplication(context.Background(), nil, nil, "0.0.0.0", "0", false)
if err != nil {
t.Fatal(err)
}
ethDriver, err := driver.NewEthDriver("", nil)
if err != nil {
t.Fatal(err)
}
bservice := bootservice.NewBootstrapService(
false,
"abc",
cfg.BootstrapList,
15*time.Second)
pubService := pubservice.NewPublisherService(ethDriver)
app.InjectService(bservice)
app.InjectService(pubService)
f := fpubsub.NewFilter(ethDriver)
app.SetGossipPeerFilter(f)
err = app.Start()
if err != nil {
t.Fatal(err)
}
time.Sleep(3 * time.Second)
err = pubService.RegisterToPublish("GGN.BUS")
if err != nil {
t.Fatal(err)
}
err = pubService.PublishData("GGN.BUS", []byte("yyyy"))
if err != nil {
t.Fatal(err)
}
}