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

Add 'include_leased' flag to ListBalances #1119

Merged
merged 8 commits into from
Sep 23, 2024
Merged

Conversation

gijswijs
Copy link
Contributor

@gijswijs gijswijs commented Sep 10, 2024

This PR adds include_leased flag to ListBalances rpc endpoint.
With this flag you show balances that include the leased assets, which are otherwise ignored. In doing so the behavior is now synced with the ListAssets endpoint.

Fixes #1106 task 2 (2nd checkbox, and probably also 1st checkbox)

Fixes #1106

@coveralls
Copy link

coveralls commented Sep 10, 2024

Pull Request Test Coverage Report for Build 10973284227

Details

  • 37 of 70 (52.86%) changed or added relevant lines in 5 files are covered.
  • 14 unchanged lines in 5 files lost coverage.
  • Overall coverage increased (+0.03%) to 40.388%

Changes Missing Coverage Covered Lines Changed/Added Lines %
tapdb/assets_store.go 33 35 94.29%
cmd/tapcli/assets.go 0 3 0.0%
rpcserver.go 0 12 0.0%
itest/assertions.go 0 16 0.0%
Files with Coverage Reduction New Missed Lines %
itest/assertions.go 2 0.0%
tappsbt/create.go 2 53.22%
asset/asset.go 2 81.61%
universe/interface.go 4 50.22%
tapgarden/caretaker.go 4 68.87%
Totals Coverage Status
Change from base Build 10958136063: 0.03%
Covered Lines: 24242
Relevant Lines: 60023

💛 - Coveralls

Copy link
Member

@guggero guggero left a comment

Choose a reason for hiding this comment

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

Nice commit structure! Looks pretty good with a couple of minor things that need to be changed though.

taprpc/taprootassets.proto Outdated Show resolved Hide resolved
cmd/tapcli/assets.go Outdated Show resolved Hide resolved
tapdb/sqlc/queries/assets.sql Outdated Show resolved Hide resolved
rpcserver.go Outdated Show resolved Hide resolved
rpcserver.go Outdated Show resolved Hide resolved
tapdb/assets_store.go Show resolved Hide resolved
tapdb/assets_store.go Outdated Show resolved Hide resolved
itest/assertions.go Show resolved Hide resolved
Copy link
Member

@guggero guggero left a comment

Choose a reason for hiding this comment

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

Very nice! Looks great, just one more question about the query (and a couple of additional nits, sorry 😅 ).

tapdb/sqlc/queries/assets.sql Outdated Show resolved Hide resolved
tapdb/assets_store.go Show resolved Hide resolved
tapdb/assets_store.go Show resolved Hide resolved
tapdb/assets_store_test.go Show resolved Hide resolved
tapdb/assets_store_test.go Show resolved Hide resolved
tapdb/assets_store_test.go Show resolved Hide resolved
tapdb/assets_store_test.go Show resolved Hide resolved
Copy link
Member

@guggero guggero left a comment

Choose a reason for hiding this comment

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

LGTM, pending a rebase/squash and some more nits 🎉

tapdb/asset_minting.go Outdated Show resolved Hide resolved
tapdb/asset_minting_test.go Show resolved Hide resolved
tapdb/asset_minting_test.go Outdated Show resolved Hide resolved
tapdb/asset_minting_test.go Show resolved Hide resolved
tapdb/asset_minting_test.go Outdated Show resolved Hide resolved
tapdb/asset_minting_test.go Show resolved Hide resolved
tapdb/asset_minting_test.go Show resolved Hide resolved
This commit adds 'include_leased' flag to `ListBalances` rpc endpoint.
With this flag you show balances that include the leased assets, which
are otherwise ignored.
Since we now have the same flags for the `ListAssets` and `ListBalances`
calls, we add a check that makes sure the sum of all assets returned by
`ListAssets` matches the sum returned in `ListBalances`.
With this commit, we add a unit test for the `QueryBalancesByAsset` and
`QueryAssetBalancesByGroup` funcs. The test checks that those balance
queries return the expected results with all sorts of grouped and leased
assets combined, and with the `includeLeased` flag on and off.
Copy link
Member

@GeorgeTsagk GeorgeTsagk left a comment

Choose a reason for hiding this comment

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

Lgtm!
very nice commit structure and thorough unit test 💯

@@ -1913,7 +1913,9 @@ func AssertAssetBalances(t *testing.T, client taprpc.TaprootAssetsClient,

require.Equal(t, len(allAssets), len(assetIDBalances.AssetBalances))

var totalBalance uint64
Copy link
Member

Choose a reason for hiding this comment

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

nit: shouldn't this commit precede the previous itest: test balances with an without leased flag

@Roasbeef Roasbeef merged commit 3b92c82 into main Sep 23, 2024
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

[feature]: Enhance asset_sum report to clarify conservation
6 participants