Skip to content

Commit 642c536

Browse files
itest: export HashmailHarness struct
1 parent e332cb8 commit 642c536

File tree

3 files changed

+23
-18
lines changed

3 files changed

+23
-18
lines changed

itest/connection_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ func testHashmailServerReconnect(t *harnessTest) {
4545
require.Equal(t.t, len(defaultMessage)*10, len(resp.Resp))
4646

4747
// Shut down hashmail server
48-
require.NoError(t.t, t.hmserver.stop())
48+
require.NoError(t.t, t.hmserver.Stop())
4949

5050
// Check that the client and server status are updated appropriately.
5151
assertServerStatus(t, mailbox.ServerStatusNotConnected)
5252
assertClientStatus(t, mailbox.ClientStatusNotConnected)
5353

5454
// Restart hashmail server
55-
require.NoError(t.t, t.hmserver.start())
55+
require.NoError(t.t, t.hmserver.Start())
5656

5757
// Check that the client and server successfully reconnect.
5858
assertServerStatus(t, mailbox.ServerStatusInUse)

itest/hashmailserver_harness.go

+16-11
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,17 @@ import (
1212
"github.com/lightningnetwork/lnd/lntest/wait"
1313
)
1414

15-
type hashmailHarness struct {
16-
aperture *aperture.Aperture
17-
apertureCfg *aperture.Config
15+
type HashmailHarness struct {
16+
aperture *aperture.Aperture
17+
18+
// ApertureCfg is the configuration aperture uses when being initialized.
19+
ApertureCfg *aperture.Config
1820
}
1921

20-
func newHashmailHarness() *hashmailHarness {
21-
return &hashmailHarness{
22-
apertureCfg: &aperture.Config{
22+
// NewHashmailHarness creates a new instance of the HashmailHarness.
23+
func NewHashmailHarness() *HashmailHarness {
24+
return &HashmailHarness{
25+
ApertureCfg: &aperture.Config{
2326
ListenAddr: fmt.Sprintf("127.0.0.1:%d",
2427
node.NextAvailablePort()),
2528
Authenticator: &aperture.AuthConfig{
@@ -39,8 +42,8 @@ func newHashmailHarness() *hashmailHarness {
3942
}
4043

4144
// initAperture starts the aperture proxy.
42-
func (hm *hashmailHarness) initAperture() error {
43-
hm.aperture = aperture.NewAperture(hm.apertureCfg)
45+
func (hm *HashmailHarness) initAperture() error {
46+
hm.aperture = aperture.NewAperture(hm.ApertureCfg)
4447
errChan := make(chan error)
4548

4649
if err := hm.aperture.Start(errChan); err != nil {
@@ -60,7 +63,7 @@ func (hm *hashmailHarness) initAperture() error {
6063
}
6164
return wait.NoError(func() error {
6265
apertureAddr := fmt.Sprintf("https://%s/dummy",
63-
hm.apertureCfg.ListenAddr)
66+
hm.ApertureCfg.ListenAddr)
6467

6568
resp, err := http.Get(apertureAddr)
6669
if err != nil {
@@ -75,14 +78,16 @@ func (hm *hashmailHarness) initAperture() error {
7578
}, 3*time.Second)
7679
}
7780

78-
func (hm *hashmailHarness) start() error {
81+
// Start attempts to start the aperture proxy.
82+
func (hm *HashmailHarness) Start() error {
7983
if err := hm.initAperture(); err != nil {
8084
return fmt.Errorf("could not start aperture: %v", err)
8185
}
8286

8387
return nil
8488
}
8589

86-
func (hm *hashmailHarness) stop() error {
90+
// Stop attempts to stop the aperture proxy.
91+
func (hm *HashmailHarness) Stop() error {
8792
return hm.aperture.Stop()
8893
}

itest/test_harness.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ type harnessTest struct {
4444

4545
server *serverHarness
4646

47-
hmserver *hashmailHarness
47+
hmserver *HashmailHarness
4848
}
4949

5050
// testConfig determines the way in which the test will be set up.
@@ -61,11 +61,11 @@ func newHarnessTest(t *testing.T, cfg *testConfig) *harnessTest {
6161
mailboxAddr := testnetMailbox
6262
var insecure bool
6363
if !cfg.stagingMailbox {
64-
ht.hmserver = newHashmailHarness()
65-
if err := ht.hmserver.start(); err != nil {
64+
ht.hmserver = NewHashmailHarness()
65+
if err := ht.hmserver.Start(); err != nil {
6666
t.Fatalf("could not start hashmail server: %v", err)
6767
}
68-
mailboxAddr = ht.hmserver.apertureCfg.ListenAddr
68+
mailboxAddr = ht.hmserver.ApertureCfg.ListenAddr
6969
insecure = true
7070
}
7171

@@ -186,7 +186,7 @@ func (h *harnessTest) shutdown() error {
186186
h.server.stop()
187187

188188
if h.hmserver != nil {
189-
err := h.hmserver.stop()
189+
err := h.hmserver.Stop()
190190
if err != nil {
191191
returnErr = err
192192
}

0 commit comments

Comments
 (0)