Skip to content

Commit

Permalink
fixup! itest: add test to check set/query for federation sync config
Browse files Browse the repository at this point in the history
  • Loading branch information
ffranr committed Oct 3, 2023
1 parent 3d6bd42 commit e69617e
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions itest/universe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"crypto/sha256"
"encoding/hex"
"fmt"
"github.com/lightninglabs/taproot-assets/universe"
"io"
prand "math/rand"

Expand Down Expand Up @@ -511,7 +512,12 @@ func testUniverseFederation(t *harnessTest) {
// testFederationSyncConfig tests that we can properly set and query the
// federation sync config.
func testFederationSyncConfig(t *harnessTest) {
ctxb := context.Background()
var (
ctx = context.Background()

excludeAllProofs = universe.SyncProofTypesNone
issuanceOnly = universe.SyncProofTypesIssuance
)

// Generate a random asset ID in order to generate a universe ID.
rand := prand.New(prand.NewSource(1))
Expand All @@ -522,36 +528,40 @@ func testFederationSyncConfig(t *harnessTest) {

// Set both the general and a universe specific federation sync configs.
_, err := t.tapd.UniverseClient.SetFederationSyncConfig(
ctxb, &unirpc.SetFederationSyncConfigRequest{
ctx, &unirpc.SetFederationSyncConfigRequest{
GeneralSyncConfig: &unirpc.GeneralFederationSyncConfig{
OnlySyncIssuanceProofs: true,
ProofTypes: issuanceOnly.String(),
},
AssetSyncConfig: []*unirpc.AssetFederationSyncConfig{
{
Id: uniIdRpc,
Exclude: true,
Id: uniIdRpc,
ProofTypes: excludeAllProofs.String(),
},
},
},
)
require.NoError(t.t, err)

resp, err := t.tapd.UniverseClient.QueryFederationSyncConfig(ctxb, &unirpc.QueryFederationSyncConfigRequest{
Id: []*unirpc.ID{
uniIdRpc,
},
})
resp, err := t.tapd.UniverseClient.QueryFederationSyncConfig(
ctx, &unirpc.QueryFederationSyncConfigRequest{
Id: []*unirpc.ID{
uniIdRpc,
},
})
require.NoError(t.t, err)

// In general, we expect to only sync issuance proofs.
require.True(t.t, resp.GeneralSyncConfig.OnlySyncIssuanceProofs)
require.Equal(
t.t, resp.GeneralSyncConfig.ProofTypes, issuanceOnly.String(),
)

// Ensure that the universe specific config is set as expected.
require.Equal(t.t, len(resp.AssetSyncConfigs), 1)

assetSyncConfig := resp.AssetSyncConfigs[0]

require.Equal(t.t, uniIdRpc.Id, assetSyncConfig.Id.Id)
require.True(t.t, assetSyncConfig.Exclude)
require.False(t.t, assetSyncConfig.OnlySyncIssuanceProofs)
require.Equal(
t.t, assetSyncConfig.ProofTypes, excludeAllProofs.String(),
)
}

0 comments on commit e69617e

Please sign in to comment.