@@ -120,43 +120,65 @@ void getEntityId(boolean create) {
120120 @ CsvSource (
121121 textBlock =
122122 """
123- 'abab', true, , 'abab'
124- '', true, , ''
125- , true, , ''
126- , false, 'abab', 'abab'
127- , false, '', ''
128- , false, , ''
123+ 'abab', , 'abab'
124+ , 'abab', 'abab'
125+ 'abab', 'efef', 'abab'
126+ , , ''
129127 """ )
130128 void updateContractResult (
131129 @ ConvertWith (HexToByteArrayConverter .class ) byte [] callData ,
132- boolean callDataInlined ,
133130 @ ConvertWith (HexToByteArrayConverter .class ) byte [] callDataInFile ,
134131 @ ConvertWith (HexToByteArrayConverter .class ) byte [] expectedFunctionParameters ) {
135132 // given
136133 var contractResult = new ContractResult ();
134+ boolean callDataInlined = callData != null ;
135+ var callDataId = callDataInFile != null ? domainBuilder .entityId () : null ;
137136 var ethereumTransaction = domainBuilder
138137 .ethereumTransaction (callDataInlined )
139- .customize (e -> e .callData (callData ))
138+ .customize (e -> e .callData (callData ). callDataId ( callDataId ) )
140139 .get ();
141140 var recordItem = recordItemBuilder
142141 .ethereumTransaction ()
143142 .recordItem (r -> r .blockstream (true ).ethereumTransaction (ethereumTransaction ))
144143 .build ();
145- if (!callDataInlined ) {
146- doReturn (callDataInFile ).when (contractBytecodeService ).get (ethereumTransaction .getCallDataId ());
144+ boolean expectCallDataFromFile = !callDataInlined && callDataId != null ;
145+ if (expectCallDataFromFile ) {
146+ doReturn (callDataInFile ).when (contractBytecodeService ).get (callDataId );
147147 }
148148
149149 // when
150150 transactionHandler .updateContractResult (contractResult , recordItem );
151151
152152 // then
153- verify (contractBytecodeService , times (callDataInlined ? 0 : 1 )).get (any (EntityId .class ));
153+ verify (contractBytecodeService , times (expectCallDataFromFile ? 1 : 0 )).get (any (EntityId .class ));
154154 assertThat (contractResult )
155155 .returns (new BigInteger (ethereumTransaction .getValue ()).longValue (), ContractResult ::getAmount )
156156 .returns (expectedFunctionParameters , ContractResult ::getFunctionParameters )
157157 .returns (ethereumTransaction .getGasLimit (), ContractResult ::getGasLimit );
158158 }
159159
160+ @ Test
161+ void updateContractResultWithNullFromCallDataId () {
162+ // given
163+ var contractResult = new ContractResult ();
164+ var ethereumTransaction = domainBuilder .ethereumTransaction (false ).get ();
165+ var recordItem = recordItemBuilder
166+ .ethereumTransaction ()
167+ .recordItem (r -> r .blockstream (true ).ethereumTransaction (ethereumTransaction ))
168+ .build ();
169+ doReturn (null ).when (contractBytecodeService ).get (ethereumTransaction .getCallDataId ());
170+
171+ // when
172+ transactionHandler .updateContractResult (contractResult , recordItem );
173+
174+ // then
175+ verify (contractBytecodeService ).get (ethereumTransaction .getCallDataId ());
176+ assertThat (contractResult )
177+ .returns (new BigInteger (ethereumTransaction .getValue ()).longValue (), ContractResult ::getAmount )
178+ .returns (EMPTY_BYTE_ARRAY , ContractResult ::getFunctionParameters )
179+ .returns (ethereumTransaction .getGasLimit (), ContractResult ::getGasLimit );
180+ }
181+
160182 @ Test
161183 void updateContractResultNullEthereumTransaction () {
162184 // given
0 commit comments