Added RepositoryFactory #386
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi @rg911
This PRs adds the RepositoryFactory and utilizes the interfaces a bit more than the concrete classes working better with abstractions.
Code improvements:
These are the improvements added to the code base. They are not breaking changes for the user (the only exception is
TransactionService
constructor, see below).RepositoryFactory
that creates repositories. The basic implementation is theRepositoryFactoryHttp
that creates the Http clients. The user should create one RepositoryFactory per application/network and reuse that object in the different components when repository/http objects are required.NetworkType
and Generation Hash. It also allows users to provide their own Network Type (as requested in AddnetworkType
to http clients constructors #361). Network type and generation hash are only loaded once for the lifetime of the factory reducing I/O and the chances of being banned.TransactionService
constructor, it was creating the HTTP objects itself missing some arguments like the network type required in 361.IListener
interface (I prefer them to beListener
interface andListenerHttp
but I didn't want to rename the currentListener
class)Test improvements:
This PR also includes fairly big e2e improvements.
IntegrationTestHelper
is a helper object that allows e2e tests to be configured and executed. It contains some helper functions that reduce the size of a test.catapult-service-bootstrap
You don't need to update your configuration every time you resetIntegrationTestHelper
holds the e2e test file's listener. This reduces the size of a test and it's a good test for scalability. In some scenarios, it would be great to have one listener running for longer that one operation (maybe for the whole life of the application). You can still create extra listeners if you like per test.CreateTransactionFromDTO.spec.ts
from e2e to testsAll HTTP and Service e2e tests have been migrated to
IntegrationTestHelper
. Overall, the size of a e2e tests have been reducing by 30-40 % without losing configurability (you can still create the transaction the way you want it) and adding all the features listed above.I think this PR is ready to be reviewed, fixed if necessary and approved.