htlcswitch: fix race in forwarding log test by grabbing log mtx

This commit is contained in:
Olaoluwa Osuntokun 2018-03-08 20:11:43 -08:00
parent 649be5ee0b
commit 51a3cab39c
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21

@ -621,6 +621,8 @@ func TestLocalPaymentNoForwardingEvents(t *testing.T) {
if !ok {
t.Fatalf("mockForwardingLog assertion failed")
}
log.Lock()
defer log.Unlock()
// If we examine the memory of the forwarding log, then it should be
// blank.
@ -681,14 +683,19 @@ func TestMultiHopPaymentForwardingEvents(t *testing.T) {
if !ok {
t.Fatalf("mockForwardingLog assertion failed")
}
aliceLog.Lock()
defer aliceLog.Unlock()
if len(aliceLog.events) != 0 {
t.Fatalf("log should have no events, instead has: %v",
spew.Sdump(aliceLog.events))
}
carolLog, ok := n.carolServer.htlcSwitch.cfg.FwdingLog.(*mockForwardingLog)
if !ok {
t.Fatalf("mockForwardingLog assertion failed")
}
carolLog.Lock()
defer carolLog.Unlock()
if len(carolLog.events) != 0 {
t.Fatalf("log should have no events, instead has: %v",
spew.Sdump(carolLog.events))
@ -699,6 +706,8 @@ func TestMultiHopPaymentForwardingEvents(t *testing.T) {
if !ok {
t.Fatalf("mockForwardingLog assertion failed")
}
bobLog.Lock()
defer bobLog.Unlock()
if len(bobLog.events) != 10 {
t.Fatalf("log should have 10 events, instead has: %v",
spew.Sdump(bobLog.events))