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(core): e2e test cases core maciState/Poll #910

Merged
merged 2 commits into from
Jan 11, 2024
Merged

test(core): e2e test cases core maciState/Poll #910

merged 2 commits into from
Jan 11, 2024

Conversation

baumstern
Copy link
Member

@baumstern baumstern commented Dec 12, 2023

This PR adds end-to-end test cases of the off-chain state machine, focusing on sanity checks.

Related to #792

@baumstern baumstern added this to the MACI v1.1.1 refactor milestone Dec 12, 2023
@baumstern baumstern requested a review from ctrlc03 December 12, 2023 15:20
@baumstern baumstern self-assigned this Dec 12, 2023
Copy link

netlify bot commented Dec 12, 2023

Deploy Preview for maci-typedoc ready!

Name Link
🔨 Latest commit f8d4ccb
🔍 Latest deploy log https://app.netlify.com/sites/maci-typedoc/deploys/65a02b95c462cd00086a2cc8
😎 Deploy Preview https://deploy-preview-910--maci-typedoc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@baumstern baumstern mentioned this pull request Dec 12, 2023
8 tasks
@baumstern baumstern force-pushed the coretest branch 3 times, most recently from 3c0891c to 907ae03 Compare December 12, 2023 15:29
@baumstern baumstern changed the title test(core): add test cases for processMessage() test(core): add e2e cases for sanity checks Dec 12, 2023
Copy link
Collaborator

@ctrlc03 ctrlc03 left a comment

Choose a reason for hiding this comment

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

Thanks for this, it can be very useful to ensure MACI works correctly, though I have some thoughts:

Currently these are gearing towards being e2e tests for the MaciState/Poll classes, which is definitely useful, though I wonder if it would be best to focus on unit testing MaciState/Poll as we already have e2e/integration tests that touch on MACI from 0 to end (though what we have now as e2e and integration tests are not the best, and in general they do not "test" much as failures could be for a variety of reasons - we have an issue open to track this #869).

If you strongly feel to keep these as it is, then I would ask you to please rename everything appropriately, e.g. move to a e2e folder inside core tests, rename to not be processMessages specific (as you are relying on tally votes too).

Otherwise, we now have an open PR which refactors the processMessage related functions, making processMessage public and parameterised with custom errors. This way it is now much easier to do unit testing and actually test that the different results are because of the different conditions (which is what is missing in this PR as well as our e2e/integration tests suite and that we need to fix). - Also the TestHarness class can possibly be adapted to work on our integration tests


const messageBatchSize = 25;

class TestHarness {
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is nice and can be very useful, but please document it and move it to an util file!

Copy link
Member Author

Choose a reason for hiding this comment

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

This is specifically designed for testing purposes and does not require exporting

Copy link
Member Author

Choose a reason for hiding this comment

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

Besides this point, we can consider designing a high-level module similar to this, something like:

class MACIHighLevel {
  init();
  vote();
  tally();
}

However, this is beyond the scope of the current PR

Copy link
Collaborator

Choose a reason for hiding this comment

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

The TestHarness class is still without any comments/documentation

Copy link
Collaborator

@ctrlc03 ctrlc03 Dec 14, 2023

Choose a reason for hiding this comment

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

so we can't re-use it for other tests? 😔

Copy link
Member Author

Choose a reason for hiding this comment

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

actually, TestHarness has been liberated for the good of all tests in 687bc92

Copy link
Collaborator

Choose a reason for hiding this comment

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

🙏 thanks for that and for documenting it

core/ts/__tests__/ProcessMessage.test.ts Outdated Show resolved Hide resolved
core/ts/__tests__/ProcessMessage.test.ts Outdated Show resolved Hide resolved
core/ts/__tests__/ProcessMessage.test.ts Outdated Show resolved Hide resolved
core/ts/__tests__/ProcessMessage.test.ts Outdated Show resolved Hide resolved
core/ts/__tests__/ProcessMessage.test.ts Outdated Show resolved Hide resolved
core/ts/__tests__/ProcessMessage.test.ts Outdated Show resolved Hide resolved
@baumstern
Copy link
Member Author

baumstern commented Dec 14, 2023

Thanks for this, it can be very useful to ensure MACI works correctly, though I have some thoughts:

Currently these are gearing towards being e2e tests for the MaciState/Poll classes, which is definitely useful, though I wonder if it would be best to focus on unit testing MaciState/Poll as we already have e2e/integration tests that touch on MACI from 0 to end (though what we have now as e2e and integration tests are not the best, and in general they do not "test" much as failures could be for a variety of reasons - we have an issue open to track this #869).

If you strongly feel to keep these as it is, then I would ask you to please rename everything appropriately, e.g. move to a e2e folder inside core tests, rename to not be processMessages specific (as you are relying on tally votes too).

Otherwise, we now have an open PR which refactors the processMessage related functions, making processMessage public and parameterised with custom errors. This way it is now much easier to do unit testing and actually test that the different results are because of the different conditions (which is what is missing in this PR as well as our e2e/integration tests suite and that we need to fix). - Also the TestHarness class can possibly be adapted to work on our integration tests

These are e2e tests at the maci-core package level. They don't cover inter-package level e2e testing, which would involve both onchain and zk components. The main objective here is to ensure the integrity of the maci-core package's module, with a specific focus on the behavior of processMessages(). This is something our other end-to-end/integration tests don't cover and is outside their scope.

As a side note, these tests are black-box in nature, which is why they rely on the results of tallyVote()

@baumstern
Copy link
Member Author

Thanks for the feedback @ctrlc03 , I've changed file name and modified it to check for a specific throw condition. Please have another look

@baumstern baumstern requested a review from ctrlc03 December 14, 2023 02:39
@baumstern baumstern requested review from ctrlc03 and removed request for ctrlc03 December 18, 2023 00:31
@ctrlc03 ctrlc03 force-pushed the coretest branch 2 times, most recently from dfc3b8b to 04759de Compare December 30, 2023 19:14
@baumstern
Copy link
Member Author

Hey @ctrlc03, I need write access to push some updates. I've fixed the ESLint errors on the branch

@ctrlc03
Copy link
Collaborator

ctrlc03 commented Jan 9, 2024

Hey @ctrlc03, I need write access to push some updates. I've fixed the ESLint errors on the branch

Sorry for taking this long to get back to you! Would you be happy for us to complete this: we would fix conflicts and push a commit to fix eslint errors. Otherwise you could open a PR from a fork? up to you and how you prefer to get this done 🙂

@baumstern
Copy link
Member Author

baumstern commented Jan 9, 2024

Hey @ctrlc03, I need write access to push some updates. I've fixed the ESLint errors on the branch

Sorry for taking this long to get back to you! Would you be happy for us to complete this: we would fix conflicts and push a commit to fix eslint errors. Otherwise you could open a PR from a fork? up to you and how you prefer to get this done 🙂

Check out the latest fixes here, and you can go from there. I would like to avoid opening redundant PR and keep things tidy

@ctrlc03
Copy link
Collaborator

ctrlc03 commented Jan 9, 2024

Hey @ctrlc03, I need write access to push some updates. I've fixed the ESLint errors on the branch

Sorry for taking this long to get back to you! Would you be happy for us to complete this: we would fix conflicts and push a commit to fix eslint errors. Otherwise you could open a PR from a fork? up to you and how you prefer to get this done 🙂

Check out the latest fixes here, and you can go from there. I would like to avoid opening redundant PR and keep things tidy

Updated, thanks for your contribution :) lmk if it looks good to you
Docs explaining different test suites in core: https://maci.pse.dev/docs/testing-in-details

@ctrlc03 ctrlc03 linked an issue Jan 9, 2024 that may be closed by this pull request
8 tasks
@ctrlc03 ctrlc03 force-pushed the coretest branch 2 times, most recently from f46b9e3 to 87d9076 Compare January 10, 2024 11:03
@ctrlc03 ctrlc03 changed the title test(core): add e2e cases for sanity checks test(core): e2e test cases maciState/Poll Jan 10, 2024
@ctrlc03 ctrlc03 changed the title test(core): e2e test cases maciState/Poll test(core): e2e test cases core maciState/Poll Jan 10, 2024
core/ts/__tests__/utils.ts Outdated Show resolved Hide resolved
@baumstern
Copy link
Member Author

Hey @ctrlc03, I need write access to push some updates. I've fixed the ESLint errors on the branch

Sorry for taking this long to get back to you! Would you be happy for us to complete this: we would fix conflicts and push a commit to fix eslint errors. Otherwise you could open a PR from a fork? up to you and how you prefer to get this done 🙂

Check out the latest fixes here, and you can go from there. I would like to avoid opening redundant PR and keep things tidy

Updated, thanks for your contribution :) lmk if it looks good to you Docs explaining different test suites in core: https://maci.pse.dev/docs/testing-in-details

thanks, the change looks good overall. just left one small comment

@ctrlc03 ctrlc03 force-pushed the coretest branch 4 times, most recently from 4f21e6d to 43629a5 Compare January 11, 2024 17:52
@ctrlc03 ctrlc03 merged commit d6a748f into dev Jan 11, 2024
14 checks passed
@ctrlc03 ctrlc03 deleted the coretest branch January 11, 2024 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Core package refactoring
2 participants