Skip to content

Commit

Permalink
itest: add test to check set/query for federation config
Browse files Browse the repository at this point in the history
  • Loading branch information
ffranr committed Sep 29, 2023
1 parent 81dd291 commit c9bb481
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
4 changes: 4 additions & 0 deletions itest/test_list_on_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ var testCases = []*testCase{
name: "burn test",
test: testBurnAssets,
},
{
name: "federation sync config",
test: testFederationSyncConfig,
},
}

var optionalTestCases = []*testCase{
Expand Down
49 changes: 49 additions & 0 deletions itest/universe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}

0 comments on commit c9bb481

Please sign in to comment.