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: fix broadcast randomly failing test #1735

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

Conversation

vatanasov
Copy link
Contributor

No description provided.

@vatanasov vatanasov self-assigned this Apr 22, 2024
Base automatically changed from chore-use-node-version-6.13 to master April 23, 2024 11:14
@yaboiishere yaboiishere force-pushed the fix-broadcast-randomly-failing-test branch from aac282d to ffa088d Compare April 23, 2024 11:26
@sborrazas
Copy link
Contributor

Can there be an explanation of why the tests fail using the registered global name? I would try to avoid making the source code more complex simply for tests to pass

@yaboiishere
Copy link
Contributor

I believe the problem was that the mocking library was having problems unloading the mocks on shared processes and if two tests mock their functionality, sometimes the wrong mocks are used and the tests fail

@sborrazas
Copy link
Contributor

Tests should run synchronously for correct mocking and unmocking of the modules, if this is not the case we should figure out a different way to test this module/server (which is working correctly) without having to change it. If it's not possible let's get rid of these tests

@vatanasov
Copy link
Contributor Author

There were different problems that occurred. The problem with the mocking was, that for some runs, where were no mock_blocks[:mb], so find_tx_location was not working correctly (I have no idea why there were runs where there were - the tests themselves does not have that key. My suspicion is that maybe something running in another process is sometimes running another version of the mocked function, that has an :mb key).

As for the registered global name - the problem is, that the Broadcaster using the registered global name is internally using State.mem_state, which is global and is changed in some of the other tests. The point to have it using a name is so that a broadcaster has his own internal state instead of always using the global one (and in prod - using the global one). I think that making the name and the state that the genservers are using configurable will make them much more easy to test (and more flexible to modify, in case we need more than one of them), without interfering with other tests, and only using tools already in the language.

I get that changing such an integral part of the code, such as the Broadcaster is worrying, so if you are wary, we could just leave the test commented for now (but I would still suggest that we try to make future genservers more flexible with regards to global states).

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.

None yet

3 participants