@@ -2,6 +2,7 @@ package sigmastate.utxo
22
33import org .ergoplatform .ErgoBox .{AdditionalRegisters , R6 , R8 }
44import org .ergoplatform ._
5+ import sigma .Colls
56import sigma .Extensions .ArrayOps
67import sigma .ast .SCollection .SByteArray
78import sigma .ast .SType .AnyOps
@@ -19,6 +20,7 @@ import sigmastate.interpreter.Interpreter._
1920import sigma .ast .Apply
2021import sigma .eval .EvalSettings
2122import sigma .exceptions .InvalidType
23+ import sigma .serialization .ValueSerializer
2224import sigmastate .utils .Helpers ._
2325
2426import java .math .BigInteger
@@ -157,6 +159,50 @@ class BasicOpsSpecification extends CompilerTestingCommons
157159 )
158160 }
159161
162+ property(" executeFromVar - SigmaProp" ) {
163+ val script = GT (Height , IntConstant (- 1 )).toSigmaProp
164+ val scriptBytes = ValueSerializer .serialize(script)
165+ val customExt = Seq (21 .toByte -> ByteArrayConstant (scriptBytes))
166+ test(" executeFromVar" , env, customExt,
167+ " executeFromVar[SigmaProp](21)" ,
168+ null ,
169+ true
170+ )
171+ }
172+
173+ property(" executeFromVar - Int" ) {
174+ val valueBytes = ValueSerializer .serialize(Plus (IntConstant (2 ), IntConstant (3 )))
175+ val customExt = Seq (21 .toByte -> ByteArrayConstant (valueBytes))
176+ test(" executeFromVar" , env, customExt,
177+ " { executeFromVar[Int](21) == 5 }" ,
178+ null ,
179+ true
180+ )
181+ }
182+
183+ property(" executeFromVar - Coll[Byte]" ) {
184+ val bytes = Slice (ByteArrayConstant (Colls .fromArray(Array .fill(5 )(1 .toByte))), IntConstant (1 ), IntConstant (3 ))
185+ val valueBytes = ValueSerializer .serialize(bytes)
186+ val customExt = Seq (21 .toByte -> ByteArrayConstant (valueBytes))
187+ test(" executeFromVar" , env, customExt,
188+ " {val ba = executeFromVar[Coll[Byte]](21); ba.size == 2 }" ,
189+ null ,
190+ true
191+ )
192+ }
193+
194+ // test which is showing impossibility of nested Deserialize*
195+ property(" executeFromVar - deserialize" ) {
196+ val script = DeserializeContext (21 .toByte, SSigmaProp )
197+ val scriptBytes = ValueSerializer .serialize(script)
198+ val customExt = Seq (21 .toByte -> ByteArrayConstant (scriptBytes))
199+ an [Exception ] should be thrownBy test(" executeFromVar" , env, customExt,
200+ " executeFromVar[SigmaProp](21)" ,
201+ null ,
202+ true
203+ )
204+ }
205+
160206 property(" Relation operations" ) {
161207 test(" R1" , env, ext,
162208 " { allOf(Coll(getVar[Boolean](trueVar).get, true, true)) }" ,
0 commit comments