Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
310 changes: 0 additions & 310 deletions docs/swagger/swagger.yaml

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion internal/database/sqlcommon/data_sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ func TestDataE2EWithDB(t *testing.T) {
fb := database.DataQueryFactory.NewFilter(ctx)
filter := fb.And(
fb.Eq("id", dataUpdated.ID.String()),
fb.Eq("namespace", dataUpdated.Namespace),
fb.Eq("validator", string(dataUpdated.Validator)),
fb.Eq("datatype.name", dataUpdated.Datatype.Name),
fb.Eq("datatype.version", dataUpdated.Datatype.Version),
Expand Down
1 change: 0 additions & 1 deletion internal/database/sqlcommon/datatype_sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ func TestDatatypeE2EWithDB(t *testing.T) {
fb := database.DatatypeQueryFactory.NewFilter(ctx)
filter := fb.And(
fb.Eq("id", datatypeUpdated.ID.String()),
fb.Eq("namespace", datatypeUpdated.Namespace),
fb.Eq("validator", string(datatypeUpdated.Validator)),
fb.Eq("name", datatypeUpdated.Name),
fb.Eq("version", datatypeUpdated.Version),
Expand Down
20 changes: 10 additions & 10 deletions internal/database/sqlcommon/filter_sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestSQLQueryFactory(t *testing.T) {
s.individualSort = true
fb := database.MessageQueryFactory.NewFilter(context.Background())
f := fb.And(
fb.Eq("namespace", "ns1"),
fb.Eq("tag", "tag1"),
fb.Or(
fb.Eq("id", "35c11cba-adff-4a4d-970a-02e3a0858dc8"),
fb.Eq("id", "caefb9d1-9fc9-4d6a-a155-514d3139adf7"),
Expand All @@ -43,7 +43,7 @@ func TestSQLQueryFactory(t *testing.T) {
Skip(50).
Limit(25).
Sort("-id").
Sort("namespace").
Sort("tag").
Sort("-sequence")

sel := squirrel.Select("*").From("mytable")
Expand All @@ -54,8 +54,8 @@ func TestSQLQueryFactory(t *testing.T) {

sqlFilter, args, err := sel.ToSql()
assert.NoError(t, err)
assert.Equal(t, "SELECT * FROM mytable WHERE (ns = ? AND (id = ? OR id = ?) AND seq > ? AND confirmed IS NULL) ORDER BY id DESC, ns, seq DESC LIMIT 25 OFFSET 50", sqlFilter)
assert.Equal(t, "ns1", args[0])
assert.Equal(t, "SELECT * FROM mytable WHERE (tag = ? AND (id = ? OR id = ?) AND seq > ? AND confirmed IS NULL) ORDER BY id DESC, tag, seq DESC LIMIT 25 OFFSET 50", sqlFilter)
assert.Equal(t, "tag1", args[0])
assert.Equal(t, "35c11cba-adff-4a4d-970a-02e3a0858dc8", args[1])
assert.Equal(t, "caefb9d1-9fc9-4d6a-a155-514d3139adf7", args[2])
assert.Equal(t, int64(12345), args[3])
Expand Down Expand Up @@ -125,8 +125,8 @@ func TestSQLQueryFactoryFinalizeFail(t *testing.T) {
s, _ := newMockProvider().init()
fb := database.MessageQueryFactory.NewFilter(context.Background())
sel := squirrel.Select("*").From("mytable")
_, _, _, err := s.filterSelect(context.Background(), "ns", sel, fb.Eq("namespace", map[bool]bool{true: false}), nil, []interface{}{"sequence"})
assert.Regexp(t, "FF00143.*namespace", err)
_, _, _, err := s.filterSelect(context.Background(), "ns", sel, fb.Eq("tag", map[bool]bool{true: false}), nil, []interface{}{"sequence"})
assert.Regexp(t, "FF00143.*tag", err)
}

func TestSQLQueryFactoryBadOp(t *testing.T) {
Expand Down Expand Up @@ -168,7 +168,7 @@ func TestSQLQueryFactoryDefaultSort(t *testing.T) {
sel := squirrel.Select("*").From("mytable")
fb := database.MessageQueryFactory.NewFilter(context.Background())
f := fb.And(
fb.Eq("namespace", "ns1"),
fb.Eq("tag", "tag1"),
)
sel, _, _, err := s.filterSelect(context.Background(), "", sel, f, nil, []interface{}{
&database.SortField{
Expand All @@ -181,8 +181,8 @@ func TestSQLQueryFactoryDefaultSort(t *testing.T) {

sqlFilter, args, err := sel.ToSql()
assert.NoError(t, err)
assert.Equal(t, "SELECT * FROM mytable WHERE (namespace = ?) ORDER BY seq DESC NULLS LAST", sqlFilter)
assert.Equal(t, "ns1", args[0])
assert.Equal(t, "SELECT * FROM mytable WHERE (tag = ?) ORDER BY seq DESC NULLS LAST", sqlFilter)
assert.Equal(t, "tag1", args[0])
}

func TestSQLQueryFactoryDefaultSortBadType(t *testing.T) {
Expand All @@ -191,7 +191,7 @@ func TestSQLQueryFactoryDefaultSortBadType(t *testing.T) {
sel := squirrel.Select("*").From("mytable")
fb := database.MessageQueryFactory.NewFilter(context.Background())
f := fb.And(
fb.Eq("namespace", "ns1"),
fb.Eq("tag", "tag1"),
)
assert.PanicsWithValue(t, "unknown sort type: 100", func() {
s.filterSelect(context.Background(), "", sel, f, nil, []interface{}{100})
Expand Down
1 change: 0 additions & 1 deletion internal/database/sqlcommon/group_sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ func TestUpsertGroupE2EWithDB(t *testing.T) {
fb := database.GroupQueryFactory.NewFilter(ctx)
filter := fb.And(
fb.Eq("hash", groupUpdated.Hash),
fb.Eq("namespace", groupUpdated.Namespace),
fb.Eq("message", groupUpdated.Message),
fb.Gt("created", "0"),
)
Expand Down
1 change: 0 additions & 1 deletion internal/database/sqlcommon/message_sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ func TestUpsertE2EWithDB(t *testing.T) {
fb := database.MessageQueryFactory.NewFilter(ctx)
filter := fb.And(
fb.Eq("id", msgUpdated.Header.ID.String()),
fb.Eq("namespace", msgUpdated.Header.Namespace),
fb.Eq("type", string(msgUpdated.Header.Type)),
fb.Eq("author", msgUpdated.Header.Author),
fb.Eq("topics", msgUpdated.Header.Topics),
Expand Down
1 change: 0 additions & 1 deletion internal/database/sqlcommon/subscription_sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ func TestSubscriptionsE2EWithDB(t *testing.T) {
// Query back the subscription
fb := database.SubscriptionQueryFactory.NewFilter(ctx)
filter := fb.And(
fb.Eq("namespace", subscriptionUpdated.Namespace),
fb.Eq("name", subscriptionUpdated.Name),
)
subscriptionRes, res, err := s.GetSubscriptions(ctx, "ns1", filter.Count(true))
Expand Down
1 change: 0 additions & 1 deletion internal/database/sqlcommon/tokenpool_sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ func TestTokenPoolE2EWithDB(t *testing.T) {
fb := database.TokenPoolQueryFactory.NewFilter(ctx)
filter := fb.And(
fb.Eq("id", pool.ID.String()),
fb.Eq("namespace", pool.Namespace),
fb.Eq("name", pool.Name),
fb.Eq("locator", pool.Locator),
fb.Eq("message", pool.Message),
Expand Down
1 change: 0 additions & 1 deletion internal/database/sqlcommon/verifier_sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ func TestVerifiersE2EWithDB(t *testing.T) {
fb := database.VerifierQueryFactory.NewFilter(ctx)
filter := fb.And(
fb.Eq("value", string(verifierUpdated.Value)),
fb.Eq("namespace", verifierUpdated.Namespace),
)
verifierRes, res, err := s.GetVerifiers(ctx, "ns1", filter.Count(true))
assert.NoError(t, err)
Expand Down
1 change: 0 additions & 1 deletion internal/events/aggregator_batch_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,6 @@ func (bs *batchState) flushPins(ctx context.Context) error {
filter := fb.Or()
for batchID, indexes := range pinsDispatched {
filter.Condition(fb.And(
fb.Eq("namespace", bs.namespace),
fb.Eq("batch", batchID),
fb.In("index", indexes),
))
Expand Down
10 changes: 4 additions & 6 deletions internal/events/event_dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,10 @@ func newEventDispatcher(ctx context.Context, ei events.Plugin, di database.Plugi
MaximumDelay: config.GetDuration(coreconfig.EventDispatcherRetryMaxDelay),
Factor: config.GetFloat64(coreconfig.EventDispatcherRetryFactor),
},
namespace: sub.definition.Namespace,
offsetType: core.OffsetTypeSubscription,
offsetName: sub.definition.ID.String(),
addCriteria: func(af database.AndFilter) database.AndFilter {
return af.Condition(af.Builder().Eq("namespace", sub.definition.Namespace))
},
namespace: sub.definition.Namespace,
offsetType: core.OffsetTypeSubscription,
offsetName: sub.definition.ID.String(),
addCriteria: func(af database.AndFilter) database.AndFilter { return af },
queryFactory: database.EventQueryFactory,
getItems: ed.getEvents,
newEventsHandler: ed.bufferedDelivery,
Expand Down
1 change: 0 additions & 1 deletion internal/networkmap/data_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ func (nm *networkMap) GetIdentityByID(ctx context.Context, id string) (*core.Ide
func (nm *networkMap) withVerifiers(ctx context.Context, identity *core.Identity) (*core.IdentityWithVerifiers, error) {
fb := database.VerifierQueryFactory.NewFilter(ctx)
filter := fb.And(
fb.Eq("namespace", identity.Namespace),
fb.Eq("identity", identity.ID),
)
verifiers, _, err := nm.database.GetVerifiers(ctx, nm.namespace, filter)
Expand Down
1 change: 0 additions & 1 deletion internal/networkmap/did.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ func (nm *networkMap) generateDIDDocument(ctx context.Context, identity *core.Id
fb := database.VerifierQueryFactory.NewFilter(ctx)
filter := fb.And(
fb.Eq("identity", identity.ID),
fb.Eq("namespace", identity.Namespace),
)
verifiers, _, err := nm.database.GetVerifiers(ctx, nm.namespace, filter)
if err != nil {
Expand Down
32 changes: 16 additions & 16 deletions pkg/database/filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
func TestBuildMessageFilter(t *testing.T) {
fb := MessageQueryFactory.NewFilter(context.Background())
f, err := fb.And().
Condition(fb.Eq("namespace", "ns1")).
Condition(fb.Eq("tag", "tag1")).
Condition(fb.Or().
Condition(fb.Eq("id", "35c11cba-adff-4a4d-970a-02e3a0858dc8")).
Condition(fb.Eq("id", "caefb9d1-9fc9-4d6a-a155-514d3139adf7")),
Expand All @@ -39,11 +39,11 @@ func TestBuildMessageFilter(t *testing.T) {
Skip(50).
Limit(25).
Count(true).
Sort("namespace").
Sort("tag").
Descending().
Finalize()
assert.NoError(t, err)
assert.Equal(t, "( namespace == 'ns1' ) && ( ( id == '35c11cba-adff-4a4d-970a-02e3a0858dc8' ) || ( id == 'caefb9d1-9fc9-4d6a-a155-514d3139adf7' ) ) && ( sequence >> 12345 ) && ( confirmed == null ) sort=-namespace skip=50 limit=25 count=true", f.String())
assert.Equal(t, "( tag == 'tag1' ) && ( ( id == '35c11cba-adff-4a4d-970a-02e3a0858dc8' ) || ( id == 'caefb9d1-9fc9-4d6a-a155-514d3139adf7' ) ) && ( sequence >> 12345 ) && ( confirmed == null ) sort=-tag skip=50 limit=25 count=true", f.String())
}

func TestBuildMessageFilter2(t *testing.T) {
Expand Down Expand Up @@ -183,19 +183,19 @@ func TestBuildMessageStringConvert(t *testing.T) {
u := fftypes.MustParseUUID("3f96e0d5-a10e-47c6-87a0-f2e7604af179")
b32 := fftypes.UUIDBytes(u)
f, err := fb.And(
fb.Lt("namespace", int(111)),
fb.Lt("namespace", int32(222)),
fb.Lt("namespace", int64(333)),
fb.Lt("namespace", uint(444)),
fb.Lt("namespace", uint32(555)),
fb.Lt("namespace", uint64(666)),
fb.Lt("namespace", *u),
fb.Lt("namespace", u),
fb.Lt("namespace", *b32),
fb.Lt("namespace", b32),
fb.Lt("tag", int(111)),
fb.Lt("tag", int32(222)),
fb.Lt("tag", int64(333)),
fb.Lt("tag", uint(444)),
fb.Lt("tag", uint32(555)),
fb.Lt("tag", uint64(666)),
fb.Lt("tag", *u),
fb.Lt("tag", u),
fb.Lt("tag", *b32),
fb.Lt("tag", b32),
).Finalize()
assert.NoError(t, err)
assert.Equal(t, "( namespace << '111' ) && ( namespace << '222' ) && ( namespace << '333' ) && ( namespace << '444' ) && ( namespace << '555' ) && ( namespace << '666' ) && ( namespace << '3f96e0d5-a10e-47c6-87a0-f2e7604af179' ) && ( namespace << '3f96e0d5-a10e-47c6-87a0-f2e7604af179' ) && ( namespace << '3f96e0d5a10e47c687a0f2e7604af17900000000000000000000000000000000' ) && ( namespace << '3f96e0d5a10e47c687a0f2e7604af17900000000000000000000000000000000' )", f.String())
assert.Equal(t, "( tag << '111' ) && ( tag << '222' ) && ( tag << '333' ) && ( tag << '444' ) && ( tag << '555' ) && ( tag << '666' ) && ( tag << '3f96e0d5-a10e-47c6-87a0-f2e7604af179' ) && ( tag << '3f96e0d5-a10e-47c6-87a0-f2e7604af179' ) && ( tag << '3f96e0d5a10e47c687a0f2e7604af17900000000000000000000000000000000' ) && ( tag << '3f96e0d5a10e47c687a0f2e7604af17900000000000000000000000000000000' )", f.String())
}

func TestBuildMessageBoolConvert(t *testing.T) {
Expand Down Expand Up @@ -244,8 +244,8 @@ func TestBuildFFStringArrayConvert(t *testing.T) {

func TestBuildMessageFailStringConvert(t *testing.T) {
fb := MessageQueryFactory.NewFilter(context.Background())
_, err := fb.Lt("namespace", map[bool]bool{true: false}).Finalize()
assert.Regexp(t, "FF00143.*namespace", err)
_, err := fb.Lt("tag", map[bool]bool{true: false}).Finalize()
assert.Regexp(t, "FF00143.*tag", err)
}

func TestBuildMessageFailBoolConvert(t *testing.T) {
Expand Down
Loading