Skip to content

Commit 8ac370b

Browse files
authored
Merge pull request #914 from lightninglabs/decimal-display-funding-blob
mod+itest: bump tapd, assert asset decimal display
2 parents e413905 + a551501 commit 8ac370b

File tree

4 files changed

+53
-19
lines changed

4 files changed

+53
-19
lines changed

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ require (
2323
github.com/lightninglabs/pool v0.6.5-beta.0.20241015105339-044cb451b5df
2424
github.com/lightninglabs/pool/auctioneerrpc v1.1.2
2525
github.com/lightninglabs/pool/poolrpc v1.0.0
26-
github.com/lightninglabs/taproot-assets v0.5.0-rc1.0.20241206085244-8113fa8bb314
26+
github.com/lightninglabs/taproot-assets v0.5.0-rc1.0.20241209075049-4a15eb2ab84e
2727
github.com/lightningnetwork/lnd v0.18.4-beta.rc1
2828
github.com/lightningnetwork/lnd/cert v1.2.2
2929
github.com/lightningnetwork/lnd/fn v1.2.3

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -1177,8 +1177,8 @@ github.com/lightninglabs/pool/poolrpc v1.0.0 h1:vvosrgNx9WXF4mcHGqLjZOW8wNM0q+BL
11771177
github.com/lightninglabs/pool/poolrpc v1.0.0/go.mod h1:ZqpEpBFRMMBAerMmilEjh27tqauSXDwLaLR0O3jvmMA=
11781178
github.com/lightninglabs/protobuf-go-hex-display v1.34.2-hex-display h1:w7FM5LH9Z6CpKxl13mS48idsu6F+cEZf0lkyiV+Dq9g=
11791179
github.com/lightninglabs/protobuf-go-hex-display v1.34.2-hex-display/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
1180-
github.com/lightninglabs/taproot-assets v0.5.0-rc1.0.20241206085244-8113fa8bb314 h1:ykWP63wGxW0OKW4lITz8/lWv6CLMswRRX4DCr37wAkU=
1181-
github.com/lightninglabs/taproot-assets v0.5.0-rc1.0.20241206085244-8113fa8bb314/go.mod h1:d9GdY5DVoSh6+dEQRS4UUcjpVvZlAHgP8U2DAp4YedA=
1180+
github.com/lightninglabs/taproot-assets v0.5.0-rc1.0.20241209075049-4a15eb2ab84e h1:dFbyAZrkQ9xALiVUf0qikLV2TabucCgPwJZ/Dc6r62Y=
1181+
github.com/lightninglabs/taproot-assets v0.5.0-rc1.0.20241209075049-4a15eb2ab84e/go.mod h1:d9GdY5DVoSh6+dEQRS4UUcjpVvZlAHgP8U2DAp4YedA=
11821182
github.com/lightningnetwork/lightning-onion v1.2.1-0.20240712235311-98bd56499dfb h1:yfM05S8DXKhuCBp5qSMZdtSwvJ+GFzl94KbXMNB1JDY=
11831183
github.com/lightningnetwork/lightning-onion v1.2.1-0.20240712235311-98bd56499dfb/go.mod h1:c0kvRShutpj3l6B9WtTsNTBUtjSmjZXbJd9ZBRQOSKI=
11841184
github.com/lightningnetwork/lnd v0.18.4-beta.rc1 h1:z6hFKvtbfo8udPrIb81GbSoKlUWd06d4LRxTkD19IMQ=

itest/assets_test.go

+43-9
Original file line numberDiff line numberDiff line change
@@ -184,14 +184,14 @@ func createTestAssetNetwork(t *harnessTest, net *NetworkHarness, charlieTap,
184184
// Make sure the pending channel shows up in the list and has the
185185
// custom records set as JSON.
186186
assertPendingChannels(
187-
t.t, charlieTap.node, assetID, 1, charlieFundingAmount, 0,
187+
t.t, charlieTap.node, mintedAsset, 1, charlieFundingAmount, 0,
188188
)
189189
assertPendingChannels(
190-
t.t, daveTap.node, assetID, 2, daveFundingAmount,
190+
t.t, daveTap.node, mintedAsset, 2, daveFundingAmount,
191191
charlieFundingAmount,
192192
)
193193
assertPendingChannels(
194-
t.t, erinTap.node, assetID, 1, erinFundingAmount, 0,
194+
t.t, erinTap.node, mintedAsset, 1, erinFundingAmount, 0,
195195
)
196196

197197
// Now that we've looked at the pending channels, let's actually confirm
@@ -259,13 +259,14 @@ func createTestAssetNetwork(t *harnessTest, net *NetworkHarness, charlieTap,
259259
// Make sure the channel shows the correct asset information.
260260
assertAssetChan(
261261
t.t, charlieTap.node, daveTap.node, charlieFundingAmount,
262-
assetID,
262+
mintedAsset,
263263
)
264264
assertAssetChan(
265-
t.t, daveTap.node, yaraTap.node, daveFundingAmount, assetID,
265+
t.t, daveTap.node, yaraTap.node, daveFundingAmount, mintedAsset,
266266
)
267267
assertAssetChan(
268-
t.t, erinTap.node, fabiaTap.node, erinFundingAmount, assetID,
268+
t.t, erinTap.node, fabiaTap.node, erinFundingAmount,
269+
mintedAsset,
269270
)
270271

271272
chanPointCD := &lnrpc.ChannelPoint{
@@ -451,8 +452,9 @@ func assertUniverseProofExists(t *testing.T, universe *tapClient,
451452
return a
452453
}
453454

454-
func assertPendingChannels(t *testing.T, node *HarnessNode, assetID []byte,
455-
numChannels int, localSum, remoteSum uint64) {
455+
func assertPendingChannels(t *testing.T, node *HarnessNode,
456+
mintedAsset *taprpc.Asset, numChannels int, localSum,
457+
remoteSum uint64) {
456458

457459
ctxb := context.Background()
458460
ctxt, cancel := context.WithTimeout(ctxb, defaultTimeout)
@@ -474,6 +476,22 @@ func assertPendingChannels(t *testing.T, node *HarnessNode, assetID []byte,
474476

475477
require.NotZero(t, pendingJSON.Assets[0].Capacity)
476478

479+
// Check the decimal display of the channel funding blob. If no explicit
480+
// value was set, we assume and expect the value of 0.
481+
var expectedDecimalDisplay uint8
482+
if mintedAsset.DecimalDisplay != nil {
483+
expectedDecimalDisplay = uint8(
484+
mintedAsset.DecimalDisplay.DecimalDisplay,
485+
)
486+
}
487+
488+
require.Equal(
489+
t, expectedDecimalDisplay,
490+
pendingJSON.Assets[0].AssetInfo.DecimalDisplay,
491+
)
492+
493+
// Check the balance of the pending channel.
494+
assetID := mintedAsset.AssetGenesis.AssetId
477495
pendingLocalBalance, pendingRemoteBalance, _, _ :=
478496
getAssetChannelBalance(
479497
t, node, assetID, true,
@@ -483,8 +501,9 @@ func assertPendingChannels(t *testing.T, node *HarnessNode, assetID []byte,
483501
}
484502

485503
func assertAssetChan(t *testing.T, src, dst *HarnessNode, fundingAmount uint64,
486-
assetID []byte) {
504+
mintedAsset *taprpc.Asset) {
487505

506+
assetID := mintedAsset.AssetGenesis.AssetId
488507
assetIDStr := hex.EncodeToString(assetID)
489508
err := wait.NoError(func() error {
490509
a, err := getChannelCustomData(src, dst)
@@ -501,6 +520,21 @@ func assertAssetChan(t *testing.T, src, dst *HarnessNode, fundingAmount uint64,
501520
fundingAmount, a.Capacity)
502521
}
503522

523+
// Check the decimal display of the channel funding blob. If no
524+
// explicit value was set, we assume and expect the value of 0.
525+
var expectedDecimalDisplay uint8
526+
if mintedAsset.DecimalDisplay != nil {
527+
expectedDecimalDisplay = uint8(
528+
mintedAsset.DecimalDisplay.DecimalDisplay,
529+
)
530+
}
531+
532+
if a.AssetInfo.DecimalDisplay != expectedDecimalDisplay {
533+
return fmt.Errorf("expected decimal display %d, got %d",
534+
expectedDecimalDisplay,
535+
a.AssetInfo.DecimalDisplay)
536+
}
537+
504538
return nil
505539
}, defaultTimeout)
506540
require.NoError(t, err)

itest/litd_custom_channels_test.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ func testCustomChannels(_ context.Context, net *NetworkHarness,
681681
t.t, universeTap, assetID, nil, fundingScriptTreeBytes,
682682
fmt.Sprintf("%v:%v", fundRespCD.Txid, fundRespCD.OutputIndex),
683683
)
684-
assertAssetChan(t.t, charlie, dave, fundingAmount, assetID)
684+
assertAssetChan(t.t, charlie, dave, fundingAmount, cents)
685685

686686
// And let's just close the channel again.
687687
chanPointCD = &lnrpc.ChannelPoint{
@@ -1116,7 +1116,7 @@ func testCustomChannelsGroupedAsset(_ context.Context, net *NetworkHarness,
11161116
t.t, universeTap, nil, groupID, fundingScriptTreeBytes,
11171117
fmt.Sprintf("%v:%v", fundRespCD.Txid, fundRespCD.OutputIndex),
11181118
)
1119-
assertAssetChan(t.t, charlie, dave, fundingAmount, assetID)
1119+
assertAssetChan(t.t, charlie, dave, fundingAmount, cents)
11201120

11211121
// And let's just close the channel again.
11221122
chanPointCD = &lnrpc.ChannelPoint{
@@ -1292,7 +1292,7 @@ func testCustomChannelsForceClose(_ context.Context, net *NetworkHarness,
12921292
)
12931293

12941294
// Make sure the channel shows the correct asset information.
1295-
assertAssetChan(t.t, charlie, dave, fundingAmount, assetID)
1295+
assertAssetChan(t.t, charlie, dave, fundingAmount, cents)
12961296

12971297
// Before we start sending out payments, let's make sure each node can
12981298
// see the other one in the graph and has all required features.
@@ -1635,7 +1635,7 @@ func testCustomChannelsBreach(_ context.Context, net *NetworkHarness,
16351635
)
16361636

16371637
// Make sure the channel shows the correct asset information.
1638-
assertAssetChan(t.t, charlie, dave, fundingAmount, assetID)
1638+
assertAssetChan(t.t, charlie, dave, fundingAmount, cents)
16391639

16401640
// Before we start sending out payments, let's make sure each node can
16411641
// see the other one in the graph and has all required features.
@@ -2289,7 +2289,7 @@ func testCustomChannelsBalanceConsistency(_ context.Context,
22892289
// Make sure the pending channel shows up in the list and has the
22902290
// custom records set as JSON.
22912291
assertPendingChannels(
2292-
t.t, charlieTap.node, assetID, 1, charlieBalance, 0,
2292+
t.t, charlieTap.node, cents, 1, charlieBalance, 0,
22932293
)
22942294

22952295
// Let's confirm the channel.
@@ -2325,7 +2325,7 @@ func testCustomChannelsBalanceConsistency(_ context.Context,
23252325

23262326
// Make sure the channel shows the correct asset information.
23272327
assertAssetChan(
2328-
t.t, charlieTap.node, daveTap.node, charlieBalance, assetID,
2328+
t.t, charlieTap.node, daveTap.node, charlieBalance, cents,
23292329
)
23302330

23312331
logBalance(t.t, nodes, assetID, "initial")
@@ -2513,7 +2513,7 @@ func testCustomChannelsSingleAssetMultiInput(_ context.Context,
25132513

25142514
// Make sure the channel shows the correct asset information.
25152515
assertAssetChan(
2516-
t.t, charlieTap.node, daveTap.node, 2*halfCentsAmount, assetID,
2516+
t.t, charlieTap.node, daveTap.node, 2*halfCentsAmount, cents,
25172517
)
25182518
}
25192519

0 commit comments

Comments
 (0)