Official cwtch.im peer and server implementations. https://cwtch.im
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

server_instance_test.go 856B

12345678910111213141516171819202122232425262728293031323334353637
  1. package server
  2. import (
  3. "cwtch.im/cwtch/protocol"
  4. "cwtch.im/cwtch/server/metrics"
  5. "cwtch.im/cwtch/server/storage"
  6. "git.openprivacy.ca/openprivacy/libricochet-go/application"
  7. "os"
  8. "testing"
  9. "time"
  10. )
  11. func TestServerInstance(t *testing.T) {
  12. si := new(Instance)
  13. ai := new(application.Instance)
  14. ra := new(application.RicochetApplication)
  15. msi := new(storage.MessageStore)
  16. os.RemoveAll("messages")
  17. msi.Init(".", 5, metrics.NewCounter())
  18. gm := protocol.GroupMessage{
  19. Ciphertext: []byte("Hello this is a fairly average length message that we are writing here."),
  20. Spamguard: []byte{},
  21. }
  22. si.Init(ai, ra, msi)
  23. msi.AddMessage(gm)
  24. res := si.HandleFetchRequest()
  25. if len(res) != 1 {
  26. t.Errorf("Expected 1 Group messages Instead got %v", res)
  27. }
  28. // ra.HandleApplicationInstance(ai)
  29. si.HandleGroupMessage(&gm)
  30. time.Sleep(time.Second * 2)
  31. }