-
Notifications
You must be signed in to change notification settings - Fork 41
[6.0] Box.getReg implementation #1015
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,11 +2,14 @@ package sigma | |
|
|
||
| import org.ergoplatform.ErgoHeader | ||
| import scorex.util.encode.Base16 | ||
| import org.ergoplatform.ErgoBox | ||
| import org.ergoplatform.ErgoBox.Token | ||
| import scorex.util.ModifierId | ||
| import sigma.ast.ErgoTree.ZeroHeader | ||
| import sigma.ast.SCollection.SByteArray | ||
| import sigma.ast.syntax.TrueSigmaProp | ||
| import sigma.ast._ | ||
| import sigma.data.{CBigInt, CHeader, ExactNumeric} | ||
| import sigma.data.{CBigInt, CHeader, CBox, ExactNumeric} | ||
| import sigma.eval.{CostDetails, SigmaDsl, TracedCost} | ||
| import sigma.util.Extensions.{BooleanOps, ByteOps, IntOps, LongOps} | ||
| import sigmastate.exceptions.MethodNotFound | ||
|
|
@@ -267,9 +270,13 @@ class LanguageSpecificationV6 extends LanguageSpecificationBase { suite => | |
| } | ||
|
|
||
| property("Box properties equivalence (new features)") { | ||
| // TODO v6.0: related to https://github.com/ScorexFoundation/sigmastate-interpreter/issues/416 | ||
| val getReg = newFeature((x: Box) => x.getReg[Int](1).get, | ||
| "{ (x: Box) => x.getReg[Int](1).get }", | ||
| // related to https://github.com/ScorexFoundation/sigmastate-interpreter/issues/416 | ||
| def getReg = newFeature((x: Box) => x.getReg[Long](0).get, | ||
| "{ (x: Box) => x.getReg[Long](0).get }", | ||
| FuncValue( | ||
| Array((1, SBox)), | ||
| OptionGet(ExtractRegisterAs(ValUse(1, SBox), ErgoBox.R0, SOption(SLong))) | ||
| ), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The idea behind getReg was to have "computable" index, not just constant. So I suggest to add additional test with variable register passed as function argument and have a series of cases in verifyCases.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
and so the new test can also be used for reference for people asked for computable index. |
||
| sinceVersion = VersionContext.V6SoftForkVersion) | ||
|
|
||
| if (activatedVersionInTests < VersionContext.V6SoftForkVersion) { | ||
|
|
@@ -279,6 +286,16 @@ class LanguageSpecificationV6 extends LanguageSpecificationBase { suite => | |
| forAll { box: Box => | ||
| Seq(getReg).foreach(_.checkEquality(box)) | ||
| } | ||
| } else { | ||
| val value = 10L | ||
| val box = CBox(new ErgoBox(value, TrueTree, Colls.emptyColl[Token], Map.empty, | ||
| ModifierId @@ Base16.encode(Array.fill(32)(0)), 0, 0)) | ||
| verifyCases( | ||
| Seq( | ||
| box -> new Expected(ExpectedResult(Success(value), None)) | ||
| ), | ||
| getReg | ||
| ) | ||
| } | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.