Skip to content
This repository has been archived by the owner on Apr 13, 2022. It is now read-only.

Commit

Permalink
fix double message notification about semantic valid modifier
Browse files Browse the repository at this point in the history
  • Loading branch information
terjokhin committed Oct 27, 2017
1 parent 496080e commit ce9f931
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 3 deletions.
1 change: 0 additions & 1 deletion src/main/scala/scorex/core/NodeViewHolder.scala
Expand Up @@ -259,7 +259,6 @@ trait NodeViewHolder[P <: Proposition, TX <: Transaction[P], PMOD <: PersistentN
}

log.info(s"Persistent modifier ${Base58.encode(pmod.id)} applied successfully")
notifySubscribers(EventType.SuccessfulSemanticallyValidModifier, SemanticallySuccessfulModifier(pmod))
nodeView = (newHistory, newMinState, newVault, newMemPool)

case Failure(e) =>
Expand Down
Expand Up @@ -12,7 +12,7 @@ import scorex.core.transaction.wallet.Vault
import scorex.core.transaction.{MemoryPool, Transaction}
import scorex.core.utils.ScorexLogging
import scorex.core.{NodeViewHolder, PersistentNodeViewModifier}
import scorex.testkit.generators.{SyntacticallyTargetedModifierProducer, TotallyValidModifierProducer}
import scorex.testkit.generators.{SemanticallyInvalidModifierProducer, SyntacticallyTargetedModifierProducer, TotallyValidModifierProducer}
import scorex.testkit.utils.{FileUtils, SequentialAkkaFixture}

import scala.concurrent.duration._
Expand All @@ -31,7 +31,8 @@ VL <: Vault[P, TX, PM, VL]]
with PropertyChecks
with ScorexLogging
with SyntacticallyTargetedModifierProducer[PM, SI, HT]
with TotallyValidModifierProducer[PM, ST, SI, HT] {
with TotallyValidModifierProducer[PM, ST, SI, HT]
with SemanticallyInvalidModifierProducer[PM, ST] {

type Fixture = HolderFixture

Expand All @@ -43,8 +44,67 @@ VL <: Vault[P, TX, PM, VL]]

def createAkkaFixture(): Fixture = new HolderFixture

val semantic = Seq(SuccessfulSemanticallyValidModifier, SemanticallyFailedPersistentModifier)
val syntactic = Seq(SuccessfulSyntacticallyValidModifier, SyntacticallyFailedPersistentModifier)
val allEvents = semantic ++ syntactic

import NodeViewHolder._


property("NodeViewHolder: syntactically valid modifier subscription") { ctx =>
import ctx._

node ! NodeViewHolder.Subscribe(syntactic)
node ! GetDataFromCurrentView[HT, ST, VL, MPool, PM] { v => totallyValidModifiers(v.history, v.state, 2).head }
val mod = receiveOne(5 seconds).asInstanceOf[PM]
node ! LocallyGeneratedModifier(mod)
expectMsgType[SyntacticallySuccessfulModifier[PM]]

}

property("NodeViewHolder: syntactically failed modifier subscription") { ctx =>
import ctx._

node ! NodeViewHolder.Subscribe(syntactic)
val invalid = syntacticallyInvalidModifier(h)
node ! LocallyGeneratedModifier(invalid)
expectMsgType[SyntacticallyFailedModification[PM]]
}

property("NodeViewHolder: semantically valid modifier subscription") { ctx =>
import ctx._

node ! NodeViewHolder.Subscribe(allEvents)
node ! GetDataFromCurrentView[HT, ST, VL, MPool, PM] { v => totallyValidModifiers(v.history, v.state, 2).head }
val mod = receiveOne(5 seconds).asInstanceOf[PM]
node ! LocallyGeneratedModifier(mod)
expectMsgType[SyntacticallySuccessfulModifier[PM]]
expectMsgType[SemanticallySuccessfulModifier[PM]]
}

property("NodeViewHolder: semantically failed modifier subscription") { ctx =>
import ctx._

node ! NodeViewHolder.Subscribe(allEvents)
node ! GetDataFromCurrentView[HT, ST, VL, MPool, PM] { v => semanticallyInvalidModifier(v.state) }
val invalid = receiveOne(5 seconds).asInstanceOf[PM]
node ! LocallyGeneratedModifier(invalid)
expectMsgType[SyntacticallySuccessfulModifier[PM]]
expectMsgType[SemanticallyFailedModification[PM]]
}

property("NodeViewHolder: syntactically/semantically valid modifier subscription") { ctx =>
import ctx._

node ! NodeViewHolder.Subscribe(allEvents)

node ! GetDataFromCurrentView[HT, ST, VL, MPool, PM] { v => totallyValidModifiers(v.history, v.state, 2).head }
val mod = receiveOne(5 seconds).asInstanceOf[PM]
node ! LocallyGeneratedModifier(mod)
expectMsgType[SyntacticallySuccessfulModifier[PM]]
expectMsgType[SemanticallySuccessfulModifier[PM]]
}

property("NodeViewHolder: check state after creation") { ctx =>
import ctx._
node ! GetDataFromCurrentView[HT, ST, VL, MPool, Boolean] { v =>
Expand Down

0 comments on commit ce9f931

Please sign in to comment.