diff --git a/core/services/job/wasm_file_spec_factory.go b/core/services/job/wasm_file_spec_factory.go index 12bb5471d8..b2e1d92ba3 100644 --- a/core/services/job/wasm_file_spec_factory.go +++ b/core/services/job/wasm_file_spec_factory.go @@ -78,9 +78,10 @@ func (w WasmFileSpecFactory) rawSpecAndShaFromWasm(wasm, config []byte) ([]byte, } func (w WasmFileSpecFactory) sha(wasm, config []byte) string { - sha := sha256.New() - sha.Write(wasm) - return fmt.Sprintf("%x", sha.Sum(config)) + sum := sha256.New() + sum.Write(wasm) + sum.Write(config) + return fmt.Sprintf("%x", sum.Sum(nil)) } var _ WorkflowSpecFactory = (*WasmFileSpecFactory)(nil) diff --git a/core/services/job/wasm_file_spec_factory_test.go b/core/services/job/wasm_file_spec_factory_test.go index 9334a66d76..0bc95f7f6b 100644 --- a/core/services/job/wasm_file_spec_factory_test.go +++ b/core/services/job/wasm_file_spec_factory_test.go @@ -3,6 +3,7 @@ package job_test import ( "crypto/sha256" "encoding/json" + "fmt" "os" "os/exec" "testing" @@ -31,12 +32,13 @@ func TestWasmFileSpecFactory(t *testing.T) { rawBinary, err := os.ReadFile(binaryLocation) require.NoError(t, err) - expected, err := host.GetWorkflowSpec(&host.ModuleConfig{Logger: logger.NullLogger}, rawBinary, config) + expected, err := host.GetWorkflowSpec(&host.ModuleConfig{Logger: logger.NullLogger, IsUncompressed: true}, rawBinary, config) require.NoError(t, err) expectedSha := sha256.New() expectedSha.Write(rawBinary) - require.Equal(t, expectedSha.Sum(config), []byte(actualSha)) + expectedSha.Write(config) + require.Equal(t, fmt.Sprintf("%x", expectedSha.Sum(nil)), actualSha) require.Equal(t, *expected, actual) } @@ -44,7 +46,7 @@ func TestWasmFileSpecFactory(t *testing.T) { func createTestBinary(t *testing.T) string { const testBinaryLocation = "testdata/wasm/testmodule.wasm" - cmd := exec.Command("go", "build", "-o", testBinaryLocation, "github.com/smartcontractkit/chainlink/v2/core/services/job/testdata/wasm") + cmd := exec.Command("go1.22.7", "build", "-o", testBinaryLocation, "github.com/smartcontractkit/chainlink/v2/core/services/job/testdata/wasm") cmd.Env = append(os.Environ(), "GOOS=wasip1", "GOARCH=wasm") output, err := cmd.CombinedOutput() diff --git a/core/services/job/yaml_spec_factory_test.go b/core/services/job/yaml_spec_factory_test.go index b37c3efeed..c12d4872d9 100644 --- a/core/services/job/yaml_spec_factory_test.go +++ b/core/services/job/yaml_spec_factory_test.go @@ -2,6 +2,7 @@ package job_test import ( "crypto/sha256" + "fmt" "testing" "github.com/stretchr/testify/assert" @@ -74,5 +75,5 @@ func TestYamlSpecFactory_GetSpec(t *testing.T) { require.NoError(t, err) require.Equal(t, expected, actual) - assert.Equal(t, sha256.Sum256([]byte(anyYamlSpec)), actualSha) + assert.Equal(t, fmt.Sprintf("%x", sha256.Sum256([]byte(anyYamlSpec))), actualSha) }