From 2dd8974e3650798111d789a0fc8d44aa4c05ba44 Mon Sep 17 00:00:00 2001 From: Silas Lenihan Date: Thu, 3 Oct 2024 14:47:01 -0400 Subject: [PATCH] Added nil err check --- .../relay/evm/evmtesting/run_tests.go | 2 +- core/services/relay/evm/read/event.go | 32 +++++++++++-------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/core/services/relay/evm/evmtesting/run_tests.go b/core/services/relay/evm/evmtesting/run_tests.go index 50a949c3557..ecfbb78d5d8 100644 --- a/core/services/relay/evm/evmtesting/run_tests.go +++ b/core/services/relay/evm/evmtesting/run_tests.go @@ -151,7 +151,7 @@ func RunContractReaderEvmTests[T TestingT[T]](t T, it *EVMChainComponentsInterfa func RunContractReaderInLoopTests[T TestingT[T]](t T, it ChainComponentsInterfaceTester[T]) { RunContractReaderInterfaceTests[T](t, it, false) - + it.Setup(t) ctx := tests.Context(t) cr := it.GetContractReader(t) diff --git a/core/services/relay/evm/read/event.go b/core/services/relay/evm/read/event.go index b73a0608974..0c9db210ae4 100644 --- a/core/services/relay/evm/read/event.go +++ b/core/services/relay/evm/read/event.go @@ -240,17 +240,19 @@ func (b *EventBinding) GetLatestValue(ctx context.Context, address common.Addres ) defer func() { - callErr := newErrorFromCall(err, Call{ - ContractAddress: address, - ContractName: b.contractName, - MethodName: b.eventName, - Params: params, - ReturnVal: into, - }, strconv.Itoa(int(confs)), false) + if err != nil { + callErr := newErrorFromCall(err, Call{ + ContractAddress: address, + ContractName: b.contractName, + MethodName: b.eventName, + Params: params, + ReturnVal: into, + }, strconv.Itoa(int(confs)), false) - callErr.Result = result + callErr.Result = result - err = callErr + err = callErr + } }() if err = b.validateBound(address); err != nil { @@ -303,11 +305,13 @@ func (b *EventBinding) GetLatestValue(ctx context.Context, address common.Addres func (b *EventBinding) QueryKey(ctx context.Context, address common.Address, filter query.KeyFilter, limitAndSort query.LimitAndSort, sequenceDataType any) (sequences []commontypes.Sequence, err error) { defer func() { - err = newErrorFromCall(err, Call{ - ContractAddress: address, - ContractName: b.contractName, - MethodName: b.eventName, - }, "", false) + if err != nil { + err = newErrorFromCall(err, Call{ + ContractAddress: address, + ContractName: b.contractName, + MethodName: b.eventName, + }, "", false) + } }() if err = b.validateBound(address); err != nil {