Commit 8dd18f0e authored by Adrian Sutton's avatar Adrian Sutton Committed by GitHub

Use log label game consistently (#10603)

parent cfe82c63
...@@ -96,7 +96,7 @@ func (b *Bonds) checkCredits(games []*types.EnrichedGameData) { ...@@ -96,7 +96,7 @@ func (b *Bonds) checkCredits(games []*types.EnrichedGameData) {
if maxDurationReached { if maxDurationReached {
if comparison > 0 { if comparison > 0 {
creditMetrics[metrics.CreditAboveMaxDuration] += 1 creditMetrics[metrics.CreditAboveMaxDuration] += 1
b.logger.Warn("Credit above expected amount", "recipient", recipient, "expected", expected, "actual", actual, "gameAddr", game.Proxy, "duration", "reached") b.logger.Warn("Credit above expected amount", "recipient", recipient, "expected", expected, "actual", actual, "game", game.Proxy, "duration", "reached")
} else if comparison == 0 { } else if comparison == 0 {
creditMetrics[metrics.CreditEqualMaxDuration] += 1 creditMetrics[metrics.CreditEqualMaxDuration] += 1
} else { } else {
...@@ -105,12 +105,12 @@ func (b *Bonds) checkCredits(games []*types.EnrichedGameData) { ...@@ -105,12 +105,12 @@ func (b *Bonds) checkCredits(games []*types.EnrichedGameData) {
} else { } else {
if comparison > 0 { if comparison > 0 {
creditMetrics[metrics.CreditAboveNonMaxDuration] += 1 creditMetrics[metrics.CreditAboveNonMaxDuration] += 1
b.logger.Warn("Credit above expected amount", "recipient", recipient, "expected", expected, "actual", actual, "gameAddr", game.Proxy, "duration", "unreached") b.logger.Warn("Credit above expected amount", "recipient", recipient, "expected", expected, "actual", actual, "game", game.Proxy, "duration", "unreached")
} else if comparison == 0 { } else if comparison == 0 {
creditMetrics[metrics.CreditEqualNonMaxDuration] += 1 creditMetrics[metrics.CreditEqualNonMaxDuration] += 1
} else { } else {
creditMetrics[metrics.CreditBelowNonMaxDuration] += 1 creditMetrics[metrics.CreditBelowNonMaxDuration] += 1
b.logger.Warn("Credit withdrawn early", "recipient", recipient, "expected", expected, "actual", actual, "gameAddr", game.Proxy, "duration", "unreached") b.logger.Warn("Credit withdrawn early", "recipient", recipient, "expected", expected, "actual", actual, "game", game.Proxy, "duration", "unreached")
} }
} }
} }
......
...@@ -348,21 +348,21 @@ func TestCheckRecipientCredit(t *testing.T) { ...@@ -348,21 +348,21 @@ func TestCheckRecipientCredit(t *testing.T) {
require.NotNil(t, logs.FindLog( require.NotNil(t, logs.FindLog(
testlog.NewLevelFilter(log.LevelWarn), testlog.NewLevelFilter(log.LevelWarn),
testlog.NewMessageFilter("Credit withdrawn early"), testlog.NewMessageFilter("Credit withdrawn early"),
testlog.NewAttributesFilter("gameAddr", game1.Proxy.Hex()), testlog.NewAttributesFilter("game", game1.Proxy.Hex()),
testlog.NewAttributesFilter("recipient", addr2.Hex()), testlog.NewAttributesFilter("recipient", addr2.Hex()),
testlog.NewAttributesFilter("duration", "unreached"))) testlog.NewAttributesFilter("duration", "unreached")))
// addr3 is above expected // addr3 is above expected
require.NotNil(t, logs.FindLog( require.NotNil(t, logs.FindLog(
testlog.NewLevelFilter(log.LevelWarn), testlog.NewLevelFilter(log.LevelWarn),
testlog.NewMessageFilter("Credit above expected amount"), testlog.NewMessageFilter("Credit above expected amount"),
testlog.NewAttributesFilter("gameAddr", game1.Proxy.Hex()), testlog.NewAttributesFilter("game", game1.Proxy.Hex()),
testlog.NewAttributesFilter("recipient", addr3.Hex()), testlog.NewAttributesFilter("recipient", addr3.Hex()),
testlog.NewAttributesFilter("duration", "unreached"))) testlog.NewAttributesFilter("duration", "unreached")))
// addr4 is below expected before max duration, so warn about early withdrawal // addr4 is below expected before max duration, so warn about early withdrawal
require.NotNil(t, logs.FindLog( require.NotNil(t, logs.FindLog(
testlog.NewLevelFilter(log.LevelWarn), testlog.NewLevelFilter(log.LevelWarn),
testlog.NewMessageFilter("Credit withdrawn early"), testlog.NewMessageFilter("Credit withdrawn early"),
testlog.NewAttributesFilter("gameAddr", game1.Proxy.Hex()), testlog.NewAttributesFilter("game", game1.Proxy.Hex()),
testlog.NewAttributesFilter("recipient", addr4.Hex()), testlog.NewAttributesFilter("recipient", addr4.Hex()),
testlog.NewAttributesFilter("duration", "unreached"))) testlog.NewAttributesFilter("duration", "unreached")))
...@@ -373,7 +373,7 @@ func TestCheckRecipientCredit(t *testing.T) { ...@@ -373,7 +373,7 @@ func TestCheckRecipientCredit(t *testing.T) {
require.NotNil(t, logs.FindLog( require.NotNil(t, logs.FindLog(
testlog.NewLevelFilter(log.LevelWarn), testlog.NewLevelFilter(log.LevelWarn),
testlog.NewMessageFilter("Credit above expected amount"), testlog.NewMessageFilter("Credit above expected amount"),
testlog.NewAttributesFilter("gameAddr", game2.Proxy.Hex()), testlog.NewAttributesFilter("game", game2.Proxy.Hex()),
testlog.NewAttributesFilter("recipient", addr3.Hex()), testlog.NewAttributesFilter("recipient", addr3.Hex()),
testlog.NewAttributesFilter("duration", "reached"))) testlog.NewAttributesFilter("duration", "reached")))
// addr4 is correct // addr4 is correct
...@@ -384,7 +384,7 @@ func TestCheckRecipientCredit(t *testing.T) { ...@@ -384,7 +384,7 @@ func TestCheckRecipientCredit(t *testing.T) {
require.NotNil(t, logs.FindLog( require.NotNil(t, logs.FindLog(
testlog.NewLevelFilter(log.LevelWarn), testlog.NewLevelFilter(log.LevelWarn),
testlog.NewMessageFilter("Credit withdrawn early"), testlog.NewMessageFilter("Credit withdrawn early"),
testlog.NewAttributesFilter("gameAddr", game3.Proxy.Hex()), testlog.NewAttributesFilter("game", game3.Proxy.Hex()),
testlog.NewAttributesFilter("recipient", addr2.Hex()), testlog.NewAttributesFilter("recipient", addr2.Hex()),
testlog.NewAttributesFilter("duration", "unreached"))) testlog.NewAttributesFilter("duration", "unreached")))
// addr3 is not involved so no logs // addr3 is not involved so no logs
...@@ -392,7 +392,7 @@ func TestCheckRecipientCredit(t *testing.T) { ...@@ -392,7 +392,7 @@ func TestCheckRecipientCredit(t *testing.T) {
require.NotNil(t, logs.FindLog( require.NotNil(t, logs.FindLog(
testlog.NewLevelFilter(log.LevelWarn), testlog.NewLevelFilter(log.LevelWarn),
testlog.NewMessageFilter("Credit above expected amount"), testlog.NewMessageFilter("Credit above expected amount"),
testlog.NewAttributesFilter("gameAddr", game3.Proxy.Hex()), testlog.NewAttributesFilter("game", game3.Proxy.Hex()),
testlog.NewAttributesFilter("recipient", addr4.Hex()), testlog.NewAttributesFilter("recipient", addr4.Hex()),
testlog.NewAttributesFilter("duration", "unreached"))) testlog.NewAttributesFilter("duration", "unreached")))
...@@ -404,7 +404,7 @@ func TestCheckRecipientCredit(t *testing.T) { ...@@ -404,7 +404,7 @@ func TestCheckRecipientCredit(t *testing.T) {
require.NotNil(t, logs.FindLog( require.NotNil(t, logs.FindLog(
testlog.NewLevelFilter(log.LevelWarn), testlog.NewLevelFilter(log.LevelWarn),
testlog.NewMessageFilter("Credit above expected amount"), testlog.NewMessageFilter("Credit above expected amount"),
testlog.NewAttributesFilter("gameAddr", game4.Proxy.Hex()), testlog.NewAttributesFilter("game", game4.Proxy.Hex()),
testlog.NewAttributesFilter("recipient", addr4.Hex()), testlog.NewAttributesFilter("recipient", addr4.Hex()),
testlog.NewAttributesFilter("duration", "reached"))) testlog.NewAttributesFilter("duration", "reached")))
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment