From ae3a02f55301f27fef247263d643c68d31c74940 Mon Sep 17 00:00:00 2001 From: vyzo Date: Tue, 28 Apr 2020 17:43:58 +0300 Subject: [PATCH] add test for rejections with ignore validator decision --- score_test.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/score_test.go b/score_test.go index 488132f..45e2356 100644 --- a/score_test.go +++ b/score_test.go @@ -594,6 +594,31 @@ func TestScoreRejectMessageDeliveries(t *testing.T) { time.Sleep(1 * time.Millisecond) ps.deliveries.gc() + // insert a record in the message deliveries + ps.ValidateMessage(&msg) + + // this should have no effect in the score, and subsequent duplicate messages should have no + // effect either + ps.RejectMessage(&msg, rejectValidationIgnored) + ps.DuplicateMessage(&msg2) + + aScore = ps.Score(peerA) + expected = 0.0 + if aScore != expected { + t.Fatalf("Score: %f. Expected %f", aScore, expected) + } + + bScore = ps.Score(peerB) + expected = 0.0 + if bScore != expected { + t.Fatalf("Score: %f. Expected %f", aScore, expected) + } + + // now clear the delivery record + ps.deliveries.head.expire = time.Now() + time.Sleep(1 * time.Millisecond) + ps.deliveries.gc() + // insert a new record in the message deliveries ps.ValidateMessage(&msg)