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

Feature/better event assertions #83

Merged
merged 6 commits into from
Oct 28, 2022

Conversation

neodaoist
Copy link
Contributor

Resolves #74

  • One production code change — Include claimId as a topic on OptionsWritten event (it's indexed on other events too, so thought this makes sense)
  • Fix broken first topic assertion on event test for creating new option type
  • Fix claim ID assertion on event emission when writing both new and existing claims
  • Add event test for fees swept during exercise

The snapshot diff is way nastier than my changes, think it includes some other recent changes, just heads up. Indexing claimId on the event should only cost 110 gas more on write() calls.

emit FeeAccrued(WETH_A, ALICE, expectedFeeAccruedAmount);

vm.expectEmit(true, true, true, true);
emit OptionsWritten(testOptionId, ALICE, claimId, 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

@0xAlcibiades @neodaoist what do we think makes the most sense here to emit. Currently the index of the claim is emitted (1, 2 ,3 ,4). Do we want to emit the entire claim ID instead with the encoded option ID in the top 160b?

Copy link
Contributor

Choose a reason for hiding this comment

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

(Not related to changes in this PR btw)

Copy link
Contributor Author

@neodaoist neodaoist Oct 28, 2022

Choose a reason for hiding this comment

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

Honestly I would love to talk through how dapp devs or end users might want to view and monitor this event. Need more context to have an opinion yet

@@ -543,11 +570,16 @@ contract OptionSettlementTest is Test, NFTreceiver {
uint96(expectedUnderlyingAmount)
);

engine.claim(claimId);
// engine.claim(claimId);
Copy link
Contributor

Choose a reason for hiding this comment

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

Was the test passing before this? Should we add or update an assert here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah woops, I meant to remove this altogether. There's no need to call the view function, the test exercises the events emitted from redeem().

@0xAlcibiades
Copy link
Member

0xAlcibiades commented Oct 27, 2022 via email

@0xAlcibiades 0xAlcibiades merged commit a5d5159 into master Oct 28, 2022
@0xAlcibiades 0xAlcibiades deleted the feature/better-event-assertions branch October 28, 2022 16:28
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.

assertions for claim and optionIds
3 participants