-
Notifications
You must be signed in to change notification settings - Fork 3
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: Make block-streamer
unit-testable and add tests
#442
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
morgsmccauley
changed the base branch from
main
to
420-expose-endpoint-to-control-streams
December 11, 2023 00:25
morgsmccauley
force-pushed
the
test/block-streamer
branch
2 times, most recently
from
December 11, 2023 02:55
21ebb38
to
c77a532
Compare
morgsmccauley
changed the title
test/block streamer
test: Make Dec 11, 2023
block-streamer
unit-testable and add tests
morgsmccauley
force-pushed
the
test/block-streamer
branch
from
December 11, 2023 07:40
3617ab0
to
a04e4f9
Compare
morgsmccauley
commented
Dec 11, 2023
block-streamer/Cargo.toml
Outdated
tokio-util = "0.7.10" | ||
tokio-stream = "0.1.14" | ||
tonic = "0.10.2" | ||
wildmatch = "2.1.1" | ||
|
||
near-lake-framework = "0.7.1" | ||
near-lake-framework = { git = "https://github.com/near/near-lake-framework-rs", branch="chore/upgrade-aws-0.7.x"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will pin to the specific version once near/near-lake-framework-rs#94 is merged
darunrs
approved these changes
Dec 13, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really cool stuff!
morgsmccauley
force-pushed
the
420-expose-endpoint-to-control-streams
branch
from
December 14, 2023 00:11
9322584
to
2d570f0
Compare
Base automatically changed from
420-expose-endpoint-to-control-streams
to
main
December 14, 2023 00:13
morgsmccauley
force-pushed
the
test/block-streamer
branch
from
December 14, 2023 00:19
0d49621
to
135c00d
Compare
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR is a combination of refactoring + testing, the former enabling the latter
Mock
impl
instead oftrait
Originally,
trait
s such asS3ClientTrait
were used to abstract the behaviour of I/O relatedstruct
s, allowing for the injection of mock implementations viaautomock
. This was fine, but lead to very verbose syntax which needed to be propagated throughout the codebase where ever it was used.Now, the
impl
itself is mocked, and either the mock or real implementation is returned dependant on thecfg(test)
flag. This means we no longer need to worry about generics and can instead use thestruct
itself, as we would with non-mocked code.The trade-off here is that rust now thinks the 'real' code is dead/unused as
test
is enabled by default.Mocking
near-lake-framework
aws
exposes an HTTP client which can be configured with mock request/response values.aws-sdk-s3
can be configured to use this client, creating a mock client. Injecting this config intonear-lake-framework
allows us to create deterministic outputs, enabling unit-testing.aws_config
is now taken as a parameter where relevant so that we can mocknear-lake-framework
in out tests. The functions for achieving this have been placed intest_utils
so they can be reused.Test
BlockStreamerService
andBlockStream
With
RedisClient
,S3Client
, andLake
now mockable - tests have been added for thesestruct
s. I've also added a Github action which runs on every PR. All raw block data has been added todata/
, which makes up the majority of the diff in this PR.