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

test(bug): In TestDeleteByAddress, delete by address, check deletion of all keys with that address #2476

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jefft0
Copy link
Contributor

@jefft0 jefft0 commented Jul 1, 2024

This PR demonstrates a bug. In keybase_test, we add a new test TestDeleteByAddress which is similar to the existing TestKeyManagement. We use CreateAccount to add two accounts with the same mnemonic (same bech32 address) but two different names, "john" and "john2". Then we call Delete to delete by the bech32 address. Only one of the keys is deleted. The other 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:150
        	Error:      	Should be false
        	Test:       	TestDeleteByAddress

Discussion: Keybase writeInfo stores the same info under the key name and also the key address. This only allows an address to map to one name. When the key (with the same address) is created by the second name, the mapping from the address to the first name is replaced. Therefore, the call to delete by address only deletes the entry by the second name. The key is still accessible by the first name, meaning that "delete" doesn't really delete.

Possible solutions:

  • writeInfo should fail if there is already an entry for the address, or
  • writeInfo should map an address to a set of key names, or
  • don't "double index" by both name and address. (Only by name.)

Signed-off-by: Jeff Thompson <jeff@thefirst.org>
@jefft0 jefft0 requested review from jaekwon, moul and a team as code owners July 1, 2024 15:45
@github-actions github-actions bot added the 📦 🌐 tendermint v2 Issues or PRs tm2 related label Jul 1, 2024
Copy link

codecov bot commented Jul 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 54.70%. Comparing base (e282618) to head (416ea5d).
Report is 180 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2476   +/-   ##
=======================================
  Coverage   54.70%   54.70%           
=======================================
  Files         583      583           
  Lines       78504    78504           
=======================================
  Hits        42945    42945           
  Misses      32350    32350           
  Partials     3209     3209           
Flag Coverage Δ
contribs/gnodev 23.81% <ø> (ø)
contribs/gnofaucet 14.46% <ø> (ø)
contribs/gnokeykc 0.00% <ø> (ø)
contribs/gnomd 0.00% <ø> (ø)
gno.land 62.54% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jefft0 jefft0 added the 🐞 bug Something isn't working label Jul 1, 2024
@jefft0
Copy link
Contributor Author

jefft0 commented Jul 1, 2024

I added the "bug" label so that this PR gets attention as demonstrating a bug.

@jefft0 jefft0 changed the title chore: In keybase_test, add TestDeleteByAddress bug: In keybase_test, add TestDeleteByAddress Jul 3, 2024
@jefft0 jefft0 changed the title bug: In keybase_test, add TestDeleteByAddress bug: In TestDeleteByAddress, deleting by address should delete all keys with that address Jul 3, 2024
@jefft0 jefft0 changed the title bug: In TestDeleteByAddress, deleting by address should delete all keys with that address bug: In TestDeleteByAddress, delete by address, check deletion of all keys with that address Jul 3, 2024
@jefft0 jefft0 changed the title bug: In TestDeleteByAddress, delete by address, check deletion of all keys with that address test(bug): In TestDeleteByAddress, delete by address, check deletion of all keys with that address Jul 3, 2024
@Kouteki Kouteki added the review team PRs that should be reviewed first by the review team or external contributors label Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working 📦 🌐 tendermint v2 Issues or PRs tm2 related review team PRs that should be reviewed first by the review team or external contributors
Projects
Status: No status
Status: In Review
Development

Successfully merging this pull request may close these issues.

2 participants