cwtch/server/server_instance_test.go

38 lines
856 B
Go
Raw Normal View History

2018-03-09 20:44:13 +00:00
package server
import (
2018-05-28 18:05:06 +00:00
"cwtch.im/cwtch/protocol"
"cwtch.im/cwtch/server/metrics"
2019-01-21 20:11:40 +00:00
"cwtch.im/cwtch/server/storage"
2018-06-23 16:15:36 +00:00
"git.openprivacy.ca/openprivacy/libricochet-go/application"
2018-03-09 20:44:13 +00:00
"os"
"testing"
2018-03-30 21:16:51 +00:00
"time"
2018-03-09 20:44:13 +00:00
)
func TestServerInstance(t *testing.T) {
2018-03-14 22:23:35 +00:00
si := new(Instance)
2019-01-23 20:50:53 +00:00
ai := new(application.Instance)
2018-03-09 20:44:13 +00:00
ra := new(application.RicochetApplication)
msi := new(storage.MessageStore)
os.RemoveAll("messages")
msi.Init(".", 5, metrics.NewCounter())
2018-03-09 20:44:13 +00:00
gm := protocol.GroupMessage{
Ciphertext: []byte("Hello this is a fairly average length message that we are writing here."),
Spamguard: []byte{},
}
si.Init(ai, ra, msi)
msi.AddMessage(gm)
res := si.HandleFetchRequest()
if len(res) != 1 {
t.Errorf("Expected 1 Group messages Instead got %v", res)
2018-03-09 20:44:13 +00:00
}
2018-03-30 21:16:51 +00:00
// ra.HandleApplicationInstance(ai)
si.HandleGroupMessage(&gm)
time.Sleep(time.Second * 2)
2018-03-09 20:44:13 +00:00
}