From 25bd7bb2ce10fd8ab0f0f0dbd2f4cdddff0eb544 Mon Sep 17 00:00:00 2001 From: Jordan Krage Date: Mon, 8 Jan 2024 15:33:43 -0600 Subject: [PATCH] fix TestOCR2TaskJobSpec_String --- core/services/job/testdata/compact.toml | 2 +- core/services/job/testdata/pretty.toml | 4 ++-- core/services/relay/evm/chain_reader.go | 5 ++--- core/services/relay/evm/chain_reader_test.go | 4 ++-- core/services/relay/evm/types/gen/main.go | 2 +- core/services/relay/evm/types/types.go | 2 +- integration-tests/actions/ocr2_helpers_local.go | 3 +++ .../client/chainlink_models_test.go | 16 +++++----------- 8 files changed, 17 insertions(+), 21 deletions(-) diff --git a/core/services/job/testdata/compact.toml b/core/services/job/testdata/compact.toml index a784895636d..10f9fdf0875 100644 --- a/core/services/job/testdata/compact.toml +++ b/core/services/job/testdata/compact.toml @@ -23,7 +23,7 @@ contractABI = "[\n {\n \"anonymous\": false,\n \"inputs\": [\n {\n [relayConfig.chainReader.contracts.median.configs] LatestRoundRequested = "{\n \"chainSpecificName\": \"RoundRequested\",\n \"readType\": \"event\"\n}\n" -LatestTransmissionDetails = "{\n \"chainSpecificName\": \"latestTransmissionDetails\",\n \"output_modifications\": [\n {\n \"Fields\": [\n \"LatestTimestamp_\"\n ],\n \"type\": \"epoch to time\"\n },\n {\n \"Fields\": {\n \"LatestAnswer_\": \"LatestAnswer\",\n \"LatestTimestamp_\": \"LatestTimestamp\"\n },\n \"type\": \"rename\"\n }\n ]\n}\n" +LatestTransmissionDetails = "{\n \"chainSpecificName\": \"latestTransmissionDetails\",\n \"output_modifications\": [\n {\n \"Fields\": [\n \"LatestTimestamp_\"\n ],\n \"Type\": \"epoch to time\"\n },\n {\n \"Fields\": {\n \"LatestAnswer_\": \"LatestAnswer\",\n \"LatestTimestamp_\": \"LatestTimestamp\"\n },\n \"Type\": \"rename\"\n }\n ]\n}\n" [relayConfig.codec] [relayConfig.codec.configs] diff --git a/core/services/job/testdata/pretty.toml b/core/services/job/testdata/pretty.toml index d4cd9c72803..def8ab29871 100644 --- a/core/services/job/testdata/pretty.toml +++ b/core/services/job/testdata/pretty.toml @@ -95,14 +95,14 @@ LatestTransmissionDetails = ''' "Fields": [ "LatestTimestamp_" ], - "type": "epoch to time" + "Type": "epoch to time" }, { "Fields": { "LatestAnswer_": "LatestAnswer", "LatestTimestamp_": "LatestTimestamp" }, - "type": "rename" + "Type": "rename" } ] } diff --git a/core/services/relay/evm/chain_reader.go b/core/services/relay/evm/chain_reader.go index 31e4c0b4468..b1d95adfa89 100644 --- a/core/services/relay/evm/chain_reader.go +++ b/core/services/relay/evm/chain_reader.go @@ -7,7 +7,6 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi" - "github.com/smartcontractkit/chainlink-common/pkg/codec" commonservices "github.com/smartcontractkit/chainlink-common/pkg/services" commontypes "github.com/smartcontractkit/chainlink-common/pkg/types" @@ -190,7 +189,7 @@ func (cr *chainReader) addEncoderDef(contractName, methodName string, args abi.A return err } - inputMod, err := (*codec.ModifiersConfig)(&chainReaderDefinition.InputModifications).ToModifier(evmDecoderHooks...) + inputMod, err := chainReaderDefinition.InputModifications.ToModifier(evmDecoderHooks...) if err != nil { return err } @@ -201,7 +200,7 @@ func (cr *chainReader) addEncoderDef(contractName, methodName string, args abi.A func (cr *chainReader) addDecoderDef(contractName, methodName string, outputs abi.Arguments, def types.ChainReaderDefinition) error { output := &codecEntry{Args: outputs} - mod, err := (*codec.ModifiersConfig)(&def.OutputModifications).ToModifier(evmDecoderHooks...) + mod, err := def.OutputModifications.ToModifier(evmDecoderHooks...) if err != nil { return err } diff --git a/core/services/relay/evm/chain_reader_test.go b/core/services/relay/evm/chain_reader_test.go index 51ea24cb219..dfe92ef7090 100644 --- a/core/services/relay/evm/chain_reader_test.go +++ b/core/services/relay/evm/chain_reader_test.go @@ -78,7 +78,7 @@ func (it *chainReaderInterfaceTester) Setup(t *testing.T) { Contracts: map[string]types.ChainContractReader{ AnyContractName: { ContractABI: chain_reader_example.LatestValueHolderMetaData.ABI, - Configs: map[string]types.ChainReaderDefinition{ + Configs: map[string]*types.ChainReaderDefinition{ MethodTakingLatestParamsReturningTestStruct: { ChainSpecificName: "GetElementAtIndex", }, @@ -114,7 +114,7 @@ func (it *chainReaderInterfaceTester) Setup(t *testing.T) { }, AnySecondContractName: { ContractABI: chain_reader_example.LatestValueHolderMetaData.ABI, - Configs: map[string]types.ChainReaderDefinition{ + Configs: map[string]*types.ChainReaderDefinition{ MethodReturningUint64: { ChainSpecificName: "GetDifferentPrimitiveValue", }, diff --git a/core/services/relay/evm/types/gen/main.go b/core/services/relay/evm/types/gen/main.go index 7bd35bf3d18..6253c6d282d 100644 --- a/core/services/relay/evm/types/gen/main.go +++ b/core/services/relay/evm/types/gen/main.go @@ -49,7 +49,7 @@ func runTemplate(name, rawTemplate, outputFile string, input any) { panic(err) } - res, err := format.Source([]byte(br.Bytes())) + res, err := format.Source(br.Bytes()) if err != nil { panic(err) } diff --git a/core/services/relay/evm/types/types.go b/core/services/relay/evm/types/types.go index b8a0bd04902..19925bd8f84 100644 --- a/core/services/relay/evm/types/types.go +++ b/core/services/relay/evm/types/types.go @@ -31,7 +31,7 @@ type CodecConfig struct { type ChainCodecConfig struct { TypeABI string `json:"typeAbi" toml:"typeABI"` - ModifierConfigs codec.ModifiersConfig `toml:"modifierConfigs,omitempty"` + ModifierConfigs codec.ModifiersConfig `toml:"modifierConfigs,omitempty"` //TODO test this? } type ChainContractReader struct { diff --git a/integration-tests/actions/ocr2_helpers_local.go b/integration-tests/actions/ocr2_helpers_local.go index 49c5bfb5c05..8a0a02c050f 100644 --- a/integration-tests/actions/ocr2_helpers_local.go +++ b/integration-tests/actions/ocr2_helpers_local.go @@ -137,6 +137,9 @@ func CreateOCRv2JobsLocal( "LatestTransmissionDetails": { ChainSpecificName: "latestTransmissionDetails", OutputModifications: codec.ModifiersConfig{ + &codec.EpochToTimeModifierConfig{ + Fields: []string{"LatestTimestamp_"}, + }, &codec.RenameModifierConfig{ Fields: map[string]string{ "LatestAnswer_": "LatestAnswer", diff --git a/integration-tests/client/chainlink_models_test.go b/integration-tests/client/chainlink_models_test.go index 4178b1da2af..5dbac2c27c4 100644 --- a/integration-tests/client/chainlink_models_test.go +++ b/integration-tests/client/chainlink_models_test.go @@ -46,6 +46,9 @@ func TestOCR2TaskJobSpec_String(t *testing.T) { "LatestTransmissionDetails": { ChainSpecificName: "latestTransmissionDetails", OutputModifications: codec.ModifiersConfig{ + &codec.EpochToTimeModifierConfig{ + Fields: []string{"LatestTimestamp_"}, + }, &codec.RenameModifierConfig{ Fields: map[string]string{ "LatestAnswer_": "LatestAnswer", @@ -112,17 +115,8 @@ fromBlock = 42 contractABI = "[\n {\n \"anonymous\": false,\n \"inputs\": [\n {\n \"indexed\": true,\n \"internalType\": \"address\",\n \"name\": \"requester\",\n \"type\": \"address\"\n }\n ],\n \"name\": \"RoundRequested\",\n \"type\": \"event\"\n }\n]\n" [relayConfig.chainReader.contracts.median.configs] -[relayConfig.chainReader.contracts.median.configs.LatestRoundRequested] -chainSpecificName = 'RoundRequested' -readType = 'event' - -[relayConfig.chainReader.contracts.median.configs.LatestTransmissionDetails] -chainSpecificName = 'latestTransmissionDetails' - -[[relayConfig.chainReader.contracts.median.configs.LatestTransmissionDetails.outputModifications]] -[relayConfig.chainReader.contracts.median.configs.LatestTransmissionDetails.outputModifications.Fields] -LatestAnswer_ = 'LatestAnswer' -LatestTimestamp_ = 'LatestTimestamp' +LatestRoundRequested = "{\n \"chainSpecificName\": \"RoundRequested\",\n \"readType\": \"event\"\n}\n" +LatestTransmissionDetails = "{\n \"chainSpecificName\": \"latestTransmissionDetails\",\n \"output_modifications\": [\n {\n \"Fields\": [\n \"LatestTimestamp_\"\n ],\n \"Type\": \"epoch to time\"\n },\n {\n \"Fields\": {\n \"LatestAnswer_\": \"LatestAnswer\",\n \"LatestTimestamp_\": \"LatestTimestamp\"\n },\n \"Type\": \"rename\"\n }\n ]\n}\n" [relayConfig.codec] [relayConfig.codec.configs]