Skip to content

mod+itest: bump tapd, assert asset decimal display #914

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

Merged
merged 1 commit into from
Dec 9, 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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ require (
github.com/lightninglabs/pool v0.6.5-beta.0.20241015105339-044cb451b5df
github.com/lightninglabs/pool/auctioneerrpc v1.1.2
github.com/lightninglabs/pool/poolrpc v1.0.0
github.com/lightninglabs/taproot-assets v0.5.0-rc1.0.20241206085244-8113fa8bb314
github.com/lightninglabs/taproot-assets v0.5.0-rc1.0.20241209075049-4a15eb2ab84e
github.com/lightningnetwork/lnd v0.18.4-beta.rc1
github.com/lightningnetwork/lnd/cert v1.2.2
github.com/lightningnetwork/lnd/fn v1.2.3
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1177,8 +1177,8 @@ github.com/lightninglabs/pool/poolrpc v1.0.0 h1:vvosrgNx9WXF4mcHGqLjZOW8wNM0q+BL
github.com/lightninglabs/pool/poolrpc v1.0.0/go.mod h1:ZqpEpBFRMMBAerMmilEjh27tqauSXDwLaLR0O3jvmMA=
github.com/lightninglabs/protobuf-go-hex-display v1.34.2-hex-display h1:w7FM5LH9Z6CpKxl13mS48idsu6F+cEZf0lkyiV+Dq9g=
github.com/lightninglabs/protobuf-go-hex-display v1.34.2-hex-display/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
github.com/lightninglabs/taproot-assets v0.5.0-rc1.0.20241206085244-8113fa8bb314 h1:ykWP63wGxW0OKW4lITz8/lWv6CLMswRRX4DCr37wAkU=
github.com/lightninglabs/taproot-assets v0.5.0-rc1.0.20241206085244-8113fa8bb314/go.mod h1:d9GdY5DVoSh6+dEQRS4UUcjpVvZlAHgP8U2DAp4YedA=
github.com/lightninglabs/taproot-assets v0.5.0-rc1.0.20241209075049-4a15eb2ab84e h1:dFbyAZrkQ9xALiVUf0qikLV2TabucCgPwJZ/Dc6r62Y=
github.com/lightninglabs/taproot-assets v0.5.0-rc1.0.20241209075049-4a15eb2ab84e/go.mod h1:d9GdY5DVoSh6+dEQRS4UUcjpVvZlAHgP8U2DAp4YedA=
github.com/lightningnetwork/lightning-onion v1.2.1-0.20240712235311-98bd56499dfb h1:yfM05S8DXKhuCBp5qSMZdtSwvJ+GFzl94KbXMNB1JDY=
github.com/lightningnetwork/lightning-onion v1.2.1-0.20240712235311-98bd56499dfb/go.mod h1:c0kvRShutpj3l6B9WtTsNTBUtjSmjZXbJd9ZBRQOSKI=
github.com/lightningnetwork/lnd v0.18.4-beta.rc1 h1:z6hFKvtbfo8udPrIb81GbSoKlUWd06d4LRxTkD19IMQ=
Expand Down
52 changes: 43 additions & 9 deletions itest/assets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,14 @@ func createTestAssetNetwork(t *harnessTest, net *NetworkHarness, charlieTap,
// Make sure the pending channel shows up in the list and has the
// custom records set as JSON.
assertPendingChannels(
t.t, charlieTap.node, assetID, 1, charlieFundingAmount, 0,
t.t, charlieTap.node, mintedAsset, 1, charlieFundingAmount, 0,
)
assertPendingChannels(
t.t, daveTap.node, assetID, 2, daveFundingAmount,
t.t, daveTap.node, mintedAsset, 2, daveFundingAmount,
charlieFundingAmount,
)
assertPendingChannels(
t.t, erinTap.node, assetID, 1, erinFundingAmount, 0,
t.t, erinTap.node, mintedAsset, 1, erinFundingAmount, 0,
)

// Now that we've looked at the pending channels, let's actually confirm
Expand Down Expand Up @@ -259,13 +259,14 @@ func createTestAssetNetwork(t *harnessTest, net *NetworkHarness, charlieTap,
// Make sure the channel shows the correct asset information.
assertAssetChan(
t.t, charlieTap.node, daveTap.node, charlieFundingAmount,
assetID,
mintedAsset,
)
assertAssetChan(
t.t, daveTap.node, yaraTap.node, daveFundingAmount, assetID,
t.t, daveTap.node, yaraTap.node, daveFundingAmount, mintedAsset,
)
assertAssetChan(
t.t, erinTap.node, fabiaTap.node, erinFundingAmount, assetID,
t.t, erinTap.node, fabiaTap.node, erinFundingAmount,
mintedAsset,
)

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

func assertPendingChannels(t *testing.T, node *HarnessNode, assetID []byte,
numChannels int, localSum, remoteSum uint64) {
func assertPendingChannels(t *testing.T, node *HarnessNode,
mintedAsset *taprpc.Asset, numChannels int, localSum,
remoteSum uint64) {

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

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

// Check the decimal display of the channel funding blob. If no explicit
// value was set, we assume and expect the value of 0.
var expectedDecimalDisplay uint8
if mintedAsset.DecimalDisplay != nil {
expectedDecimalDisplay = uint8(
mintedAsset.DecimalDisplay.DecimalDisplay,
)
}

require.Equal(
t, expectedDecimalDisplay,
pendingJSON.Assets[0].AssetInfo.DecimalDisplay,
)

// Check the balance of the pending channel.
assetID := mintedAsset.AssetGenesis.AssetId
pendingLocalBalance, pendingRemoteBalance, _, _ :=
getAssetChannelBalance(
t, node, assetID, true,
Expand All @@ -483,8 +501,9 @@ func assertPendingChannels(t *testing.T, node *HarnessNode, assetID []byte,
}

func assertAssetChan(t *testing.T, src, dst *HarnessNode, fundingAmount uint64,
assetID []byte) {
mintedAsset *taprpc.Asset) {

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

// Check the decimal display of the channel funding blob. If no
// explicit value was set, we assume and expect the value of 0.
var expectedDecimalDisplay uint8
if mintedAsset.DecimalDisplay != nil {
expectedDecimalDisplay = uint8(
mintedAsset.DecimalDisplay.DecimalDisplay,
)
}

if a.AssetInfo.DecimalDisplay != expectedDecimalDisplay {
return fmt.Errorf("expected decimal display %d, got %d",
expectedDecimalDisplay,
a.AssetInfo.DecimalDisplay)
}

return nil
}, defaultTimeout)
require.NoError(t, err)
Expand Down
14 changes: 7 additions & 7 deletions itest/litd_custom_channels_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ func testCustomChannels(_ context.Context, net *NetworkHarness,
t.t, universeTap, assetID, nil, fundingScriptTreeBytes,
fmt.Sprintf("%v:%v", fundRespCD.Txid, fundRespCD.OutputIndex),
)
assertAssetChan(t.t, charlie, dave, fundingAmount, assetID)
assertAssetChan(t.t, charlie, dave, fundingAmount, cents)

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

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

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

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

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

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

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

// Make sure the channel shows the correct asset information.
assertAssetChan(
t.t, charlieTap.node, daveTap.node, charlieBalance, assetID,
t.t, charlieTap.node, daveTap.node, charlieBalance, cents,
)

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

// Make sure the channel shows the correct asset information.
assertAssetChan(
t.t, charlieTap.node, daveTap.node, 2*halfCentsAmount, assetID,
t.t, charlieTap.node, daveTap.node, 2*halfCentsAmount, cents,
)
}

Expand Down
Loading