4242 regtestParams = & chaincfg .RegressionNetParams
4343)
4444
45+ const (
46+ SyncModeIssuance = universerpc .UniverseSyncMode_SYNC_ISSUANCE_ONLY
47+ SyncModeFull = universerpc .UniverseSyncMode_SYNC_FULL
48+ )
49+
4550// ClientEventStream is a generic interface for a client stream that allows us
4651// to receive events from a server.
4752type ClientEventStream [T any ] interface {
@@ -834,15 +839,45 @@ func MintAssetExternalSigner(t *harnessTest, tapNode *tapdHarness,
834839 return batchAssets
835840}
836841
842+ // syncOptions is a struct that is used to customize the way we perform a
843+ // universe sync.
844+ type syncOptions struct {
845+ syncMode universerpc.UniverseSyncMode
846+ }
847+
848+ // defaultSyncOptions returns the default syncOptions.
849+ func defaultSyncOptions () * syncOptions {
850+ return & syncOptions {
851+ syncMode : SyncModeIssuance ,
852+ }
853+ }
854+
855+ // SyncUniverseOpt is used to modify the parameters of a universe sync.
856+ type SyncUniverseOpt func (* syncOptions )
857+
858+ // WithSyncMode can be used to define which sync mode to be used when performing
859+ // a universe sync.
860+ func WithSyncMode (mode universerpc.UniverseSyncMode ) SyncUniverseOpt {
861+ return func (so * syncOptions ) {
862+ so .syncMode = mode
863+ }
864+ }
865+
837866// SyncUniverses syncs the universes of two tapd instances and waits until they
838867// are in sync.
839868func SyncUniverses (ctx context.Context , t * testing.T , clientTapd ,
840869 universeTapd commands.RpcClientsBundle , universeHost string ,
841- timeout time.Duration ) {
870+ timeout time.Duration , opts ... SyncUniverseOpt ) {
842871
843872 ctxt , cancel := context .WithTimeout (ctx , timeout )
844873 defer cancel ()
845874
875+ options := defaultSyncOptions ()
876+
877+ for _ , opt := range opts {
878+ opt (options )
879+ }
880+
846881 _ , err := clientTapd .AddFederationServer (
847882 ctxt , & universerpc.AddFederationServerRequest {
848883 Servers : []* universerpc.UniverseFederationServer {
@@ -863,10 +898,9 @@ func SyncUniverses(ctx context.Context, t *testing.T, clientTapd,
863898 // If we've already added the server in a previous run, we'll
864899 // just need to kick off a sync (as that would otherwise be done
865900 // by adding the server request already).
866- mode := universerpc .UniverseSyncMode_SYNC_ISSUANCE_ONLY
867901 _ , err := clientTapd .SyncUniverse (ctxt , & universerpc.SyncRequest {
868902 UniverseHost : universeHost ,
869- SyncMode : mode ,
903+ SyncMode : options . syncMode ,
870904 })
871905 require .NoError (t , err )
872906 }
0 commit comments