-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2ac15f1
commit 21cfd44
Showing
15 changed files
with
277 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package api | ||
|
||
import ( | ||
"context" | ||
"database/sql" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
"github.com/xmtp/xmtpd/pkg/proto/identity/associations" | ||
"github.com/xmtp/xmtpd/pkg/proto/xmtpv4/message_api" | ||
test "github.com/xmtp/xmtpd/pkg/testing" | ||
"google.golang.org/protobuf/proto" | ||
) | ||
|
||
func newTestService(t *testing.T) (*Service, *sql.DB, func()) { | ||
ctx := context.Background() | ||
log := test.NewLog(t) | ||
db, _, dbCleanup := test.NewDB(t, ctx) | ||
|
||
svc, err := NewReplicationApiService(ctx, log, db) | ||
require.NoError(t, err) | ||
|
||
return svc, db, func() { | ||
svc.Close() | ||
dbCleanup() | ||
} | ||
} | ||
|
||
func TestSimplePublish(t *testing.T) { | ||
svc, _, cleanup := newTestService(t) | ||
defer cleanup() | ||
|
||
resp, err := svc.PublishEnvelope( | ||
context.Background(), | ||
&message_api.PublishEnvelopeRequest{ | ||
PayerEnvelope: &message_api.PayerEnvelope{ | ||
UnsignedClientEnvelope: []byte{0x5}, | ||
PayerSignature: &associations.RecoverableEcdsaSignature{}, | ||
}, | ||
}, | ||
) | ||
require.NoError(t, err) | ||
require.NotNil(t, resp) | ||
|
||
unsignedEnv := &message_api.UnsignedOriginatorEnvelope{} | ||
require.NoError( | ||
t, | ||
proto.Unmarshal(resp.GetOriginatorEnvelope().GetUnsignedOriginatorEnvelope(), unsignedEnv), | ||
) | ||
require.Equal(t, uint8(0x5), unsignedEnv.GetPayerEnvelope().GetUnsignedClientEnvelope()[0]) | ||
|
||
// TODO(rich) Test that the published envelope is retrievable via the query API | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.