2018-03-09 20:44:13 +00:00
|
|
|
package server
|
|
|
|
|
|
|
|
import (
|
2018-05-28 18:05:06 +00:00
|
|
|
"cwtch.im/cwtch/protocol"
|
2018-06-27 15:14:59 +00:00
|
|
|
"cwtch.im/cwtch/server/metrics"
|
2018-05-28 18:05:06 +00:00
|
|
|
"cwtch.im/cwtch/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)
|
2018-03-09 20:44:13 +00:00
|
|
|
ai := new(application.ApplicationInstance)
|
|
|
|
ra := new(application.RicochetApplication)
|
|
|
|
msi := new(storage.MessageStore)
|
|
|
|
os.Remove("ms.test")
|
2018-06-27 15:14:59 +00:00
|
|
|
msi.Init("ms.test", 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 {
|
2018-06-03 19:36:20 +00:00
|
|
|
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
|
|
|
}
|