Skip to content

Commit

Permalink
tx-signing-js: fixed test for isoUnsignedTransaction
Browse files Browse the repository at this point in the history
  • Loading branch information
aslesarenko committed Aug 5, 2023
1 parent a9fe1c5 commit 4c5b84c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import special.sigma._

import java.math.BigInteger
import scala.collection.compat.immutable.ArraySeq
import scala.collection.immutable.VectorMap
import scala.collection.mutable.ListBuffer
import scala.reflect.ClassTag

Expand Down Expand Up @@ -238,7 +239,7 @@ trait ObjectGenerators extends TypeGenerators

lazy val contextExtensionGen: Gen[ContextExtension] = for {
values <- Gen.sequence(contextExtensionValuesGen(0, 5))(Buildable.buildableSeq)
} yield ContextExtension(values.toMap)
} yield ContextExtension(VectorMap.from(values.sortBy(_._1)))

lazy val serializedProverResultGen: Gen[ProverResult] = for {
bytes <- arrayOfRange(1, 100, arbByte.arbitrary)
Expand Down
2 changes: 1 addition & 1 deletion sdk/js/src/main/scala/org/ergoplatform/sdk/js/Isos.scala
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ object Isos {
implicit val isoContextExtension: Iso[contextExtensionMod.ContextExtension, ContextExtension] = new Iso[contextExtensionMod.ContextExtension, ContextExtension] {
override def to(x: contextExtensionMod.ContextExtension): ContextExtension = {
var map = new ListMap[Byte, Constant[SType]]()
val keys = js.Object.keys(x)
val keys = js.Object.keys(x).sorted
for ( k <- keys ) {
val id = k.toInt.toByte
val c = isoHexStringToConstant.to(x.apply(id).get.get)
Expand Down
5 changes: 2 additions & 3 deletions sdk/js/src/test/scala/org/ergoplatform/sdk/js/IsosSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ class IsosSpec extends AnyPropSpec with Matchers with ObjectGenerators with Sca
)

def roundtrip[A,B](iso: Iso[A,B])(b: B): Unit = {
val invIso = iso.inverse
invIso.from(invIso.to(b)) shouldBe b
iso.to(iso.from(b)) shouldBe b
}

override implicit val generatorDrivenConfig: PropertyCheckConfiguration = PropertyCheckConfiguration(minSuccessful = 30)
Expand Down Expand Up @@ -164,7 +163,7 @@ class IsosSpec extends AnyPropSpec with Matchers with ObjectGenerators with Sca
}
}

ignore("Iso.isoUnsignedTransaction") {
property("Iso.isoUnsignedTransaction") {
forAll { (tx: UnsignedErgoLikeTransaction) =>
roundtrip(Isos.isoUnsignedTransaction)(tx)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class ExtensionsSpec extends AnyPropSpec with ScalaCheckPropertyChecks with Matc
val left = builder.pairColl(leftKeys, leftValues)
val right = builder.pairColl(rightKeys, rightValues)
val res = builder.outerJoin(left, right)(l => l._2 - 2, r => r._2 - 3, i => i._2._1 + 5)
val (ks, vs) = builder.unzip(res)
val (_, vs) = builder.unzip(res)
vs.sum shouldBe (col.sum * 2 + col.map(_ + 5).sum)
}
// test(builder.fromItems(0))
Expand Down

0 comments on commit 4c5b84c

Please sign in to comment.