Skip to content

Commit 9fd7e5f

Browse files
committed
itest: preparations for testing disabled sub-servers
1 parent c8aa0c9 commit 9fd7e5f

File tree

1 file changed

+76
-29
lines changed

1 file changed

+76
-29
lines changed

itest/litd_node.go

Lines changed: 76 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ var (
6262
type LitNodeConfig struct {
6363
*node.BaseNodeConfig
6464

65-
LitArgs []string
65+
LitArgs []string
66+
ActiveArgs *litArgs
6667

6768
RemoteMode bool
6869

@@ -129,6 +130,19 @@ func (l *litArgs) addArg(name, value string) {
129130
l.args[name] = value
130131
}
131132

133+
// getArg gets the arg with the given name from the set and returns the value.
134+
// The boolean returned will be true if the argument is in the set. If the
135+
// boolean is true but the string is empty, it means it is a boolean config
136+
// flag.
137+
func (l *litArgs) getArg(name string) (string, bool) {
138+
l.mu.Lock()
139+
defer l.mu.Unlock()
140+
141+
value, ok := l.args[name]
142+
143+
return value, ok
144+
}
145+
132146
// toArgList converts the litArgs map to an arguments string slice.
133147
func (l *litArgs) toArgList() []string {
134148
l.mu.Lock()
@@ -175,6 +189,8 @@ func (cfg *LitNodeConfig) GenArgs(opts ...LitArgOption) []string {
175189
opt(args)
176190
}
177191

192+
cfg.ActiveArgs = args
193+
178194
return args.toArgList()
179195
}
180196

@@ -539,7 +555,7 @@ func renameFile(fromFileName, toFileName string) {
539555
// This may not clean up properly if an error is returned, so the caller should
540556
// call shutdown() regardless of the return value.
541557
func (hn *HarnessNode) start(litdBinary string, litdError chan<- error,
542-
wait bool, litArgOpts ...LitArgOption) error {
558+
waitForStart bool, litArgOpts ...LitArgOption) error {
543559

544560
hn.quit = make(chan struct{})
545561

@@ -640,7 +656,7 @@ func (hn *HarnessNode) start(litdBinary string, litdError chan<- error,
640656

641657
// We may want to skip waiting for the node to come up (eg. the node
642658
// is waiting to become the leader).
643-
if !wait {
659+
if !waitForStart {
644660
return nil
645661
}
646662

@@ -681,7 +697,16 @@ func (hn *HarnessNode) start(litdBinary string, litdError chan<- error,
681697
}
682698
hn.litConn = litConn
683699

684-
return nil
700+
ctxt, cancel := context.WithTimeout(
701+
context.Background(), lntest.DefaultTimeout,
702+
)
703+
defer cancel()
704+
return wait.NoError(func() error {
705+
litConn := litrpc.NewProxyClient(hn.litConn)
706+
707+
_, err = litConn.GetInfo(ctxt, &litrpc.GetInfoRequest{})
708+
return err
709+
}, lntest.DefaultTimeout)
685710
}
686711

687712
// WaitUntilStarted waits until the wallet state flips from "WAITING_TO_START".
@@ -695,39 +720,53 @@ func (hn *HarnessNode) WaitUntilStarted(conn grpc.ClientConnInterface,
695720
return err
696721
}
697722

723+
faradayMode, _ := hn.Cfg.ActiveArgs.getArg("faraday-mode")
724+
loopMode, _ := hn.Cfg.ActiveArgs.getArg("faraday-mode")
725+
poolMode, _ := hn.Cfg.ActiveArgs.getArg("faraday-mode")
726+
698727
ctxt, cancel := context.WithTimeout(context.Background(), timeout)
699728
defer cancel()
700729
return wait.NoError(func() error {
701-
faradayClient, err := hn.faradayClient()
702-
if err != nil {
703-
return err
704-
}
730+
if faradayMode != "disable" {
731+
faradayClient, err := hn.faradayClient()
732+
if err != nil {
733+
return err
734+
}
705735

706-
_, err = faradayClient.RevenueReport(
707-
ctxt, &frdrpc.RevenueReportRequest{},
708-
)
709-
if err != nil {
710-
return err
736+
_, err = faradayClient.RevenueReport(
737+
ctxt, &frdrpc.RevenueReportRequest{},
738+
)
739+
if err != nil {
740+
return err
741+
}
711742
}
712743

713-
loopClient, err := hn.loopClient()
714-
if err != nil {
715-
return err
716-
}
744+
if loopMode != "disable" {
745+
loopClient, err := hn.loopClient()
746+
if err != nil {
747+
return err
748+
}
717749

718-
_, err = loopClient.ListSwaps(ctxt, &looprpc.ListSwapsRequest{})
719-
if err != nil {
720-
return err
750+
_, err = loopClient.ListSwaps(
751+
ctxt, &looprpc.ListSwapsRequest{},
752+
)
753+
if err != nil {
754+
return err
755+
}
721756
}
722757

723-
poolClient, err := hn.poolClient()
724-
if err != nil {
725-
return err
726-
}
758+
if poolMode != "disable" {
759+
poolClient, err := hn.poolClient()
760+
if err != nil {
761+
return err
762+
}
727763

728-
_, err = poolClient.GetInfo(ctxt, &poolrpc.GetInfoRequest{})
729-
if err != nil {
730-
return err
764+
_, err = poolClient.GetInfo(
765+
ctxt, &poolrpc.GetInfoRequest{},
766+
)
767+
if err != nil {
768+
return err
769+
}
731770
}
732771

733772
return nil
@@ -788,9 +827,17 @@ func (hn *HarnessNode) waitForState(conn grpc.ClientConnInterface,
788827
ctx, cancel := context.WithCancel(context.Background())
789828
defer cancel()
790829

791-
stateStream, err := stateClient.SubscribeState(
792-
ctx, &lnrpc.SubscribeStateRequest{},
830+
var (
831+
stateStream lnrpc.State_SubscribeStateClient
832+
err error
793833
)
834+
err = wait.NoError(func() error {
835+
stateStream, err = stateClient.SubscribeState(
836+
ctx, &lnrpc.SubscribeStateRequest{},
837+
)
838+
839+
return err
840+
}, lntest.DefaultTimeout)
794841
if err != nil {
795842
return err
796843
}

0 commit comments

Comments
 (0)