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

Empty strings in DIDSet transaction #717

Merged
merged 17 commits into from
Jul 3, 2024
Merged

Conversation

ckeshava
Copy link
Collaborator

High Level Overview of Change

Fix #716

Context of Change

Fields within a DID object can only be deleted by setting an empty string. However, the regex in the DIDSet model do not account for empty strings.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (non-breaking change that only restructures code)
  • Tests (You added tests for code that already exists, or your new feature included in this PR)
  • Documentation Updates
  • Release

Did you update CHANGELOG.md?

  • Yes
  • No, this change does not impact library users

Test Plan

Unit tests have been added to this effect

@ckeshava ckeshava requested review from mvadari and khancode June 17, 2024 23:36
CHANGELOG.md Show resolved Hide resolved
@ckeshava ckeshava requested a review from mvadari June 25, 2024 17:54
@ckeshava ckeshava requested a review from mvadari June 25, 2024 18:52
Copy link
Collaborator

@khancode khancode left a comment

Choose a reason for hiding this comment

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

Add integration test for submitting DIDSet with empty string.

with self.assertRaises(XRPLModelException):
DIDSet(account=_ACCOUNT, data="", did_document="", uri="")

def test_remove_multiple_fields(self):
Copy link
Collaborator

Choose a reason for hiding this comment

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

IMO each transaction should be a separate test. Easier to run.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'd like to remove consecutive fields in the DID object, in order to demonstrate that users cannot leave behind an empty DID object.

I need to perform consecutive removals on the same object, it cannot be demonstrated with a new DID ledger object

Copy link
Collaborator

Choose a reason for hiding this comment

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

That's not a library test, that's a rippled test. And even if it were a library test, it should happen in an integration test, because it won't happen in a unit test (the unit test doesn't submit transactions and therefore doesn't create/modify/delete ledger objects). All you're doing here is creating the models, not submitting anything.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

okay, I've created an integration test for the same

…o test in unit tests

format the docs for DIDSet model data fields
@ckeshava
Copy link
Collaborator Author

I have reverted back to an older commit. I removed the integration test and restored the unit test. Let me know if this looks ok

@ckeshava ckeshava requested review from mvadari and khancode June 25, 2024 23:27
self.assertTrue(tx.is_valid())

# remove the data field from the above DID object
tx = DIDSet(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you still want a transaction for each field?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm only removing the data field. I'm not using any other transaction

Copy link
Collaborator

Choose a reason for hiding this comment

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

You originally also removed the other fields.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes, that's correct. but now, I'm only empty-ing the data field

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, should there be tests for emptying each field?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

can you tell me the name of the unit test that you are objecting to?

test_empty_data_field -- a unit test that empties only the data field. all the other fields contain valid values.

test_create_did_object_all_empty_fields -- a unit test that validates the initial input for the DIDSet transaction. This verifies that all the input fields are not empty.

You are correct that rippled has already tested this functionality. Which one of these warrants a change?

@ckeshava ckeshava requested review from khancode and mvadari June 26, 2024 20:56
@justinr1234 justinr1234 merged commit b0c2b76 into XRPLF:main Jul 3, 2024
21 checks passed
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.

Delete data, URI, DIDDocument fields in DID object
4 participants