-
Notifications
You must be signed in to change notification settings - Fork 62
endpoint.Service: Bind multiple ephemeral identities at the same time #1009 #1033
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
312e46b to
5625f77
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again for addressing my comments.
platform/view/services/storage/driver/sql/postgres/binding_test.go
Outdated
Show resolved
Hide resolved
platform/view/services/storage/driver/sql/sqlite/binding_test.go
Outdated
Show resolved
Hide resolved
674d885 to
2cd3a22
Compare
585de5d to
406634f
Compare
Signed-off-by: [email protected] <[email protected]>
Signed-off-by: [email protected] <[email protected]>
Signed-off-by: [email protected] <[email protected]>
Signed-off-by: [email protected] <[email protected]>
Signed-off-by: [email protected] <[email protected]>
Signed-off-by: [email protected] <[email protected]>
Signed-off-by: [email protected] <[email protected]>
Signed-off-by: [email protected] <[email protected]>
Signed-off-by: [email protected] <[email protected]>
Signed-off-by: [email protected] <[email protected]>
Signed-off-by: Angelo De Caro <[email protected]>
2. fixed postgres test Signed-off-by: [email protected] <[email protected]>
Signed-off-by: [email protected] <[email protected]>
Signed-off-by: [email protected] <[email protected]>
Signed-off-by: [email protected] <[email protected]>
Signed-off-by: [email protected] <[email protected]>
406634f to
efa9438
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this PR! It is in a good shape already. See below a few minor comments to address. Thanks again!
platform/fabric/sdk/dig/sdk_test.go
Outdated
| sss := sdk.WithBool("fabric.enabled", true) | ||
| err := sdk.DryRunWiring(NewFrom, sss) | ||
| assert.NoError(t, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this change really needed?
| logger.DebugfContext(ctx, "Id [%s] is an unregistered long term ID", longTerm.UniqueID()) | ||
|
|
||
| func (db *BindingStore) PutBindings(ctx context.Context, longTerm view.Identity, ephemerals ...view.Identity) error { | ||
| if len(ephemerals) == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we also check that longTerm is not nil?
platform/view/services/storage/driver/sql/postgres/binding_test.go
Outdated
Show resolved
Hide resolved
| // Input identities | ||
| longTerm := view.Identity("long") | ||
| e1 := view.Identity("eph1") | ||
| e2 := view.Identity("eph2") | ||
|
|
||
| // Check that store does not have bindings for e1 and e2 | ||
| lt, err := db.GetLongTerm(ctx, e1) | ||
| require.NoError(t, err) | ||
| require.ElementsMatch(t, len(lt), 0) | ||
| lt, err = db.GetLongTerm(ctx, e2) | ||
| require.NoError(t, err) | ||
| require.ElementsMatch(t, len(lt), 0) | ||
|
|
||
| // Create new bindings | ||
| err = db.PutBindings(ctx, longTerm, e1, e2) | ||
| require.NoError(t, err) | ||
|
|
||
| // Check that the bindings where correctly written | ||
| lt, err = db.GetLongTerm(ctx, e1) | ||
| require.NoError(t, err) | ||
| require.ElementsMatch(t, lt, longTerm) | ||
|
|
||
| lt, err = db.GetLongTerm(ctx, e2) | ||
| require.NoError(t, err) | ||
| require.ElementsMatch(t, lt, longTerm) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test looks more or less identical to the postgres/binding_test.go
Let's move the actual test case to common/binding_test.go into a test method e.g.,
RunPutBindingTests, which takes as input a database abstraction.
In this file here we just instantiate the db and call common.RunPutBindingTests(t, db). We do the same for the postgres test.
WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the latest changes you moved the actual binding code to common. Please consider doing the same for the actual test cases.
| // Build single INSERT with multiple VALUES | ||
| query := fmt.Sprintf(`INSERT INTO %s (ephemeral_hash, long_term_id) VALUES `, db.table) | ||
|
|
||
| args := []interface{}{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| args := []interface{}{} | |
| var args := []any |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
platform/view/services/storage/driver/sql/common/binding.go:116:13: []any (type) is not an expression
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry - this was a sloppy suggestion. it should be var args []any.
Signed-off-by: [email protected] <[email protected]>
Signed-off-by: [email protected] <[email protected]>
Signed-off-by: [email protected] <[email protected]>
Signed-off-by: [email protected] <[email protected]>
Signed-off-by: [email protected] <[email protected]>
Signed-off-by: [email protected] <[email protected]>
Signed-off-by: [email protected] <[email protected]>
Signed-off-by: [email protected] <[email protected]>
| if len(ephemerals) > 1000 { | ||
| return errors.Errorf("Too many ephemerals (%d). Max allowed is 1000", len(ephemerals)) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update the go docs for this function to clearly describe that here is a limit.
| func TestWiring(t *testing.T) { | ||
| assert.NoError(t, sdk.DryRunWiring(NewFrom, sdk.WithBool("fabric.enabled", true))) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I did not mean to remove this test. I meant to just revert the changes to it. Let's keep it. It's a good test.
| // Input identities | ||
| longTerm := view.Identity("long") | ||
| e1 := view.Identity("eph1") | ||
| e2 := view.Identity("eph2") | ||
|
|
||
| // Check that store does not have bindings for e1 and e2 | ||
| lt, err := db.GetLongTerm(ctx, e1) | ||
| require.NoError(t, err) | ||
| require.ElementsMatch(t, len(lt), 0) | ||
| lt, err = db.GetLongTerm(ctx, e2) | ||
| require.NoError(t, err) | ||
| require.ElementsMatch(t, len(lt), 0) | ||
|
|
||
| // Create new bindings | ||
| err = db.PutBindings(ctx, longTerm, e1, e2) | ||
| require.NoError(t, err) | ||
|
|
||
| // Check that the bindings where correctly written | ||
| lt, err = db.GetLongTerm(ctx, e1) | ||
| require.NoError(t, err) | ||
| require.ElementsMatch(t, lt, longTerm) | ||
|
|
||
| lt, err = db.GetLongTerm(ctx, e2) | ||
| require.NoError(t, err) | ||
| require.ElementsMatch(t, lt, longTerm) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the latest changes you moved the actual binding code to common. Please consider doing the same for the actual test cases.
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func TestPutBindingsMultipleEphemeralsPostgres(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about adding one case to test our limit :)
The goal of this PR is to allow the binding of multiple identities at the same time so to same in the number of DB connections when binding multiple identities. This will be used in the token-sdk.
This PR is linked to FTS's PR hyperledger-labs/fabric-token-sdk#1245