Official cwtch.im peer and server implementations.
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 809B

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