Skip to content

Commit

Permalink
update String function
Browse files Browse the repository at this point in the history
  • Loading branch information
amirylm committed Nov 27, 2023
1 parent c071bfa commit 01a75f2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
8 changes: 6 additions & 2 deletions pkg/v3/types/basetypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const (
checkResultDelimiter = 0x09
)

// checkResultStringTemplate is a JSON template, used for debugging purposes only.
var checkResultStringTemplate = `{
"PipelineExecutionState":%d,
"Retryable":%v,
Expand All @@ -24,7 +25,8 @@ var checkResultStringTemplate = `{
"GasAllocated":%d,
"PerformData":"%s",
"FastGasWei":%s,
"LinkNative":%s
"LinkNative":%s,
"RetryInterval":%d
}`

func init() {
Expand Down Expand Up @@ -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,
)
}

Expand Down
5 changes: 2 additions & 3 deletions pkg/v3/types/basetypes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit 01a75f2

Please sign in to comment.