feat(tokens): achieve 80%+ unit test coverage for tokens service#1499
Open
Rozerxshashank wants to merge 2 commits intohyperledger-labs:mainfrom
Open
feat(tokens): achieve 80%+ unit test coverage for tokens service#1499Rozerxshashank wants to merge 2 commits intohyperledger-labs:mainfrom
Rozerxshashank wants to merge 2 commits intohyperledger-labs:mainfrom
Conversation
a42c070 to
6e5fd7f
Compare
Contributor
Author
|
Hi @adecaro , This PR is to the Fabric Token SDK! I’ve been working on increasing the unit test coverage for the token/services/tokens package, and I’ve successfully brought it from roughly 30% up to 81.1% . |
2470faa to
e3220e6
Compare
Contributor
|
Hi @Rozerxshashank , great effort. I'll review ASAP. Thanks a lot 🙏 |
Contributor
|
Hi @Rozerxshashank , please, use counterfeiter for the mocks. We use it almost everywhere. Thanks 🙏 |
ff9b8ce to
28fdcec
Compare
Signed-off-by: Shashank <yshashank959@gmail.com>
Signed-off-by: Shashank <yshashank959@gmail.com>
28fdcec to
136ae89
Compare
This file contains hidden or 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
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.
Fixes: #1487
I’ve spent some time digging into the
token/services/tokenspackage and managed to push our unit test coverage from a pretty low 30% all the way up to 81.1%.The main goal here wasn't just to bump up the numbers, but to make sure the core services are actually reliable. Here’s a breakdown of what I worked on:
mocks_test.gofor the Vault, QueryEngine, TMS, and Network. I also added a couple of helpers (buildTestTMS,buildTestNetwork) that make it way easier to spin up isolated tests without a ton of boilerplate.PruneInvalidUnspentTokensandCacheRequest. This includes covering those tricky parsing paths like Auditor flags and Graph Hiding that were previously untested.DBStorageto make sure we’re correctly handling the full transaction lifecycle: specifically things like Commits, Rollbacks, and how we notify other components.Verification Results
token/services/tokensare passing (go test -v).