You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// 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.
The text was updated successfully, but these errors were encountered:
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
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
Description
Describe your issue in as much detail as possible here
Your environment
Steps to reproduce
TestExportImport
add these lines: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 .
:Proposed solution
The
Export
function exports theInfo
struct which has the key name, in this case "john". ThenImport
imports the key with a new name, but does not change theInfo
struct. (Is this by design?) TheDelete
function fetches theInfo
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 theInfo
struct with the new name before storing in the database.The text was updated successfully, but these errors were encountered: