Skip to content

Commit

Permalink
Merge pull request #2059 from ergoplatform/sr-invali
Browse files Browse the repository at this point in the history
Test for garbage-collecting utxo with invalid ergo tree
  • Loading branch information
kushti authored Nov 9, 2023
2 parents 2315cf5 + beb55d5 commit f8dae70
Showing 1 changed file with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,23 @@ import org.ergoplatform.utils.ErgoPropertyTest
import org.ergoplatform.wallet.interpreter.ErgoInterpreter
import org.ergoplatform.{ErgoBox, ErgoBoxCandidate, Input}
import org.scalatest.Assertion
import scorex.util.encode.Base16
import sigma.Colls
import sigmastate.Values.ShortConstant
import sigmastate.Values.{ErgoTree, ShortConstant}
import sigmastate.interpreter.{ContextExtension, ProverResult}
import sigmastate.eval._
import sigmastate.helpers.TestingHelpers._
import sigmastate.serialization.ErgoTreeSerializer

class ExpirationSpecification extends ErgoPropertyTest {

type Height = Int

private implicit val verifier: ErgoInterpreter = ErgoInterpreter(parameters)

def falsify(box: ErgoBox): ErgoBox = {
def injectScript(box: ErgoBox, script: ErgoTree): ErgoBox = {
testBox(box.value,
Constants.FalseLeaf,
script,
box.creationHeight,
box.additionalTokens.toArray.toSeq,
box.additionalRegisters,
Expand Down Expand Up @@ -68,6 +70,16 @@ class ExpirationSpecification extends ErgoPropertyTest {
}
}

property("successful spending w. invalid ergotree") {
forAll(unspendableErgoBoxGen()) { from =>
// invalid (unparseable) ergo tree
val etString = "0e1631393039303063646462363930366462363530336665"
val et = ErgoTreeSerializer.DefaultSerializer.deserializeErgoTree(Base16.decode(etString).get)
val modified = injectScript(from, et)
constructTest(modified, 0, _ => IndexedSeq(modified), expectedValidity = true)
}
}

property("successful spending w. max spending") {
forAll(unspendableErgoBoxGen()) { from =>
constructTest(from, 0, h => {
Expand Down

0 comments on commit f8dae70

Please sign in to comment.