|
1 | 1 | package itest
|
2 | 2 |
|
3 | 3 | import (
|
| 4 | + "fmt" |
4 | 5 | "testing"
|
5 | 6 | )
|
6 | 7 |
|
7 |
| -const testnetMailbox = "mailbox.testnet.lightningcluster.com:443" |
8 |
| - |
9 | 8 | // TestLightningNodeConnect runs the itests against a local mailbox instance.
|
10 | 9 | func TestLightningNodeConnect(t *testing.T) {
|
11 | 10 | // If no tests are registered, then we can exit early.
|
12 | 11 | if len(testCases) == 0 {
|
13 | 12 | t.Skip("integration tests not selected")
|
14 | 13 | }
|
15 | 14 |
|
16 |
| - ht := newHarnessTest(t, nil, nil, nil) |
17 |
| - ht.setupLogging() |
| 15 | + setupLogging(t) |
| 16 | + |
| 17 | + testConfigs := []*testConfig{ |
| 18 | + {stagingMailbox: false, grpcClientConn: false}, |
| 19 | + {stagingMailbox: false, grpcClientConn: true}, |
| 20 | + {stagingMailbox: true, grpcClientConn: false}, |
| 21 | + {stagingMailbox: true, grpcClientConn: true}, |
| 22 | + } |
18 | 23 |
|
19 | 24 | t.Logf("Running %v integration tests", len(testCases))
|
20 | 25 | for _, testCase := range testCases {
|
21 | 26 |
|
22 | 27 | testCase := testCase
|
| 28 | + for _, config := range testConfigs { |
| 29 | + config := config |
23 | 30 |
|
24 |
| - success := t.Run(testCase.name, func(t1 *testing.T) { |
25 |
| - clientHarness, serverHarness, hashmailHarness := setupHarnesses(t1) |
26 |
| - |
27 |
| - ht := newHarnessTest( |
28 |
| - t1, clientHarness, serverHarness, |
29 |
| - hashmailHarness, |
30 |
| - ) |
31 |
| - |
32 |
| - // Now we have everything to run the test case. |
33 |
| - ht.RunTestCase(testCase) |
34 |
| - |
35 |
| - // Shut down both client, server and hashmail server |
36 |
| - // to remove all state. |
37 |
| - err := ht.shutdown() |
38 |
| - if err != nil { |
39 |
| - t1.Fatalf("error shutting down harness: %v", |
40 |
| - err) |
| 31 | + if config.stagingMailbox && testCase.localMailboxOnly { |
| 32 | + continue |
41 | 33 | }
|
42 |
| - }) |
43 |
| - |
44 |
| - // Close at the first failure. Mimic behavior of original test |
45 |
| - // framework. |
46 |
| - if !success { |
47 |
| - break |
48 |
| - } |
49 |
| - } |
50 |
| -} |
51 |
| - |
52 |
| -// TestLightningNodeConnectTestnetMailbox runs the itests using the mailbox |
53 |
| -// running in the LL testnet environment. |
54 |
| -func TestLightningNodeConnectTestnetMailbox(t *testing.T) { |
55 |
| - // If no tests are registered, then we can exit early. |
56 |
| - if len(stagingMailboxTests) == 0 { |
57 |
| - t.Skip("integration tests not selected") |
58 |
| - } |
59 | 34 |
|
60 |
| - ht := newHarnessTest(t, nil, nil, nil) |
61 |
| - ht.setupLogging() |
62 |
| - |
63 |
| - t.Logf("Running %v integration tests", len(stagingMailboxTests)) |
64 |
| - for _, testCase := range stagingMailboxTests { |
65 |
| - |
66 |
| - testCase := testCase |
67 |
| - |
68 |
| - success := t.Run(testCase.name, func(t1 *testing.T) { |
69 |
| - clientHarness, serverHarness := |
70 |
| - setupClientAndServerHarnesses( |
71 |
| - t1, testnetMailbox, false, |
72 |
| - ) |
73 |
| - |
74 |
| - ht := newHarnessTest( |
75 |
| - t1, clientHarness, serverHarness, nil, |
76 |
| - ) |
77 |
| - |
78 |
| - // Now we have everything to run the test case. |
79 |
| - ht.RunTestCase(testCase) |
80 |
| - |
81 |
| - // Shut down both client, server and hashmail server |
82 |
| - // to remove all state. |
83 |
| - err := ht.shutdown() |
84 |
| - if err != nil { |
85 |
| - t1.Fatalf("error shutting down harness: %v", |
86 |
| - err) |
| 35 | + name := fmt.Sprintf("%s(stagingMailbox:%t,"+ |
| 36 | + "grpcClientConn:%t)", testCase.name, |
| 37 | + config.stagingMailbox, config.grpcClientConn) |
| 38 | + |
| 39 | + success := t.Run(name, func(t1 *testing.T) { |
| 40 | + ht := newHarnessTest(t1, config) |
| 41 | + |
| 42 | + // Now we have everything to run the test case. |
| 43 | + ht.RunTestCase(testCase) |
| 44 | + |
| 45 | + // Shut down both client, server and hashmail |
| 46 | + // server to remove all state. |
| 47 | + err := ht.shutdown() |
| 48 | + if err != nil { |
| 49 | + t1.Fatalf("error shutting down "+ |
| 50 | + "harness: %v", err) |
| 51 | + } |
| 52 | + }) |
| 53 | + |
| 54 | + // Close at the first failure. Mimic behavior of |
| 55 | + // original test framework. |
| 56 | + if !success { |
| 57 | + break |
87 | 58 | }
|
88 |
| - }) |
89 |
| - |
90 |
| - // Close at the first failure. Mimic behavior of original test |
91 |
| - // framework. |
92 |
| - if !success { |
93 |
| - break |
94 | 59 | }
|
95 | 60 | }
|
96 | 61 | }
|
0 commit comments