Skip to content

Commit

Permalink
deprecation: replace calls to isEqualToComparingFieldByField (hyperle…
Browse files Browse the repository at this point in the history
…dger#3042)

* replace isEqualToComparingFieldByField with usingRecursiveComparison().isEqualTo

Signed-off-by: Sally MacFarlane <sally.macfarlane@consensys.net>

* isEqualTo()

Signed-off-by: Sally MacFarlane <sally.macfarlane@consensys.net>

* revert ibft and qbft tests back to compareFieldByField

Signed-off-by: Sally MacFarlane <sally.macfarlane@consensys.net>

* revert tests back to compareFieldByField

Signed-off-by: Sally MacFarlane <sally.macfarlane@consensys.net>
  • Loading branch information
macfarla authored and eum602 committed Nov 3, 2023
1 parent 42b9add commit d6f6609
Show file tree
Hide file tree
Showing 83 changed files with 297 additions and 282 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ public PrivGetPrivateTransactionSuccess(
@Override
public void verify(final Node node) {
final PrivateTransactionGroupResponse result = node.execute(transaction);
assertThat(result).isEqualToComparingFieldByField(privateTransaction);
assertThat(result).usingRecursiveComparison().isEqualTo(privateTransaction);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public void aliceCanUsePrivDistributeTransaction() {
bobEnclave.receive(
Bytes.fromHexString(transactionKey).toBase64String(), bob.getEnclaveKey());

assertThat(bobRR).isEqualToComparingFieldByField(aliceRR);
assertThat(bobRR).usingRecursiveComparison().isEqualTo(aliceRR);

final RawTransaction pmt =
RawTransaction.createTransaction(
Expand Down
12 changes: 8 additions & 4 deletions besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,8 @@ public void nodePermissionsSmartContractMustUseOption() {
final PermissioningConfiguration config =
permissioningConfigurationArgumentCaptor.getValue().get();
assertThat(config.getSmartContractConfig().get())
.isEqualToComparingFieldByField(smartContractPermissioningConfiguration);
.usingRecursiveComparison()
.isEqualTo(smartContractPermissioningConfiguration);

assertThat(commandErrorOutput.toString()).isEmpty();
assertThat(commandOutput.toString()).isEmpty();
Expand All @@ -487,7 +488,8 @@ public void nodePermissionsContractVersionDefaultValue() {
final PermissioningConfiguration config =
permissioningConfigurationArgumentCaptor.getValue().get();
assertThat(config.getSmartContractConfig().get())
.isEqualToComparingFieldByField(expectedConfig);
.usingRecursiveComparison()
.isEqualTo(expectedConfig);

assertThat(commandErrorOutput.toString()).isEmpty();
assertThat(commandOutput.toString()).isEmpty();
Expand Down Expand Up @@ -516,7 +518,8 @@ public void nodePermissionsContractVersionSetsValue() {
final PermissioningConfiguration config =
permissioningConfigurationArgumentCaptor.getValue().get();
assertThat(config.getSmartContractConfig().get())
.isEqualToComparingFieldByField(expectedConfig);
.usingRecursiveComparison()
.isEqualTo(expectedConfig);

assertThat(commandErrorOutput.toString()).isEmpty();
assertThat(commandOutput.toString()).isEmpty();
Expand Down Expand Up @@ -718,7 +721,8 @@ public void nodePermissioningTomlPathMustUseOption() throws IOException {
final PermissioningConfiguration config =
permissioningConfigurationArgumentCaptor.getValue().get();
assertThat(config.getLocalConfig().get())
.isEqualToComparingFieldByField(localPermissioningConfiguration);
.usingRecursiveComparison()
.isEqualTo(localPermissioningConfiguration);

assertThat(commandErrorOutput.toString()).isEmpty();
assertThat(commandOutput.toString()).isEmpty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private void getCLIOptions(final D domainObject) {
final TestBesuCommand cmd = parseCommand(cliOptions);
final T optionsFromCommand = getOptionsFromBesuCommand(cmd);

assertThat(optionsFromCommand).isEqualToComparingFieldByField(options);
assertThat(optionsFromCommand).usingRecursiveComparison().isEqualTo(options);

assertThat(commandOutput.toString()).isEmpty();
assertThat(commandErrorOutput.toString()).isEmpty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ public void aBlockTimerExpiryEventIsAddedToTheQueueOnExpiry() throws Interrupted
final BftEvent queuedEvent = eventQueue.poll(0, TimeUnit.SECONDS);
assertThat(queuedEvent).isInstanceOf(BlockTimerExpiry.class);
assertThat(((BlockTimerExpiry) queuedEvent).getRoundIndentifier())
.isEqualToComparingFieldByField(round);
.usingRecursiveComparison()
.isEqualTo(round);
}

@Test
Expand Down Expand Up @@ -169,7 +170,8 @@ public void eventIsImmediatelyAddedToTheQueueIfAbsoluteExpiryIsEqualToNow() {

assertThat(bftEventCaptor.getValue() instanceof BlockTimerExpiry).isTrue();
assertThat(((BlockTimerExpiry) bftEventCaptor.getValue()).getRoundIndentifier())
.isEqualToComparingFieldByField(round);
.usingRecursiveComparison()
.isEqualTo(round);
}

@Test
Expand Down Expand Up @@ -198,7 +200,8 @@ public void eventIsImmediatelyAddedToTheQueueIfAbsoluteExpiryIsInThePast() {

assertThat(bftEventCaptor.getValue() instanceof BlockTimerExpiry).isTrue();
assertThat(((BlockTimerExpiry) bftEventCaptor.getValue()).getRoundIndentifier())
.isEqualToComparingFieldByField(round);
.usingRecursiveComparison()
.isEqualTo(round);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void testConversionFromVoteTypeToBoolean() {

final JsonRpcResponse response = getMethod().response(request);

assertThat(response).isEqualToComparingFieldByField(expectedResponse);
assertThat(response).usingRecursiveComparison().isEqualTo(expectedResponse);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public void testCreateDeleteRetrievePrivacyGroup() {
final PrivacyGroup retrievePrivacyGroup =
enclave.retrievePrivacyGroup(privacyGroupResponse.getPrivacyGroupId());

assertThat(retrievePrivacyGroup).isEqualToComparingFieldByField(privacyGroupResponse);
assertThat(retrievePrivacyGroup).usingRecursiveComparison().isEqualTo(privacyGroupResponse);

final String response =
enclave.deletePrivacyGroup(privacyGroupResponse.getPrivacyGroupId(), publicKeys.get(0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,6 @@ public void debugTraceTransactionMissingTest() {
final JsonRpcResponse expectedResponse = new JsonRpcSuccessResponse(null, null);

final JsonRpcResponse response = method.response(request);
assertThat(response).isEqualToComparingFieldByField(expectedResponse);
assertThat(response).usingRecursiveComparison().isEqualTo(expectedResponse);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public void shouldReturnExpectedResultForCallAtLatestBlock() {

final JsonRpcResponse response = method.response(request);

assertThat(response).isEqualToComparingFieldByField(expectedResponse);
assertThat(response).usingRecursiveComparison().isEqualTo(expectedResponse);
}

@Test
Expand All @@ -107,7 +107,7 @@ public void shouldReturnExpectedResultForCallAtSpecificBlock() {

final JsonRpcResponse response = method.response(request);

assertThat(response).isEqualToComparingFieldByField(expectedResponse);
assertThat(response).usingRecursiveComparison().isEqualTo(expectedResponse);
}

@Test
Expand Down Expand Up @@ -152,7 +152,7 @@ public void shouldReturnErrorWithGasLimitTooLow() {

final JsonRpcResponse response = method.response(request);

assertThat(response).isEqualToComparingFieldByField(expectedResponse);
assertThat(response).usingRecursiveComparison().isEqualTo(expectedResponse);
}

@Test
Expand All @@ -174,7 +174,7 @@ public void shouldReturnErrorWithGasPriceTooHighAndStrict() {

final JsonRpcResponse response = method.response(request);

assertThat(response).isEqualToComparingFieldByField(expectedResponse);
assertThat(response).usingRecursiveComparison().isEqualTo(expectedResponse);
}

@Test
Expand All @@ -197,7 +197,7 @@ public void shouldReturnSuccessWithGasPriceTooHighNotStrict() {

final JsonRpcResponse response = method.response(request);

assertThat(response).isEqualToComparingFieldByField(expectedResponse);
assertThat(response).usingRecursiveComparison().isEqualTo(expectedResponse);
}

@Test
Expand All @@ -219,7 +219,7 @@ public void shouldReturnErrorWithGasPriceTooHigh() {

final JsonRpcResponse response = method.response(request);

assertThat(response).isEqualToComparingFieldByField(expectedResponse);
assertThat(response).usingRecursiveComparison().isEqualTo(expectedResponse);
}

@Test
Expand All @@ -242,7 +242,7 @@ public void shouldReturnSuccessWithValidGasPrice() {

final JsonRpcResponse response = method.response(request);

assertThat(response).isEqualToComparingFieldByField(expectedResponse);
assertThat(response).usingRecursiveComparison().isEqualTo(expectedResponse);
}

@Test
Expand All @@ -264,7 +264,7 @@ public void shouldReturnErrorWithGasPriceAndEmptyBalance() {

final JsonRpcResponse response = method.response(request);

assertThat(response).isEqualToComparingFieldByField(expectedResponse);
assertThat(response).usingRecursiveComparison().isEqualTo(expectedResponse);
}

@Test
Expand All @@ -287,7 +287,7 @@ public void shouldReturnSuccessWithZeroGasPriceAndEmptyBalance() {

final JsonRpcResponse response = method.response(request);

assertThat(response).isEqualToComparingFieldByField(expectedResponse);
assertThat(response).usingRecursiveComparison().isEqualTo(expectedResponse);
}

@Test
Expand All @@ -310,7 +310,7 @@ public void shouldReturnSuccessWithoutGasPriceAndEmptyBalance() {

final JsonRpcResponse response = method.response(request);

assertThat(response).isEqualToComparingFieldByField(expectedResponse);
assertThat(response).usingRecursiveComparison().isEqualTo(expectedResponse);
}

@Test
Expand All @@ -333,7 +333,7 @@ public void shouldReturnSuccessWithInvalidGasPricingAndEmptyBalance() {

final JsonRpcResponse response = method.response(request);

assertThat(response).isEqualToComparingFieldByField(expectedResponse);
assertThat(response).usingRecursiveComparison().isEqualTo(expectedResponse);
}

@Test
Expand All @@ -354,7 +354,7 @@ public void shouldReturnEmptyHashResultForCallWithOnlyToField() {

final JsonRpcResponse response = method.response(request);

assertThat(response).isEqualToComparingFieldByField(expectedResponse);
assertThat(response).usingRecursiveComparison().isEqualTo(expectedResponse);
}

private JsonRpcRequestContext requestWithParams(final Object... params) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void returnEmptyResponseIfBlockNotFound() {
final JsonRpcMethod method = ethGetBlockByHash();
final JsonRpcResponse actual = method.response(requestWithParams(ZERO_HASH, true));

assertThat(actual).isEqualToComparingFieldByField(expected);
assertThat(actual).usingRecursiveComparison().isEqualTo(expected);
}

@Test
Expand Down Expand Up @@ -196,7 +196,7 @@ public void returnTransactionHashOnlyIfBlockFound() {
"0x10aaf14a53caf27552325374429d3558398a36d3682ede6603c2c6511896e9f9", false);
final JsonRpcResponse actual = ethGetBlockByHash().response(request);

assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected);
assertThat(actual).usingRecursiveComparison().isEqualTo(expected);
}

private JsonRpcRequestContext requestWithParams(final Object... params) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public void shouldReturnErrorResponseIfFilterNotFound() {
final JsonRpcResponse expected = new JsonRpcErrorResponse(null, JsonRpcError.FILTER_NOT_FOUND);
final JsonRpcResponse actual = method.response(request);

assertThat(actual).isEqualToComparingFieldByField(expected);
assertThat(actual).usingRecursiveComparison().isEqualTo(expected);
}

@Test
Expand All @@ -159,7 +159,7 @@ public void shouldReturnEmptyArrayIfNoNewBlocks() {
final JsonRpcSuccessResponse expected = new JsonRpcSuccessResponse(null, Lists.emptyList());
final JsonRpcResponse actual = method.response(request);

assertThat(actual).isEqualToComparingFieldByField(expected);
assertThat(actual).usingRecursiveComparison().isEqualTo(expected);

filterManager.uninstallFilter(filterId);

Expand All @@ -177,7 +177,7 @@ public void shouldReturnEmptyArrayIfNoAddedPendingTransactions() {
// We haven't added any transactions, so the list of pending transactions should be empty.
final JsonRpcSuccessResponse expected = new JsonRpcSuccessResponse(null, Lists.emptyList());
final JsonRpcResponse actual = method.response(request);
assertThat(actual).isEqualToComparingFieldByField(expected);
assertThat(actual).usingRecursiveComparison().isEqualTo(expected);

filterManager.uninstallFilter(filterId);

Expand All @@ -195,19 +195,19 @@ public void shouldReturnHashesIfNewBlocks() {
// We haven't added any blocks, so the list of new blocks should be empty.
JsonRpcSuccessResponse expected = new JsonRpcSuccessResponse(null, Lists.emptyList());
JsonRpcResponse actual = method.response(request);
assertThat(actual).isEqualToComparingFieldByField(expected);
assertThat(actual).usingRecursiveComparison().isEqualTo(expected);

final Block block = appendBlock(transaction);

// We've added one block, so there should be one new hash.
expected = new JsonRpcSuccessResponse(null, Lists.newArrayList(block.getHash().toString()));
actual = method.response(request);
assertThat(actual).isEqualToComparingFieldByField(expected);
assertThat(actual).usingRecursiveComparison().isEqualTo(expected);

// The queue should be flushed and return no results.
expected = new JsonRpcSuccessResponse(null, Lists.emptyList());
actual = method.response(request);
assertThat(actual).isEqualToComparingFieldByField(expected);
assertThat(actual).usingRecursiveComparison().isEqualTo(expected);

filterManager.uninstallFilter(filterId);

Expand All @@ -225,20 +225,20 @@ public void shouldReturnHashesIfNewPendingTransactions() {
// We haven't added any transactions, so the list of pending transactions should be empty.
JsonRpcSuccessResponse expected = new JsonRpcSuccessResponse(null, Lists.emptyList());
JsonRpcResponse actual = method.response(request);
assertThat(actual).isEqualToComparingFieldByField(expected);
assertThat(actual).usingRecursiveComparison().isEqualTo(expected);

transactions.addRemoteTransaction(transaction);

// We've added one transaction, so there should be one new hash.
expected =
new JsonRpcSuccessResponse(null, Lists.newArrayList(String.valueOf(transaction.getHash())));
actual = method.response(request);
assertThat(actual).isEqualToComparingFieldByField(expected);
assertThat(actual).usingRecursiveComparison().isEqualTo(expected);

// The queue should be flushed and return no results.
expected = new JsonRpcSuccessResponse(null, Lists.emptyList());
actual = method.response(request);
assertThat(actual).isEqualToComparingFieldByField(expected);
assertThat(actual).usingRecursiveComparison().isEqualTo(expected);

filterManager.uninstallFilter(filterId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,6 @@ public void shouldGetExpectedBlockResult() {
final JsonRpcResponse actual = method.response(request);

assertThat(actual).isInstanceOf(JsonRpcSuccessResponse.class);
assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected);
assertThat(actual).usingRecursiveComparison().isEqualTo(expected);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public void shouldGetExpectedBlockResult() {

final JsonRpcSuccessResponse actual = (JsonRpcSuccessResponse) method.response(request);

assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected);
assertThat(actual).usingRecursiveComparison().isEqualTo(expected);
}

private JsonRpcRequestContext getUncleByBlockNumberAndIndex() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ public void returnsStoredPrivateTransaction() {
(PrivateTransactionLegacyResult) response.getResult();

assertThat(new PrivateTransactionLegacyResult(this.privateTransaction))
.isEqualToComparingFieldByField(result);
.usingRecursiveComparison()
.isEqualTo(result);
}
}
Loading

0 comments on commit d6f6609

Please sign in to comment.