Skip to content

Commit

Permalink
fix code style issue in test
Browse files Browse the repository at this point in the history
  • Loading branch information
ncying committed Sep 23, 2019
1 parent 383e39d commit 740f956
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ class SPOSTransactionDiffTest extends PropSpec with PropertyChecks with Generato

private implicit def noShrink[A]: Shrink[A] = Shrink(_ => Stream.empty)

val ENOUGH_AMT: Long = Long.MaxValue / 3

val preconditionsAndContend: Gen[(GenesisTransaction, ContendSlotsTransaction, ContendSlotsTransaction, ContendSlotsTransaction, ContendSlotsTransaction, Long)] = for {
master <- accountGen
ts <- positiveIntGen
Expand All @@ -31,13 +29,15 @@ class SPOSTransactionDiffTest extends PropSpec with PropertyChecks with Generato
} yield (genesis, contend, contendMultiSlots, contendInvalidId1, contendInvalidId2, contend.transactionFee)

property("contend transaction doesn't break invariant") {
forAll(preconditionsAndContend) { case (genesis, contend, _, _, _, feeContend) =>
forAll(preconditionsAndContend) { case (genesis, contend: ContendSlotsTransaction, _, _, _, feeContend) =>
assertDiffAndState(Seq(TestBlock.create(Seq(genesis))), TestBlock.create(Seq(contend))) { (blockDiff, newState) =>
val totalPortfolioDiff: Portfolio = Monoid.combineAll(blockDiff.txsDiff.portfolios.values)
totalPortfolioDiff.balance shouldBe -feeContend
totalPortfolioDiff.effectiveBalance shouldBe -feeContend
val sender = EllipticCurve25519Proof.fromBytes(contend.proofs.proofs.head.bytes.arr).toOption.get.publicKey
newState.accountTransactionIds(sender, 2, 0)._2.size shouldBe 2 // genesis and payment
val proof = contend.proofs.firstCurveProof.explicitGet()
val sender = EllipticCurve25519Proof.fromBytes(proof.bytes.arr).explicitGet.publicKey
val (_, txList) = newState.accountTransactionIds(sender, 2, 0)
txList.size shouldBe 2 // genesis and payment
}
}
}
Expand Down Expand Up @@ -126,14 +126,16 @@ class SPOSTransactionDiffTest extends PropSpec with PropertyChecks with Generato

property("release transaction doesn't break invariant") {
forAll(preconditionsAndRelease) { case (genesis0, genesis1, genesis2, genesis3, genesis4, genesis5, genesis6,
genesis7, genesis8, genesis9, genesis10, release1, _, _, _, f1) =>
genesis7, genesis8, genesis9, genesis10, release1: ReleaseSlotsTransaction, _, _, _, f1) =>
assertDiffAndState(Seq(TestBlock.create(Seq(genesis0, genesis1, genesis2, genesis3, genesis4,
genesis5, genesis6, genesis7, genesis8, genesis9, genesis10))), TestBlock.create(Seq(release1))) { (blockDiff, newState) =>
val totalPortfolioDiff: Portfolio = Monoid.combineAll(blockDiff.txsDiff.portfolios.values)
totalPortfolioDiff.balance shouldBe - f1
totalPortfolioDiff.effectiveBalance shouldBe -f1
val sender = EllipticCurve25519Proof.fromBytes(release1.proofs.proofs.head.bytes.arr).toOption.get.publicKey
newState.accountTransactionIds(sender, 10, 0)._2.size shouldBe 2 // genesis and release
val proof = release1.proofs.firstCurveProof.explicitGet()
val sender = EllipticCurve25519Proof.fromBytes(proof.bytes.arr).explicitGet.publicKey
val (_, txList) = newState.accountTransactionIds(sender, 10, 0)
txList.size shouldBe 2 // genesis and release
}
}
}
Expand Down Expand Up @@ -179,7 +181,7 @@ class SPOSTransactionDiffTest extends PropSpec with PropertyChecks with Generato
slotId <- slotidGen
genesis: GenesisTransaction = GenesisTransaction.create(master, ENOUGH_AMT, -1, ts).explicitGet()
contendTmp: ContendSlotsTransaction <- contendGeneratorP(master, slotId)
proof = contendTmp.proofs.proofs.head
proof = contendTmp.proofs.firstCurveProof.explicitGet
proofs = Proofs(List(proof, proof)) // two proofs case
contend = contendTmp.copy(proofs = proofs)
} yield (genesis, contend)
Expand All @@ -198,7 +200,7 @@ class SPOSTransactionDiffTest extends PropSpec with PropertyChecks with Generato
genesis: GenesisTransaction = GenesisTransaction.create(master, ENOUGH_AMT, -1, ts).explicitGet()
contend: ContendSlotsTransaction <- contendGeneratorP(master, 0)
releaseTmp: ReleaseSlotsTransaction <- releaseGeneratorP(master, 0)
proof = releaseTmp.proofs.proofs.head
proof = releaseTmp.proofs.firstCurveProof.explicitGet
proofs = Proofs(List(proof, proof)) // two proofs case
release = releaseTmp.copy(proofs = proofs)
} yield (genesis, contend, release)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ import org.scalatest.prop.{GeneratorDrivenPropertyChecks, PropertyChecks}
import org.scalatest.{Matchers, PropSpec}
import vsys.blockchain.block.TestBlock
import vsys.blockchain.state.EitherExt2
import vsys.blockchain.transaction.{GenesisTransaction, PaymentTransaction, Transaction}
import vsys.blockchain.transaction._
import vsys.blockchain.transaction.lease.{LeaseCancelTransaction, LeaseTransaction}
import vsys.blockchain.transaction.TransactionParser.TransactionType
import vsys.blockchain.transaction.{ProcessedTransaction, TransactionGen, TransactionStatus}

class StateReaderTransactionQueryTest extends PropSpec with PropertyChecks with GeneratorDrivenPropertyChecks with Matchers with TransactionGen {

Expand Down

0 comments on commit 740f956

Please sign in to comment.