Skip to content

Commit

Permalink
Merge branch 'main' of github.com:xmtp/xmtp-node-go into insipx/valid…
Browse files Browse the repository at this point in the history
…ation-cred-server
  • Loading branch information
insipx committed May 20, 2024
2 parents baef063 + 63cb087 commit 58b170e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pkg/mls/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,10 @@ func (s *Store) GetInboxIds(ctx context.Context, req *identity.GetInboxIdsReques
resp := identity.GetInboxIdsResponse_Response{}
resp.Address = address

for _, log_entry := range addressLogEntries {
if log_entry.Address == address {
resp.InboxId = &log_entry.InboxID
for _, logEntry := range addressLogEntries {
if logEntry.Address == address {
inboxId := logEntry.InboxID
resp.InboxId = &inboxId
}
}
out[index] = &resp
Expand Down
25 changes: 25 additions & 0 deletions pkg/mls/store/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,31 @@ func TestInboxIds(t *testing.T) {
require.Equal(t, "inbox2", *resp.Responses[1].InboxId)
}

func TestMultipleInboxIds(t *testing.T) {
store, cleanup := NewTestStore(t)
defer cleanup()
ctx := context.Background()

_, err := store.queries.InsertAddressLog(ctx, queries.InsertAddressLogParams{Address: "address_1", InboxID: "inbox_1", AssociationSequenceID: sql.NullInt64{Valid: true, Int64: 1}, RevocationSequenceID: sql.NullInt64{Valid: false}})
require.NoError(t, err)
_, err = store.queries.InsertAddressLog(ctx, queries.InsertAddressLogParams{Address: "address_2", InboxID: "inbox_2", AssociationSequenceID: sql.NullInt64{Valid: true, Int64: 2}, RevocationSequenceID: sql.NullInt64{Valid: false}})
require.NoError(t, err)

reqs := make([]*identity.GetInboxIdsRequest_Request, 0)
reqs = append(reqs, &identity.GetInboxIdsRequest_Request{
Address: "address_1",
})
reqs = append(reqs, &identity.GetInboxIdsRequest_Request{
Address: "address_2",
})
req := &identity.GetInboxIdsRequest{
Requests: reqs,
}
resp, _ := store.GetInboxIds(context.Background(), req)
require.Equal(t, "inbox_1", *resp.Responses[0].InboxId)
require.Equal(t, "inbox_2", *resp.Responses[1].InboxId)
}

func TestCreateInstallation(t *testing.T) {
store, cleanup := NewTestStore(t)
defer cleanup()
Expand Down

0 comments on commit 58b170e

Please sign in to comment.