diff --git a/core/src/main/java/haveno/core/offer/OpenOfferManager.java b/core/src/main/java/haveno/core/offer/OpenOfferManager.java index 799725c9b7..f1de5da3fd 100644 --- a/core/src/main/java/haveno/core/offer/OpenOfferManager.java +++ b/core/src/main/java/haveno/core/offer/OpenOfferManager.java @@ -557,17 +557,17 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe ResultHandler resultHandler, ErrorMessageHandler errorMessageHandler) { Offer offer = openOffer.getOffer(); - if (openOffer.isScheduled()) { - resultHandler.handleResult(); // ignore if scheduled - } else { + if (openOffer.isAvailable()) { offerBookService.deactivateOffer(offer.getOfferPayload(), - () -> { - openOffer.setState(OpenOffer.State.DEACTIVATED); - requestPersistence(); - log.debug("deactivateOpenOffer, offerId={}", offer.getId()); - resultHandler.handleResult(); - }, - errorMessageHandler); + () -> { + openOffer.setState(OpenOffer.State.DEACTIVATED); + requestPersistence(); + log.debug("deactivateOpenOffer, offerId={}", offer.getId()); + resultHandler.handleResult(); + }, + errorMessageHandler); + } else { + resultHandler.handleResult(); // ignore if unavailable } } @@ -598,15 +598,15 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe offersToBeEdited.put(openOffer.getId(), openOffer); - if (openOffer.isDeactivated()) { - resultHandler.handleResult(); - } else { + if (openOffer.isAvailable()) { deactivateOpenOffer(openOffer, resultHandler, errorMessage -> { offersToBeEdited.remove(openOffer.getId()); errorMessageHandler.handleErrorMessage(errorMessage); }); + } else { + resultHandler.handleResult(); } } diff --git a/core/src/test/java/haveno/core/offer/OpenOfferManagerTest.java b/core/src/test/java/haveno/core/offer/OpenOfferManagerTest.java index 16cce99cf8..ed4b85312f 100644 --- a/core/src/test/java/haveno/core/offer/OpenOfferManagerTest.java +++ b/core/src/test/java/haveno/core/offer/OpenOfferManagerTest.java @@ -13,7 +13,6 @@ import haveno.network.p2p.P2PService; import haveno.network.p2p.peers.PeerManager; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import java.nio.file.Files; @@ -51,7 +50,6 @@ public class OpenOfferManagerTest { } @Test - @Disabled // TODO: re-enable when editing offers supported public void testStartEditOfferForActiveOffer() { P2PService p2PService = mock(P2PService.class); OfferBookService offerBookService = mock(OfferBookService.class); @@ -89,6 +87,7 @@ public class OpenOfferManagerTest { }).when(offerBookService).deactivateOffer(any(OfferPayload.class), any(ResultHandler.class), any(ErrorMessageHandler.class)); final OpenOffer openOffer = new OpenOffer(make(btcUsdOffer)); + openOffer.setState(OpenOffer.State.AVAILABLE); ResultHandler resultHandler = () -> startEditOfferSuccessful.set(true); @@ -97,7 +96,6 @@ public class OpenOfferManagerTest { verify(offerBookService, times(1)).deactivateOffer(any(OfferPayload.class), any(ResultHandler.class), any(ErrorMessageHandler.class)); assertTrue(startEditOfferSuccessful.get()); - } @Test