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

Deleting an imported key deletes the old key #2446

Closed
jefft0 opened this issue Jun 26, 2024 · 1 comment
Closed

Deleting an imported key deletes the old key #2446

jefft0 opened this issue Jun 26, 2024 · 1 comment
Labels
🐞 bug Something isn't working

Comments

@jefft0
Copy link
Contributor

jefft0 commented Jun 26, 2024

Description

Describe your issue in as much detail as possible here

Your environment

  • OS and version: macOS Ventura
  • version of gno: Latest master branch
  • branch that causes this issue (with the commit hash): master 28c3b1a

Steps to reproduce

	// Delete the imported key
	err = cstore.Delete("john2", "secretcpw", false)
	require.NoError(t, err)
	// The original key should still exist
	has, err := cstore.HasByName("john")
	require.NoError(t, err)
	require.True(t, has)
  • In a terminal cd to gno/tm2/pkg/crypto/keys
  • Enter go test .

Expected behaviour

The test should pass. (The original exported key should still exist.)

Actual behaviour

The test fails because deleting the imported key by the new name deletes the key by the original name.

Logs

Output of go test .:

--- FAIL: TestExportImport (0.56s)
    keybase_test.go:246:
        	Error Trace:	/Users/jefft0/work/gno/gno/tm2/pkg/crypto/keys/keybase_test.go:246
        	Error:      	Should be true
        	Test:       	TestExportImport

Proposed solution

The Export function exports the Info struct which has the key name, in this case "john". Then Import imports the key with a new name, but does not change the Info struct. (Is this by design?) The Delete function fetches the Info struct from the database using the new name "john2", but it deletes based on the original name in the struct. This deletes the key under the original name.

Maybe Import needs to modify the Info struct with the new name before storing in the database.

@jefft0 jefft0 added the 🐞 bug Something isn't working label Jun 26, 2024
@jefft0 jefft0 changed the title Importing a key under a new name and deleting it deletes the old key name Importing a key under a new name and deleting it deletes the old name Jun 26, 2024
@jefft0 jefft0 changed the title Importing a key under a new name and deleting it deletes the old name Deleting an imported key deletes the old key Jun 27, 2024
@jefft0
Copy link
Contributor Author

jefft0 commented Jul 1, 2024

Closing in favor of a PR with code that demonstrates the bug. #2472

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working
Projects
Development

No branches or pull requests

1 participant