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

itest: add test for consistent balance reporting #871

Merged
merged 3 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions docs/release-notes/release-notes-0.13.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

### Lightning Terminal

- [Fixed a bug where REST calls for the `WalletUnlocker` service weren't allowed
* [Fixed a bug where REST calls for the `WalletUnlocker` service weren't allowed
on startup](https://github.com/lightninglabs/lightning-terminal/pull/806).
- [Added build flag 'litd_no_ui' for building litd without the ui, accessible
* [Added build flag 'litd_no_ui' for building litd without the ui, accessible
with 'make go-build-noui' and 'make go-install-noui'](https://github.com/lightninglabs/lightning-terminal/pull/500).

### LND
Expand All @@ -19,8 +19,14 @@ with 'make go-build-noui' and 'make go-install-noui'](https://github.com/lightni

### Taproot Assets

* [Inconsistent balance
reporting](https://github.com/lightninglabs/lightning-terminal/pull/871) has
been fixed: on-channel balances are now exclusively reported through channel
balances and will not show up in asset balances reported by tapd.

# Autopilot

# Contributors (Alphabetical Order)

* Oliver Gugger
* Gijs van Dam
* Oliver Gugger
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ require (
github.com/lightninglabs/loop/swapserverrpc v1.0.8
github.com/lightninglabs/pool v0.6.5-beta.0.20240604070222-e121aadb3289
github.com/lightninglabs/pool/auctioneerrpc v1.1.2
github.com/lightninglabs/taproot-assets v0.4.2-0.20240923062224-3b92c82bb332
github.com/lightninglabs/taproot-assets v0.4.2-0.20241018073747-bacd6589ee90
github.com/lightningnetwork/lnd v0.18.0-beta.rc4.0.20240919091721-70580403898e
github.com/lightningnetwork/lnd/cert v1.2.2
github.com/lightningnetwork/lnd/fn v1.1.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1175,8 +1175,8 @@ github.com/lightninglabs/pool/auctioneerrpc v1.1.2 h1:Dbg+9Z9jXnhimR27EN37foc4aB
github.com/lightninglabs/pool/auctioneerrpc v1.1.2/go.mod h1:1wKDzN2zEP8srOi0B9iySlEsPdoPhw6oo3Vbm1v4Mhw=
github.com/lightninglabs/protobuf-go-hex-display v1.30.0-hex-display h1:pRdza2wleRN1L2fJXd6ZoQ9ZegVFTAb2bOQfruJPKcY=
github.com/lightninglabs/protobuf-go-hex-display v1.30.0-hex-display/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
github.com/lightninglabs/taproot-assets v0.4.2-0.20240923062224-3b92c82bb332 h1:AVh0Ks5erEqC3RDY6gsycbf9dcYXv308j/kxi47WPyM=
github.com/lightninglabs/taproot-assets v0.4.2-0.20240923062224-3b92c82bb332/go.mod h1:B6wbs1rSTBTJwTilsKt7p/WravtKqRvJI0ICDwvcdNQ=
github.com/lightninglabs/taproot-assets v0.4.2-0.20241018073747-bacd6589ee90 h1:67sqOcoog67BcKzRuNMPhkPfG50vBLYQ617tUahoPWE=
github.com/lightninglabs/taproot-assets v0.4.2-0.20241018073747-bacd6589ee90/go.mod h1:B6wbs1rSTBTJwTilsKt7p/WravtKqRvJI0ICDwvcdNQ=
github.com/lightningnetwork/lightning-onion v1.2.1-0.20230823005744-06182b1d7d2f h1:Pua7+5TcFEJXIIZ1I2YAUapmbcttmLj4TTi786bIi3s=
github.com/lightningnetwork/lightning-onion v1.2.1-0.20230823005744-06182b1d7d2f/go.mod h1:c0kvRShutpj3l6B9WtTsNTBUtjSmjZXbJd9ZBRQOSKI=
github.com/lightningnetwork/lnd v0.18.0-beta.rc4.0.20240919091721-70580403898e h1:Weu9TWNEIpC4XLbcUoSFK3Pv2aUSwn7NlYZKdsm8wUU=
Expand Down
25 changes: 16 additions & 9 deletions itest/assets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"github.com/lightninglabs/taproot-assets/proof"
"github.com/lightninglabs/taproot-assets/rfq"
"github.com/lightninglabs/taproot-assets/rfqmsg"
"github.com/lightninglabs/taproot-assets/tapchannel"
"github.com/lightninglabs/taproot-assets/tapfreighter"
"github.com/lightninglabs/taproot-assets/taprpc"
"github.com/lightninglabs/taproot-assets/taprpc/assetwalletrpc"
Expand All @@ -30,6 +29,7 @@ import (
tchrpc "github.com/lightninglabs/taproot-assets/taprpc/tapchannelrpc"
"github.com/lightninglabs/taproot-assets/taprpc/tapdevrpc"
"github.com/lightninglabs/taproot-assets/taprpc/universerpc"
"github.com/lightninglabs/taproot-assets/tapscript"
"github.com/lightningnetwork/lnd/fn"
"github.com/lightningnetwork/lnd/lnrpc"
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
Expand Down Expand Up @@ -70,7 +70,7 @@ func createTestAssetNetwork(t *harnessTest, net *NetworkHarness, charlieTap,
groupKey = mintedAsset.AssetGroup.TweakedGroupKey
}

fundingScriptTree := tapchannel.NewFundingScriptTree()
fundingScriptTree := tapscript.NewChannelFundingScriptTree()
fundingScriptKey := fundingScriptTree.TaprootKey
fundingScriptTreeBytes := fundingScriptKey.SerializeCompressed()

Expand All @@ -88,7 +88,7 @@ func createTestAssetNetwork(t *harnessTest, net *NetworkHarness, charlieTap,

t.Logf("Sending %v asset units to Dave...", assetSendAmount)

// Send the assets to Erin.
// Send the assets to Dave.
itest.AssertAddrCreated(t.t, daveTap, mintedAsset, daveAddr)
sendResp, err := charlieTap.SendAsset(ctxb, &taprpc.SendAssetRequest{
TapAddrs: []string{daveAddr.Encoded},
Expand Down Expand Up @@ -187,14 +187,15 @@ func createTestAssetNetwork(t *harnessTest, net *NetworkHarness, charlieTap,

// We'll be tracking the expected asset balances throughout the test, so
// we can assert it after each action.
charlieAssetBalance := charlieFundingAmount
daveAssetBalance := assetSendAmount
erinAssetBalance := assetSendAmount
charlieAssetBalance := mintedAsset.Amount - 2*assetSendAmount -
charlieFundingAmount
daveAssetBalance := assetSendAmount - daveFundingAmount
erinAssetBalance := assetSendAmount - erinFundingAmount

// After opening the channels, the asset balance of the funding nodes
// shouldn't have been decreased, since the asset with the funding
// output was imported into the asset DB and should count toward the
// balance.
// should have been decreased with the funding amount. The asset with
// the funding output was imported into the asset DB but are kept out of
// the balance reporting by tapd.
assertAssetBalance(t.t, charlieTap, assetID, charlieAssetBalance)
assertAssetBalance(t.t, daveTap, assetID, daveAssetBalance)
assertAssetBalance(t.t, erinTap, assetID, erinAssetBalance)
Expand Down Expand Up @@ -1312,17 +1313,23 @@ func assertAssetBalance(t *testing.T, client *tapClient, assetID []byte,
return err
}

assetIDFound := false
for _, balance := range assetIDBalances.AssetBalances {
if !bytes.Equal(balance.AssetGenesis.AssetId, assetID) {
continue
}

assetIDFound = true
if expectedBalance != balance.Balance {
return fmt.Errorf("expected balance %d, got %d",
expectedBalance, balance.Balance)
}
}

if expectedBalance > 0 && !assetIDFound {
return fmt.Errorf("expected balance %d, got 0",
expectedBalance)
}
return nil
}, shortTimeout)
if err != nil {
Expand Down
Loading
Loading