saltyim is the Go library and reference client and broker implementation for Salty IM it contains a command-line client (cli), a terminal user interface (tui), builtin server/broker and a Mobile / Desktop App PWA (progressive web app)
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.

59 lines
1.5 KiB

package saltyim
import (
func TestClient_InvalidEndpoint(t *testing.T) {
assert := assert.New(t)
require := require.New(t)
me, err := ParseAddr("")
_, err = NewClient(me)
func TestClient_Outbox(t *testing.T) {
test := require.New(t)
endpoint := &url.URL{Host: "", Path: "/path", Scheme: "https"}
key := keys.GenerateEdX25519Key()
client := &Client{me: &Addr{endpoint: endpoint}, id: &Identity{key: key}}
outbox := client.Outbox()
test.True(endpoint.Path == "/path",
"endpoint.Path should not be modified after call to client.Outbox()")
test.False(*endpoint == *outbox,
"endpoint and outbox should not point to the same *url.URL")
expected := fmt.Sprintf("/%x", sha256.Sum256(key.Private()))
test.True(outbox.Path == expected, "expected %s but got %s", expected, outbox.Path)
func TestClient_Outbox_State(t *testing.T) {
req := require.New(t)
endpoint := &url.URL{Host: "", Path: "/path", Scheme: "https"}
key := keys.GenerateEdX25519Key()
state := NewState()
var testIndex int64 = 100
state.SetIndex("testIndex", testIndex)
client := &Client{me: &Addr{endpoint: endpoint}, id: &Identity{key: key}, state: state}
outboxClient := client.OutboxClient(nil)
req.Equal(state, outboxClient.state)
req.Equal(testIndex, outboxClient.state.GetIndex("testIndex"))