From 9b2edb2158113fef686e770bed628f4c276dcb14 Mon Sep 17 00:00:00 2001 From: amirylm Date: Thu, 22 Feb 2024 16:13:01 +0200 Subject: [PATCH] fix retry calculation test --- .../evmregistry/v21/mercury/mercury_test.go | 51 ++++++++++++------- 1 file changed, 34 insertions(+), 17 deletions(-) diff --git a/core/services/ocr2/plugins/ocr2keeper/evmregistry/v21/mercury/mercury_test.go b/core/services/ocr2/plugins/ocr2keeper/evmregistry/v21/mercury/mercury_test.go index 200c26482bc..dc95162b57b 100644 --- a/core/services/ocr2/plugins/ocr2keeper/evmregistry/v21/mercury/mercury_test.go +++ b/core/services/ocr2/plugins/ocr2keeper/evmregistry/v21/mercury/mercury_test.go @@ -248,35 +248,52 @@ func TestPacker_UnpackCheckCallbackResult(t *testing.T) { func Test_CalculateRetryConfigFn(t *testing.T) { tests := []struct { - name string - times int - expected time.Duration + name string + times int + upkeepType automationTypes.UpkeepType + expected time.Duration }{ { - name: "first retry", - times: 1, - expected: 1 * time.Second, + name: "log trigger first retry", + times: 1, + upkeepType: automationTypes.LogTrigger, + expected: 1 * time.Second, }, { - name: "second retry", - times: 2, - expected: 1 * time.Second, + name: "log trigger second retry", + times: 2, + upkeepType: automationTypes.LogTrigger, + expected: 1 * time.Second, }, { - name: "fifth retry", - times: 5, - expected: 1 * time.Second, + name: "log trigger fifth retry", + times: 5, + upkeepType: automationTypes.LogTrigger, + expected: 1 * time.Second, }, { - name: "sixth retry", - times: 6, - expected: 5 * time.Second, + name: "log trigger sixth retry", + times: 6, + upkeepType: automationTypes.LogTrigger, + expected: 5 * time.Second, }, { - name: "timeout", + name: "log trigger timeout", times: totalMediumPluginRetries + 1, expected: RetryIntervalTimeout, }, + { + name: "conditional trigger first retry", + times: 1, + upkeepType: automationTypes.ConditionTrigger, + expected: RetryIntervalTimeout, + }, + { + name: "conditional trigger timeout", + times: totalMediumPluginRetries + 1, + upkeepType: automationTypes.ConditionTrigger, + expected: RetryIntervalTimeout, + }, } for _, tc := range tests { @@ -284,7 +301,7 @@ func Test_CalculateRetryConfigFn(t *testing.T) { cfg := newMercuryConfigMock() var result time.Duration for i := 0; i < tc.times; i++ { - result = CalculateStreamsRetryConfigFn(automationTypes.ConditionTrigger, "prk", cfg) + result = CalculateStreamsRetryConfigFn(tc.upkeepType, "prk", cfg) } assert.Equal(t, tc.expected, result) })