Skip to content

Commit

Permalink
chore: moved this to chainlink repo
Browse files Browse the repository at this point in the history
  • Loading branch information
agparadiso committed Jan 8, 2025
1 parent 652c9e1 commit 6cfff8e
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 40 deletions.
13 changes: 0 additions & 13 deletions pkg/workflows/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"crypto/sha256"
"encoding/hex"
"strings"

"github.com/smartcontractkit/chainlink-common/pkg/logger"
)

func EncodeExecutionID(workflowID, eventID string) (string, error) {
Expand Down Expand Up @@ -86,14 +84,3 @@ func HashTruncateName(name string) [10]byte {

return result
}

// HexDecodeWorkflowName makes the best effort to decode the hex workflow name.
// In case of failure it will log the error and return the input name.
func HexDecodeWorkflowName(encoded string, logger logger.Logger) string {
decoded, err := hex.DecodeString(encoded)
if err != nil {
logger.Errorf("failed to decode WorkflowName %q: %v", encoded, err)
return encoded
}
return string(decoded)
}
27 changes: 0 additions & 27 deletions pkg/workflows/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/hex"
"testing"

"github.com/smartcontractkit/chainlink-common/pkg/logger"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -100,29 +99,3 @@ func TestNormalizeWorkflowName(t *testing.T) {
})
}
}

func TestHexDecodeWorkflowName(t *testing.T) {
tt := []struct {
name string
input string
expected string
}{
{
name: "OK-correct_workflow_name",
input: "776f726b666c6f772d6e616d65",
expected: "workflow-name",
},
{
name: "NOK-incorrect_workflow_name",
input: "776f726b666c6f772d6e616d65!",
expected: "776f726b666c6f772d6e616d65!",
},
}

for _, tc := range tt {
t.Run(tc.name, func(t *testing.T) {
result := HexDecodeWorkflowName(tc.input, logger.TestSugared(t))
require.Equal(t, tc.expected, result)
})
}
}

0 comments on commit 6cfff8e

Please sign in to comment.