From a107f4086a19ed96d96a11f6f4a4564e808b215e Mon Sep 17 00:00:00 2001 From: Vyatcheslav Suharnikov Date: Thu, 28 May 2020 15:26:36 +0300 Subject: [PATCH] DEX-775 Starting issue when there is matching rules (#285) --- .../wavesplatform/dex/market/OrderBookActor.scala | 13 +++++++++---- .../dex/market/OrderBookActorSpecification.scala | 7 +++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/dex/src/main/scala/com/wavesplatform/dex/market/OrderBookActor.scala b/dex/src/main/scala/com/wavesplatform/dex/market/OrderBookActor.scala index e401af8b12..f7988303bd 100644 --- a/dex/src/main/scala/com/wavesplatform/dex/market/OrderBookActor.scala +++ b/dex/src/main/scala/com/wavesplatform/dex/market/OrderBookActor.scala @@ -63,10 +63,15 @@ class OrderBookActor(settings: Settings, matchingRules = actualRules updateCurrentMatchingRules(matchingRules.head) actualRule = normalizeMatchingRule(matchingRules.head) - aggregatedRef ! AggregatedOrderBookActor.Command.ApplyChanges(LevelAmounts.empty, - None, - Some(matchingRules.head.tickSize.toDouble), - System.currentTimeMillis) + // Could be unset during the start + Option(aggregatedRef).foreach { + _ ! AggregatedOrderBookActor.Command.ApplyChanges( + LevelAmounts.empty, + None, + Some(matchingRules.head.tickSize.toDouble), + System.currentTimeMillis + ) + } } } diff --git a/dex/src/test/scala/com/wavesplatform/dex/market/OrderBookActorSpecification.scala b/dex/src/test/scala/com/wavesplatform/dex/market/OrderBookActorSpecification.scala index 622d70b04e..89a5198bf9 100644 --- a/dex/src/test/scala/com/wavesplatform/dex/market/OrderBookActorSpecification.scala +++ b/dex/src/test/scala/com/wavesplatform/dex/market/OrderBookActorSpecification.scala @@ -109,6 +109,13 @@ class OrderBookActorSpecification tp.expectMsg(OrderBookRecovered(pair, Some(50))) } + "recovery - if there is a matching rule - DEX-775" in obcTestWithPrepare( + prepare = (obsdb, p) => obsdb.update(p, 50, Some(OrderBookSnapshot.empty)), + matchingRules = NonEmptyList.of(DenormalizedMatchingRule(0, 0.00000001), DenormalizedMatchingRule(40, 0.0000001)) + ) { (pair, _, tp) => + tp.expectMsg(OrderBookRecovered(pair, Some(50))) + } + "recovery - notify address actor about orders" in obcTestWithPrepare( { (obsdb, p) => val ord = buy(p, 10 * Order.PriceConstant, 100)