Skip to content
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

core/services/keystore: switch to sqlutil.DataStore #12810

Merged
merged 1 commit into from
Apr 19, 2024

Conversation

Copy link
Contributor

I see you updated files related to core. Please run pnpm changeset in the root directory to add a changeset as well as in the text include at least one of the following tags:

#nops : For any feature that is NOP facing and needs to be in the official Release Notes for the release.
#added : For any new functionality added.
#changed : For any change to the existing functionality. 
#removed : For any functionality/config that is removed.
#updated : For any functionality that is updated.
#deprecation_notice : For any upcoming deprecation functionality.
#breaking_change : For any functionality that requires manual action for the node to boot.
#db_update : For any feature that introduces updates to database schema.
#wip : For any change that is not ready yet and external communication about it should be held off till it is feature complete.
#bugfix - For bug fixes.
#internal - For changesets that need to be excluded from the final changelog.

@jmank88
Copy link
Contributor Author

jmank88 commented Apr 17, 2024

The integration tests are failing on ensure X key.

ks := keyStore.Cosmos()
reset := func() {
ctx := context.Background() // Executed during cleanup
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it benefit to be testutils.Context(t)? I'm not 100% on my understanding of how go test cleanup operates, but i've had some friction with debugging tests that hang/fail in cleanup vs in the test execution.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it can't be a normal ctx since we execute it during t.Cleanup, when the context may already be done.

if err := q.Get(state, sql, address, chainID.String()); err != nil {
return errors.Wrap(err, "failed to insert evm_key_state")
if err := ds.GetContext(ctx, state, sql, address, chainID.String()); err != nil {
return errors.Wrap(err, "failed to insert key_state")
}
// consider: do we really need a cache of the keystates?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think we don't 😛

@@ -27,18 +29,20 @@ import (
func Test_EthKeyStore(t *testing.T) {
t.Parallel()

db := pgtest.NewSqlxDB(t)
cfg := configtest.NewTestGeneralConfig(t)
db := sqlutil.WrapDataSource(pgtest.NewSqlxDB(t), logger.Test(t), sqlutil.TimeoutHook(func() time.Duration {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why wrap pgtest.NewSqlxDb(t)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just mimicking production. This is where I debugged the issue.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's worth a code comment because it's not obvious.

or should the test db impl be changed to return the wrapper?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, in the final PR #12456 I updated cltest at least to use a timeout wrapper. We could consider updating the test funcs to return a wrapped DataSource instead of raw sqlx most places 🤷

@@ -477,7 +480,6 @@ targets:
func TestJobsController_Create_WebhookSpec(t *testing.T) {
app := cltest.NewApplicationEVMDisabled(t)
require.NoError(t, app.Start(testutils.Context(t)))
t.Cleanup(func() { assert.NoError(t, app.Stop()) })
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice - i've seen similar cleanup needed in helpers in mercury and llo. Maybe worth creating a ticket to audit (good for a new joiner?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants