Skip to content

Commit

Permalink
Merge pull request #579 from iExecBlockchainComputing/feature/disable…
Browse files Browse the repository at this point in the history
…-contribute-and-finalize-when-callback

disable contribute and finalize when callback is filled
  • Loading branch information
thewhitewizard authored May 12, 2023
2 parents 6a57dfb + e624e2a commit a4a6b66
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file.
- Add ContributeAndFinalize to `ReplicateWorkflow`. (#574)
- Add check for ContributeAndFinalize in `ReplicatesService`. (#576)
- Add `running2Finalized2Completed` in `TaskUpdateManager`. (#577 #578)
- Disable `contributeAndFinalize` with CallBack. (#579)
### Bug Fixes
- Prevent race condition on replicate update. (#568)
### Quality
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/iexec/core/workflow/ReplicateWorkflow.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.iexec.commons.poco.notification.TaskNotificationType;
import com.iexec.commons.poco.task.TaskDescription;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;

import java.util.Arrays;
import java.util.LinkedHashMap;
Expand Down Expand Up @@ -195,7 +196,8 @@ TaskNotificationType getNextActionWhenStatusAndCause(ReplicateStatus whenStatus,
log.error("TaskDescription is null with a COMPUTED status, this case shouldn't happen");
return PLEASE_ABORT;
}
if (taskDescription.isTeeTask()) {
// We must check CallBack is empty because there is an issue in poco (transaction is revert)
if (taskDescription.isTeeTask() && StringUtils.isEmpty(taskDescription.getCallback())) {
return PLEASE_CONTRIBUTE_AND_FINALIZE;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,15 @@ void shouldGetNextActionOnComputedWithoutTaskDescriptionShouldBePleaseAbort(){
.isEqualTo(PLEASE_ABORT);
}

@Test
void shouldGetNextActionOnComputedWithTeeTaskAndCallBackShouldBePlease(){
assertThat(replicateWorkflow
.getNextAction(COMPUTED,
null,
TaskDescription.builder().isTeeTask(true).callback("callback").build()))
.isEqualTo(PLEASE_CONTRIBUTE);
}

// endregion

/*
Expand Down

0 comments on commit a4a6b66

Please sign in to comment.