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

[ETCM-126] split JsonRpcControllerSpec #734

Merged
merged 10 commits into from
Oct 15, 2020
Merged

Conversation

lemastero
Copy link
Contributor

@lemastero lemastero commented Oct 13, 2020

Description

JsonRpcControllerSpec file contained around 2000 lines of code. This is hard to maintain. Context for this PR: #726 (comment)

Proposed Solution

Split it into tests related to:

  • JsonRpcControllerPersonalSpec personal_XYZ
  • JsonRpcControllerEthTransactionSpec related to eth transaction requests
  • JsonRpcControllerEthSpec other eth requests
  • JsonRpcControllerSpec other requests

Before split there were utility function extracted that simplify creating requests and creating JsonRpcService: newJsonRpcController, newJsonRpcRequest in 53283b7

Important Changes Introduced

Testing

Copy link
Contributor

@mmrozek mmrozek left a comment

Choose a reason for hiding this comment

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

Nice job. One doubt only

val version = Config.clientVersion
val blockGenerator = mock[EthashBlockGenerator]

override implicit lazy val system = ActorSystem("JsonRpcControllerSpec_System")
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to create ActorSystem for each test?

Copy link
Contributor

Choose a reason for hiding this comment

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

This.
I'd say it's preferrable to use akka's TestKit on suite level and use there WithActorSystemShutdown trait.
Benefits are as follows:

  1. Creating and shutting down systems is quite expensive operation.
  2. Actors of any kind are created per spec anyways so lack of isolation is not an issue I think
  3. In other project we had real problems with tests due to leaking running actor systems

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How about merging this PR and fix the unnecessary spawning actor system in a separate one.

There is a pretty complex wiring using cake pattern (actor system that comes from ActorSystemBuilder (via StdTestConsensusBuilder via ScenarioSetup via EphemBlockchainTestSetup and ActorSystemBilder is required in StdLedgerBuilder via self type). I need some time to figure out how to do this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good to me. And such task/PR could be extended to making sure actor system is properly closed in all tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

PR for this change: #751

Copy link
Contributor

@kapke kapke left a comment

Choose a reason for hiding this comment

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

Overall looks good to me!

@lemastero lemastero merged commit 294d814 into develop Oct 15, 2020
@lemastero lemastero deleted the ETCM-126-split-json-rpc-spec branch October 16, 2020 19:07
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.

3 participants