gno
gno copied to clipboard
test(bug): In TestExportImport, delete imported key, check if original exists
This PR demonstrates a bug. TestExportImport
creates a key named "john", uses Export
to export it, then uses Import
to import it into the same Keybase with the new name "john2". It checks if the address of the imported key is the same as the original key.
This PR expands TestExportImport
to delete the imported "john2" then uses HasByName("john")
to check if the original key still exists.
To run the test:
cd gno/tm2/pkg/crypto/keys
go test .
Expected: pass. Actual: The test fails with:
Error Trace: /Users/jefft0/work/gno/gno/tm2/pkg/crypto/keys/keybase_test.go:246
Error: Should be true
Test: TestExportImport
Discussion: 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.