Skip to content
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

Test for garbage-collecting utxo with invalid ergo tree #2059

Merged
merged 2 commits into from
Nov 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading