Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deprecation: replace calls to isEqualToComparingFieldByField #3042

Merged
merged 6 commits into from
Nov 15, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -210,6 +210,6 @@ private void verifyMessage(final MessageData actual, final BftMessage<?> expecte
fail("Illegal IBFTV2 message type.");
break;
}
assertThat(expectedMessage).isEqualToComparingFieldByFieldRecursively(actualSignedPayload);
assertThat(expectedMessage).usingRecursiveComparison().isEqualTo(actualSignedPayload);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public void emptyVoteAndListIsEncodedCorrectly() {
BftExtraData actualExtraData =
ibftExtraDataEncoder.decodeRaw(ibftExtraDataEncoder.encode(expectedExtraData));

assertThat(actualExtraData).isEqualToComparingFieldByField(expectedExtraData);
assertThat(actualExtraData).usingRecursiveComparison().isEqualTo(expectedExtraData);
}

@Test
Expand Down Expand Up @@ -255,7 +255,7 @@ public void emptyListsAreEncodedAndDecodedCorrectly() {
BftExtraData actualExtraData =
ibftExtraDataEncoder.decodeRaw(ibftExtraDataEncoder.encode(expectedExtraData));

assertThat(actualExtraData).isEqualToComparingFieldByField(expectedExtraData);
assertThat(actualExtraData).usingRecursiveComparison().isEqualTo(expectedExtraData);
}

@Test
Expand Down Expand Up @@ -322,7 +322,7 @@ public void fullyPopulatedDataIsEncodedAndDecodedCorrectly() {
final BftExtraData actualExtraData =
ibftExtraDataEncoder.decodeRaw(ibftExtraDataEncoder.encode(expectedExtraData));

assertThat(actualExtraData).isEqualToComparingFieldByField(expectedExtraData);
assertThat(actualExtraData).usingRecursiveComparison().isEqualTo(expectedExtraData);
}

@Test
Expand All @@ -340,7 +340,7 @@ public void decodingOfKnownRawHexStringMatchesKnowExtraDataObject() {
Bytes rawDecoding = Bytes.fromHexString(RAW_HEX_ENCODING_STRING);
BftExtraData actualExtraData = bftExtraDataEncoder.decodeRaw(rawDecoding);

assertThat(actualExtraData).isEqualToComparingFieldByField(expectedExtraData);
assertThat(actualExtraData).usingRecursiveComparison().isEqualTo(expectedExtraData);
}

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

final JsonRpcResponse response = method.response(request);

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

verify(voteProvider).discardVote(parameterAddress);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public void addValidator() {

final JsonRpcResponse response = method.response(request);

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

verify(voteProvider).authVote(parameterAddress);
}
Expand All @@ -118,7 +118,7 @@ public void removeValidator() {

final JsonRpcResponse response = method.response(request);

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

verify(voteProvider).dropVote(parameterAddress);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ public void roundTripRlp() {
actualPreparePayload.getRoundIdentifier();
final Hash actualDigest = actualPreparePayload.getDigest();
assertThat(actualConsensusRoundIdentifier)
.isEqualToComparingFieldByField(expectedRoundIdentifier);
.usingRecursiveComparison()
.isEqualTo(expectedRoundIdentifier);
assertThat(actualDigest).isEqualTo(digest);
assertThat(actualPreparePayload.getMessageType()).isEqualTo(IbftV2.PREPARE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,6 @@ private void verifyMessage(final MessageData actual, final BftMessage<?> expecte
fail("Illegal QBFTV1 message type.");
break;
}
assertThat(expectedMessage).isEqualToComparingFieldByFieldRecursively(actualSignedPayload);
assertThat(expectedMessage).usingRecursiveComparison().isEqualTo(actualSignedPayload);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public void emptyVoteAndListIsEncodedCorrectly() {
BftExtraData actualExtraData =
bftExtraDataCodec.decodeRaw(bftExtraDataCodec.encode(expectedExtraData));

assertThat(actualExtraData).isEqualToComparingFieldByField(expectedExtraData);
assertThat(actualExtraData).usingRecursiveComparison().isEqualTo(expectedExtraData);
}

@Test
Expand Down Expand Up @@ -255,7 +255,7 @@ public void emptyListsAreEncodedAndDecodedCorrectly() {
BftExtraData actualExtraData =
bftExtraDataCodec.decodeRaw(bftExtraDataCodec.encode(expectedExtraData));

assertThat(actualExtraData).isEqualToComparingFieldByField(expectedExtraData);
assertThat(actualExtraData).usingRecursiveComparison().isEqualTo(expectedExtraData);
}

@Test
Expand Down Expand Up @@ -321,7 +321,7 @@ public void fullyPopulatedDataIsEncodedAndDecodedCorrectly() {
BftExtraData actualExtraData =
bftExtraDataCodec.decodeRaw(bftExtraDataCodec.encode(expectedExtraData));

assertThat(actualExtraData).isEqualToComparingFieldByField(expectedExtraData);
assertThat(actualExtraData).usingRecursiveComparison().isEqualTo(expectedExtraData);
}

@Test
Expand All @@ -338,7 +338,7 @@ public void decodingOfKnownRawHexStringMatchesKnowExtraDataObject() {
Bytes rawDecoding = Bytes.fromHexString(RAW_HEX_ENCODING_STRING);
BftExtraData actualExtraData = bftExtraDataCodec.decodeRaw(rawDecoding);

assertThat(actualExtraData).isEqualToComparingFieldByField(expectedExtraData);
assertThat(actualExtraData).usingRecursiveComparison().isEqualTo(expectedExtraData);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public void canRoundTripACommitMessage() {
assertThat(decodedPrepare.getMessageType()).isEqualTo(QbftV1.COMMIT);
assertThat(decodedPrepare.getAuthor()).isEqualTo(addr);
assertThat(decodedPrepare.getSignedPayload())
.isEqualToComparingFieldByField(signedCommitPayload);
.usingRecursiveComparison()
.isEqualTo(signedCommitPayload);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public void canRoundTripAPrepareMessage() {
assertThat(decodedPrepare.getMessageType()).isEqualTo(QbftV1.PREPARE);
assertThat(decodedPrepare.getAuthor()).isEqualTo(addr);
assertThat(decodedPrepare.getSignedPayload())
.isEqualToComparingFieldByField(signedPreparePayload);
.usingRecursiveComparison()
.isEqualTo(signedPreparePayload);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,11 @@ public void canRoundTripProposalMessage() {
assertThat(decodedProposal.getAuthor()).isEqualTo(addr);
assertThat(decodedProposal.getMessageType()).isEqualTo(QbftV1.PROPOSAL);
assertThat(decodedProposal.getPrepares()).hasSize(1);
assertThat(decodedProposal.getPrepares().get(0)).isEqualToComparingFieldByField(prepare);
assertThat(decodedProposal.getPrepares().get(0)).usingRecursiveComparison().isEqualTo(prepare);
assertThat(decodedProposal.getRoundChanges()).hasSize(1);
assertThat(decodedProposal.getRoundChanges().get(0))
.isEqualToComparingFieldByField(roundChange);
.usingRecursiveComparison()
.isEqualTo(roundChange);
assertThat(decodedProposal.getSignedPayload().getPayload().getProposedBlock()).isEqualTo(BLOCK);
assertThat(decodedProposal.getSignedPayload().getPayload().getRoundIdentifier())
.isEqualTo(payload.getRoundIdentifier());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,16 @@ public void canRoundTripARoundChangeMessage() {
assertThat(decodedRoundChange.getMessageType()).isEqualTo(QbftV1.ROUND_CHANGE);
assertThat(decodedRoundChange.getAuthor()).isEqualTo(addr);
assertThat(decodedRoundChange.getSignedPayload())
.isEqualToComparingFieldByField(signedRoundChangePayload);
.usingRecursiveComparison()
.isEqualTo(signedRoundChangePayload);
assertThat(decodedRoundChange.getProposedBlock()).isNotEmpty();
assertThat(decodedRoundChange.getProposedBlock().get()).isEqualToComparingFieldByField(BLOCK);
assertThat(decodedRoundChange.getProposedBlock().get())
.usingRecursiveComparison()
.isEqualTo(BLOCK);
assertThat(decodedRoundChange.getPrepares()).hasSize(1);
assertThat(decodedRoundChange.getPrepares().get(0))
.isEqualToComparingFieldByField(signedPreparePayload);
.usingRecursiveComparison()
.isEqualTo(signedPreparePayload);
}

@Test
Expand All @@ -109,7 +113,8 @@ public void canRoundTripEmptyPreparedRoundAndPreparedList() {
assertThat(decodedRoundChange.getMessageType()).isEqualTo(QbftV1.ROUND_CHANGE);
assertThat(decodedRoundChange.getAuthor()).isEqualTo(addr);
assertThat(decodedRoundChange.getSignedPayload())
.isEqualToComparingFieldByField(signedRoundChangePayload);
.usingRecursiveComparison()
.isEqualTo(signedRoundChangePayload);
assertThat(decodedRoundChange.getProposedBlock()).isEmpty();
assertThat(decodedRoundChange.getPrepares()).isEmpty();
}
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);
}
}
Loading