test: modify testNodeAnnouncment to not open channel, shutdown dave

This commit modifies the testNodeAnnouncment to no longer open a
channel for the duration of the test. As the test is only exercising
the proper behavior of announcement propagation and doesn’t require a
channel to be open for the duration. Also we now properly shutdown the
created “dave” node, as it’s no longer needed after the tests
concludes.
This commit is contained in:
Olaoluwa Osuntokun 2017-04-16 15:27:28 -07:00
parent 610f42ad5a
commit b3424149ef
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2

@ -700,8 +700,8 @@ func testSingleHopInvoice(net *networkHarness, t *harnessTest) {
bobBalance, amt) bobBalance, amt)
} }
// Both channels should also have properly accunted from the amount // Both channels should also have properly accounted from the
// that has been sent/received over the channel. // amount that has been sent/received over the channel.
listReq := &lnrpc.ListChannelsRequest{} listReq := &lnrpc.ListChannelsRequest{}
aliceListChannels, err := net.Alice.ListChannels(ctxb, listReq) aliceListChannels, err := net.Alice.ListChannels(ctxb, listReq)
if err != nil { if err != nil {
@ -788,6 +788,7 @@ func testSingleHopInvoice(net *networkHarness, t *harnessTest) {
// With the payment completed all balance related stats should be // With the payment completed all balance related stats should be
// properly updated. // properly updated.
time.Sleep(time.Millisecond * 200)
assertPaymentBalance(paymentAmt) assertPaymentBalance(paymentAmt)
// Create another invoice for Bob, this time leaving off the preimage // Create another invoice for Bob, this time leaving off the preimage
@ -815,6 +816,7 @@ func testSingleHopInvoice(net *networkHarness, t *harnessTest) {
// The second payment should also have succeeded, with the balances // The second payment should also have succeeded, with the balances
// being update accordingly. // being update accordingly.
time.Sleep(time.Millisecond * 200)
assertPaymentBalance(paymentAmt * 2) assertPaymentBalance(paymentAmt * 2)
ctxt, _ = context.WithTimeout(ctxb, timeout) ctxt, _ = context.WithTimeout(ctxb, timeout)
@ -2073,9 +2075,7 @@ func testGraphTopologyNotifications(net *networkHarness, t *harnessTest) {
// external IP addresses specified on the command line, that those addresses // external IP addresses specified on the command line, that those addresses
// announced to the network and reported in the network graph. // announced to the network and reported in the network graph.
func testNodeAnnouncement(net *networkHarness, t *harnessTest) { func testNodeAnnouncement(net *networkHarness, t *harnessTest) {
timeout := time.Duration(time.Second * 15)
ctxb := context.Background() ctxb := context.Background()
ctxt, _ := context.WithTimeout(ctxb, timeout)
ipAddresses := map[string]bool{ ipAddresses := map[string]bool{
"192.168.1.1:8333": true, "192.168.1.1:8333": true,
@ -2096,10 +2096,7 @@ func testNodeAnnouncement(net *networkHarness, t *harnessTest) {
t.Fatalf("unable to connect bob to carol: %v", err) t.Fatalf("unable to connect bob to carol: %v", err)
} }
chanAmt := btcutil.Amount(btcutil.SatoshiPerBitcoin / 2) time.Sleep(time.Millisecond * 200)
chanPointAlice := openChannelAndAssert(ctxt, t, net, net.Alice, dave,
chanAmt, 0)
req := &lnrpc.ChannelGraphRequest{} req := &lnrpc.ChannelGraphRequest{}
chanGraph, err := net.Alice.DescribeGraph(ctxb, req) chanGraph, err := net.Alice.DescribeGraph(ctxb, req)
if err != nil { if err != nil {
@ -2130,7 +2127,10 @@ func testNodeAnnouncement(net *networkHarness, t *harnessTest) {
t.Fatalf("expected IP addresses not in channel "+ t.Fatalf("expected IP addresses not in channel "+
"graph: %v", ipAddresses) "graph: %v", ipAddresses)
} }
closeChannelAndAssert(ctxt, t, net, net.Alice, chanPointAlice, false)
if err := dave.Shutdown(); err != nil {
t.Fatalf("unable to shutdown dave: %v", err)
}
} }
type testCase struct { type testCase struct {