diff --git a/itest/test_list_on_test.go b/itest/test_list_on_test.go index ecdc77bcc..d1b0dfa5a 100644 --- a/itest/test_list_on_test.go +++ b/itest/test_list_on_test.go @@ -160,6 +160,10 @@ var testCases = []*testCase{ name: "burn test", test: testBurnAssets, }, + { + name: "federation sync config", + test: testFederationSyncConfig, + }, } var optionalTestCases = []*testCase{ diff --git a/itest/universe_test.go b/itest/universe_test.go index a923912e5..db2a6dc80 100644 --- a/itest/universe_test.go +++ b/itest/universe_test.go @@ -7,6 +7,7 @@ import ( "encoding/hex" "fmt" "io" + prand "math/rand" "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcec/v2/schnorr" @@ -492,3 +493,51 @@ func testUniverseFederation(t *harnessTest) { require.NoError(t.t, err) require.Equal(t.t, 0, len(fedNodes.Servers)) } + +// testFederationSyncConfig tests that we can properly set and query the +// federation sync config. +func testFederationSyncConfig(t *harnessTest) { + ctxb := context.Background() + + // Generate a random asset ID in order to generate a universe ID. + rand := prand.New(prand.NewSource(1)) + assetIDBytes := make([]byte, 32) + _, _ = rand.Read(assetIDBytes) + + uniIdRpc := unirpc.MarshalUniverseID(assetIDBytes, nil) + + // Set both the general and a universe specific federation sync configs. + _, err := t.tapd.UniverseClient.SetFederationSyncConfig( + ctxb, &unirpc.SetFederationSyncConfigRequest{ + GeneralSyncConfig: &unirpc.GeneralFederationSyncConfig{ + OnlySyncIssuanceProofs: true, + }, + AssetSyncConfig: []*unirpc.AssetFederationSyncConfig{ + { + Id: uniIdRpc, + Exclude: true, + }, + }, + }, + ) + require.NoError(t.t, err) + + resp, err := t.tapd.UniverseClient.QueryFederationSyncConfig(ctxb, &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) + + // 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) +}