Skip to content

Commit

Permalink
Merge pull request #589 from iExecBlockchainComputing/bugfix/use-buil…
Browse files Browse the repository at this point in the history
…ders-in-tests

Use builders in test classes
  • Loading branch information
jbern0rd authored May 25, 2023
2 parents 79fcf6c + 9360cc5 commit b3f01bf
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ All notable changes to this project will be documented in this file.
- Add purge cached task descriptions ability. (#587)
### Bug Fixes
- Prevent race condition on replicate update. (#568)
- Use builders in test classes. (#589)
### Quality
- Remove unused methods in `IexecHubService`. (#572)
- Clean unused Replicate methods and update tests. (#573)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ void shouldUpdateLastSeenBlockWhenOneDeal() {

@Test
void shouldUpdateLastSeenBlockWhenOneDealAndCreateTask() {
ChainApp chainApp = new ChainApp();
chainApp.setUri("0x00");
ChainApp chainApp = ChainApp.builder()
.uri("0x00").build();

ChainCategory chainCategory = new ChainCategory();
ChainCategory chainCategory = ChainCategory.builder().build();

ChainDeal chainDeal = ChainDeal.builder()
.botFirst(BigInteger.valueOf(0))
Expand Down Expand Up @@ -146,7 +146,7 @@ void shouldUpdateLastSeenBlockWhenOneDealAndNotCreateTaskSinceDealIsExpired() {
.botFirst(BigInteger.valueOf(0))
.botSize(BigInteger.valueOf(1))
.chainApp(ChainApp.builder().uri("0x00").build())
.chainCategory(new ChainCategory())
.chainCategory(ChainCategory.builder().build())
.params(DealParams.builder().iexecArgs("args").build())
.trust(BigInteger.valueOf(3))
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1410,7 +1410,7 @@ void shouldAuthorizeUpdateOnComputedWhenTaskDescriptionIsFilled() {
@Test
void computeUpdateReplicateStatusArgsContributed() {
final int expectedWorkerWeight = 1;
final ChainContribution expectedChainContribution = new ChainContribution();
final ChainContribution expectedChainContribution = ChainContribution.builder().build();
final String unexpectedResultLink = "resultLink";
final String unexpectedChainCallbackData = "chainCallbackData";

Expand All @@ -1426,7 +1426,7 @@ void computeUpdateReplicateStatusArgsContributed() {

when(iexecHubService.getWorkerWeight(WALLET_WORKER_1)).thenReturn(expectedWorkerWeight);
when(iexecHubService.getChainContribution(CHAIN_TASK_ID, WALLET_WORKER_1))
.thenReturn(Optional.of(new ChainContribution()));
.thenReturn(Optional.of(ChainContribution.builder().build()));

assertThat(replicatesService.computeUpdateReplicateStatusArgs(CHAIN_TASK_ID, WALLET_WORKER_1, statusUpdate))
.isEqualTo(UpdateReplicateStatusArgs.builder()
Expand All @@ -1438,7 +1438,7 @@ void computeUpdateReplicateStatusArgsContributed() {
@Test
void computeUpdateReplicateStatusArgsResultUploaded() {
final int unexpectedWorkerWeight = 1;
final ChainContribution unexpectedChainContribution = new ChainContribution();
final ChainContribution unexpectedChainContribution = ChainContribution.builder().build();
final String expectedResultLink = "resultLink";
final String expectedChainCallbackData = "chainCallbackData";
final TaskDescription expectedTaskDescription = TaskDescription.builder().build();
Expand Down Expand Up @@ -1472,7 +1472,7 @@ void computeUpdateReplicateStatusArgsResultUploaded() {
@Test
void computeUpdateReplicateStatusArgsResultUploadFailed() {
final int unexpectedWorkerWeight = 1;
final ChainContribution unexpectedChainContribution = new ChainContribution();
final ChainContribution unexpectedChainContribution = ChainContribution.builder().build();
final String unexpectedResultLink = "resultLink";
final String unexpectedChainCallbackData = "chainCallbackData";
final TaskDescription expectedTaskDescription = TaskDescription.builder().build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void shouldNotUpgrade2ReopenedSinceCurrentStatusWrong() {
when(iexecHubService.canReopen(task.getChainTaskId())).thenReturn(true);
when(iexecHubService.hasEnoughGas()).thenReturn(true);
when(taskService.updateTask(task)).thenReturn(Optional.of(task));
when(iexecHubService.reOpen(task.getChainTaskId())).thenReturn(Optional.of(new ChainReceipt()));
when(iexecHubService.reOpen(task.getChainTaskId())).thenReturn(Optional.of(ChainReceipt.builder().build()));

taskUpdateManager.consensusReached2Reopening(task);

Expand All @@ -136,7 +136,7 @@ void shouldNotUpgrade2ReopenedSinceNotAfterRevealDeadline() {
when(iexecHubService.canReopen(task.getChainTaskId())).thenReturn(true);
when(iexecHubService.hasEnoughGas()).thenReturn(true);
when(taskService.updateTask(task)).thenReturn(Optional.of(task));
when(iexecHubService.reOpen(task.getChainTaskId())).thenReturn(Optional.of(new ChainReceipt()));
when(iexecHubService.reOpen(task.getChainTaskId())).thenReturn(Optional.of(ChainReceipt.builder().build()));

taskUpdateManager.consensusReached2Reopening(task);

Expand All @@ -153,7 +153,7 @@ void shouldNotUpgrade2ReopenedSinceNotWeHaveSomeRevealed() {
when(iexecHubService.canReopen(task.getChainTaskId())).thenReturn(true);
when(iexecHubService.hasEnoughGas()).thenReturn(true);
when(taskService.updateTask(task)).thenReturn(Optional.of(task));
when(iexecHubService.reOpen(task.getChainTaskId())).thenReturn(Optional.of(new ChainReceipt()));
when(iexecHubService.reOpen(task.getChainTaskId())).thenReturn(Optional.of(ChainReceipt.builder().build()));

taskUpdateManager.consensusReached2Reopening(task);

Expand All @@ -170,7 +170,7 @@ void shouldNotUpgrade2ReopenedSinceCantReopenOnChain() {
when(iexecHubService.canReopen(task.getChainTaskId())).thenReturn(false);
when(iexecHubService.hasEnoughGas()).thenReturn(true);
when(taskService.updateTask(task)).thenReturn(Optional.of(task));
when(iexecHubService.reOpen(task.getChainTaskId())).thenReturn(Optional.of(new ChainReceipt()));
when(iexecHubService.reOpen(task.getChainTaskId())).thenReturn(Optional.of(ChainReceipt.builder().build()));

taskUpdateManager.consensusReached2Reopening(task);

Expand All @@ -187,7 +187,7 @@ void shouldNotUpgrade2ReopenedSinceNotEnoughtGas() {
when(iexecHubService.canReopen(task.getChainTaskId())).thenReturn(true);
when(iexecHubService.hasEnoughGas()).thenReturn(false);
when(taskService.updateTask(task)).thenReturn(Optional.of(task));
when(iexecHubService.reOpen(task.getChainTaskId())).thenReturn(Optional.of(new ChainReceipt()));
when(iexecHubService.reOpen(task.getChainTaskId())).thenReturn(Optional.of(ChainReceipt.builder().build()));

taskUpdateManager.consensusReached2Reopening(task);

Expand Down Expand Up @@ -224,7 +224,7 @@ void shouldUpgrade2Reopened() {
when(iexecHubService.canReopen(task.getChainTaskId())).thenReturn(true);
when(iexecHubService.hasEnoughGas()).thenReturn(true);
when(taskService.updateTask(task)).thenReturn(Optional.of(task));
when(iexecHubService.reOpen(task.getChainTaskId())).thenReturn(Optional.of(new ChainReceipt()));
when(iexecHubService.reOpen(task.getChainTaskId())).thenReturn(Optional.of(ChainReceipt.builder().build()));
when(iexecHubService.getChainTask(CHAIN_TASK_ID)).thenReturn(Optional.of(ChainTask.builder()
.status(ChainTaskStatus.ACTIVE)
.build()));
Expand Down

0 comments on commit b3f01bf

Please sign in to comment.