Skip to content

Commit

Permalink
tx-signing-js: fixed tests (2)
Browse files Browse the repository at this point in the history
  • Loading branch information
aslesarenko committed Aug 6, 2023
1 parent 964feda commit ae39af3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package sigmastate.crypto

import org.scalatest.matchers.should.Matchers
import org.scalatest.propspec.AnyPropSpec
import scorex.util.encode.Base16

import scala.scalajs.js
import scala.scalajs.js.typedarray.Uint8Array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import sigmastate.utils.{SigmaByteReader, SigmaByteWriter}
import special.sigma
import special.sigma.AnyValue

import scala.collection.mutable

/**
* User-defined variables to be put into context.
* Each variable is identified by `id: Byte` and can be accessed from a script
Expand All @@ -20,7 +22,7 @@ import special.sigma.AnyValue
*
* @param values internal container of the key-value pairs
*/
case class ContextExtension(values: Map[Byte, EvaluatedValue[_ <: SType]]) {
case class ContextExtension(values: scala.collection.Map[Byte, EvaluatedValue[_ <: SType]]) {
def add(bindings: VarBinding*): ContextExtension =
ContextExtension(values ++ bindings)
}
Expand Down Expand Up @@ -49,8 +51,7 @@ object ContextExtension {
error(s"Negative amount of context extension values: $extSize")
val ext = (0 until extSize)
.map(_ => (r.getByte(), r.getValue().asInstanceOf[EvaluatedValue[_ <: SType]]))
.toMap[Byte, EvaluatedValue[_ <: SType]]
ContextExtension(ext)
ContextExtension(mutable.LinkedHashMap(ext:_*))
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import special.sigma._

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

Expand Down Expand Up @@ -238,8 +238,8 @@ trait ObjectGenerators extends TypeGenerators
val unsignedShortGen: Gen[Short] = Gen.chooseNum(0, Short.MaxValue).map(_.toShort)

lazy val contextExtensionGen: Gen[ContextExtension] = for {
values <- Gen.sequence(contextExtensionValuesGen(0, 5))(Buildable.buildableSeq)
} yield ContextExtension(ListMap.empty ++ values.sortBy(_._1))
values: collection.Seq[(Byte, EvaluatedValue[SType])] <- Gen.sequence(contextExtensionValuesGen(0, 5))(Buildable.buildableSeq)
} yield ContextExtension(mutable.LinkedHashMap[Byte, EvaluatedValue[SType]](values.sortBy(_._1).toSeq:_*))

lazy val serializedProverResultGen: Gen[ProverResult] = for {
bytes <- arrayOfRange(1, 100, arbByte.arbitrary)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.ergoplatform.sdk

import java.math.BigInteger

import cats.syntax.either._
import io.circe._
import io.circe.syntax._
Expand Down Expand Up @@ -33,6 +32,8 @@ import org.ergoplatform.ErgoLikeTransactionTemplate
import org.ergoplatform.ErgoBoxCandidate
import org.ergoplatform.ErgoLikeContext

import scala.collection.mutable

trait JsonCodecs {

def fromTry[T](tryResult: Try[T])(implicit cursor: ACursor): Either[DecodingFailure, T] = {
Expand Down Expand Up @@ -244,7 +245,7 @@ trait JsonCodecs {

implicit val contextExtensionDecoder: Decoder[ContextExtension] = Decoder.instance({ cursor =>
for {
values <- cursor.as[Map[Byte, EvaluatedValue[SType]]]
values <- cursor.as[mutable.LinkedHashMap[Byte, EvaluatedValue[SType]]]
} yield ContextExtension(values)
})

Expand Down

0 comments on commit ae39af3

Please sign in to comment.