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.

29 lines
788B

  1. package model
  2. import (
  3. "cwtch.im/cwtch/protocol"
  4. "github.com/golang/protobuf/proto"
  5. "testing"
  6. "time"
  7. )
  8. func TestGroup(t *testing.T) {
  9. g := NewGroup("server.onion")
  10. dgm := &protocol.DecryptedGroupMessage{
  11. Onion: proto.String("onion"),
  12. Text: proto.String("Hello World!"),
  13. Timestamp: proto.Int32(int32(time.Now().Unix())),
  14. SignedGroupId: []byte{},
  15. Signature: []byte{},
  16. PreviousMessageSig: []byte{},
  17. Padding: []byte{},
  18. }
  19. encMessage := g.EncryptMessage(dgm)
  20. ok, message := g.DecryptMessage(encMessage)
  21. if !ok || message.GetText() != "Hello World!" {
  22. t.Errorf("group encryption was invalid, or returned wrong message decrypted:%v message:%v", ok, message)
  23. return
  24. }
  25. t.Logf("Got message %v", message)
  26. }