From 01a75f2a19566a31c9883845a71785a304702aae Mon Sep 17 00:00:00 2001 From: amirylm Date: Mon, 27 Nov 2023 12:05:57 -0300 Subject: [PATCH] update String function --- pkg/v3/types/basetypes.go | 8 ++++++-- pkg/v3/types/basetypes_test.go | 5 ++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/pkg/v3/types/basetypes.go b/pkg/v3/types/basetypes.go index e463c386..bee3a8cb 100644 --- a/pkg/v3/types/basetypes.go +++ b/pkg/v3/types/basetypes.go @@ -13,6 +13,7 @@ const ( checkResultDelimiter = 0x09 ) +// checkResultStringTemplate is a JSON template, used for debugging purposes only. var checkResultStringTemplate = `{ "PipelineExecutionState":%d, "Retryable":%v, @@ -24,7 +25,8 @@ var checkResultStringTemplate = `{ "GasAllocated":%d, "PerformData":"%s", "FastGasWei":%s, - "LinkNative":%s + "LinkNative":%s, + "RetryInterval":%d }` func init() { @@ -232,11 +234,13 @@ func (r CheckResult) UniqueID() string { return fmt.Sprintf("%x", resultBytes) } +// NOTE: this function is used for debugging purposes only. +// for encoding check results, please use the Encoder interface func (r CheckResult) String() string { return fmt.Sprintf( checkResultStringTemplate, r.PipelineExecutionState, r.Retryable, r.Eligible, r.IneligibilityReason, r.UpkeepID, r.Trigger, r.WorkID, r.GasAllocated, - hex.EncodeToString(r.PerformData), r.FastGasWei, r.LinkNative, + hex.EncodeToString(r.PerformData), r.FastGasWei, r.LinkNative, r.RetryInterval, ) } diff --git a/pkg/v3/types/basetypes_test.go b/pkg/v3/types/basetypes_test.go index 6e202704..233b2890 100644 --- a/pkg/v3/types/basetypes_test.go +++ b/pkg/v3/types/basetypes_test.go @@ -326,12 +326,11 @@ func TestCheckResultString(t *testing.T) { "GasAllocated":1001, "PerformData":"010203040506", "FastGasWei":12, - "LinkNative":13 + "LinkNative":13, + "RetryInterval":1 } ` assertJSONEqual(t, expected, result) - // removing fields that shouldn't be encoded - input.RetryInterval = 0 assertJSONContainsAllStructFields(t, result, input) }