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

feat: rollback publish changes #431

Merged
merged 4 commits into from
Mar 16, 2022
Merged

Conversation

nicosantangelo
Copy link
Contributor

Closes #422

Comment on lines 243 to 255
SlotUsageCheque.delete({ created_at: now }),
ItemCuration.delete({ created_at: now }),
Copy link
Contributor

Choose a reason for hiding this comment

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

There are three issues that I see here:

  • Although it could be rare, there's no guarantee that there will be only one publication in the same millisecond, as there are operations that could be done in nanoseconds, hitting the same millisecond, possibly deleting things that weren't supposed to be deleted.
  • Item curations can be created at any time. Following the same idea as the other point, we could be deleting an item curation that was created in the same millisecond period.
  • Having a new instance of the builder will increase the possibility of hitting the same millisecond.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought of all of those (except the last one regretfully) and was expecting some feedback lol. The thing is that deleting itemCurations is a bit of a pain, but I'll try saving the ids and using them here. It'll make the code more complex but I don't see any way around it. Let me know if you do!

@coveralls
Copy link

coveralls commented Mar 15, 2022

Pull Request Test Coverage Report for Build 1988953138

  • 18 of 19 (94.74%) changed or added relevant lines in 2 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.04%) to 67.969%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/Curation/ItemCuration/ItemCuration.model.ts 0 1 0.0%
Files with Coverage Reduction New Missed Lines %
src/Curation/ItemCuration/ItemCuration.model.ts 1 36.84%
Totals Coverage Status
Change from base Build 1987687748: 0.04%
Covered Lines: 2279
Relevant Lines: 3205

💛 - Coveralls

)
jest.spyOn(ethers.utils, 'verifyMessage').mockReturnValue('0x')

jest.spyOn(SlotUsageCheque, 'create').mockResolvedValueOnce({})
Copy link
Contributor

Choose a reason for hiding this comment

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

Would you mind adding here an id so we can later assert that the delete procedure was called with this id?

Copy link
Contributor

Choose a reason for hiding this comment

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

The same goes for the delete method of the SlotUsageCheque.

Comment on lines 1378 to 1380
let itemCurationDeleteSpy: jest.SpyInstance<
ReturnType<typeof ItemCuration.delete>
>
Copy link
Contributor

Choose a reason for hiding this comment

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

With the change, instead of ItemCuration.delete, ItemCuration.deleteByIds is being used.

@nicosantangelo nicosantangelo merged commit 8882e2e into master Mar 16, 2022
@nicosantangelo nicosantangelo deleted the feat/publish-rollback branch March 16, 2022 19:56
@nicosantangelo nicosantangelo restored the feat/publish-rollback branch March 16, 2022 23:02
@nicosantangelo nicosantangelo deleted the feat/publish-rollback branch March 16, 2022 23:05
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.

Add a rollback mechanism to TP publishes
3 participants