htlcswitch: fix race in forwarding log test by grabbing log mtx
This commit is contained in:
parent
649be5ee0b
commit
51a3cab39c
@ -621,6 +621,8 @@ func TestLocalPaymentNoForwardingEvents(t *testing.T) {
|
|||||||
if !ok {
|
if !ok {
|
||||||
t.Fatalf("mockForwardingLog assertion failed")
|
t.Fatalf("mockForwardingLog assertion failed")
|
||||||
}
|
}
|
||||||
|
log.Lock()
|
||||||
|
defer log.Unlock()
|
||||||
|
|
||||||
// If we examine the memory of the forwarding log, then it should be
|
// If we examine the memory of the forwarding log, then it should be
|
||||||
// blank.
|
// blank.
|
||||||
@ -681,14 +683,19 @@ func TestMultiHopPaymentForwardingEvents(t *testing.T) {
|
|||||||
if !ok {
|
if !ok {
|
||||||
t.Fatalf("mockForwardingLog assertion failed")
|
t.Fatalf("mockForwardingLog assertion failed")
|
||||||
}
|
}
|
||||||
|
aliceLog.Lock()
|
||||||
|
defer aliceLog.Unlock()
|
||||||
if len(aliceLog.events) != 0 {
|
if len(aliceLog.events) != 0 {
|
||||||
t.Fatalf("log should have no events, instead has: %v",
|
t.Fatalf("log should have no events, instead has: %v",
|
||||||
spew.Sdump(aliceLog.events))
|
spew.Sdump(aliceLog.events))
|
||||||
}
|
}
|
||||||
|
|
||||||
carolLog, ok := n.carolServer.htlcSwitch.cfg.FwdingLog.(*mockForwardingLog)
|
carolLog, ok := n.carolServer.htlcSwitch.cfg.FwdingLog.(*mockForwardingLog)
|
||||||
if !ok {
|
if !ok {
|
||||||
t.Fatalf("mockForwardingLog assertion failed")
|
t.Fatalf("mockForwardingLog assertion failed")
|
||||||
}
|
}
|
||||||
|
carolLog.Lock()
|
||||||
|
defer carolLog.Unlock()
|
||||||
if len(carolLog.events) != 0 {
|
if len(carolLog.events) != 0 {
|
||||||
t.Fatalf("log should have no events, instead has: %v",
|
t.Fatalf("log should have no events, instead has: %v",
|
||||||
spew.Sdump(carolLog.events))
|
spew.Sdump(carolLog.events))
|
||||||
@ -699,6 +706,8 @@ func TestMultiHopPaymentForwardingEvents(t *testing.T) {
|
|||||||
if !ok {
|
if !ok {
|
||||||
t.Fatalf("mockForwardingLog assertion failed")
|
t.Fatalf("mockForwardingLog assertion failed")
|
||||||
}
|
}
|
||||||
|
bobLog.Lock()
|
||||||
|
defer bobLog.Unlock()
|
||||||
if len(bobLog.events) != 10 {
|
if len(bobLog.events) != 10 {
|
||||||
t.Fatalf("log should have 10 events, instead has: %v",
|
t.Fatalf("log should have 10 events, instead has: %v",
|
||||||
spew.Sdump(bobLog.events))
|
spew.Sdump(bobLog.events))
|
||||||
|
Loading…
Reference in New Issue
Block a user