package bridge import ( "testing" "time" ) // TestNodeDataIdle: the idle bound is measured on data the node produced for the client, not // on frames from the node. A ping every couple of minutes otherwise keeps a wedged session // looking alive for ever, which is exactly how a silent node was mistaken for a slow one. func TestNodeDataIdle(t *testing.T) { now := time.Now() if nodeDataIdle(now.Add(-3*time.Minute).UnixNano(), now, 2*time.Minute) != true { t.Fatal("three minutes without data, a two-minute bound: not idle") } if nodeDataIdle(now.Add(-time.Minute).UnixNano(), now, 2*time.Minute) != false { t.Fatal("one minute without data, a two-minute bound: idle") } if nodeDataIdle(now.Add(-time.Hour).UnixNano(), now, 0) != false { t.Fatal("a zero bound expired") } }