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

More 6.0 test cases for 5.0 node #2192

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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 @@ -494,35 +494,42 @@ class ErgoNodeTransactionSpec extends ErgoCorePropertyTest {
* not recognizing it.
*/
property("Soft-forked execution of Ergoscript containing unknown methods") {
val trees = Array(
"1b130206022edf0580fcf622d193db060873007301", // contains SBigInt.nbits
"19110204040400d191b1dc6a03dd0173007301", // sigmaProp(Global.serialize(2).size > 0)
"1916030601ff090105090100d192dc061473000173017302", // { val b = bigInt("-1"); val m = unsignedBigInt("5"); val ub = b.toUnsignedMod(m); ub >= 0 }
"190d00d193db0207e4e30102850880" // { val b = getVar[Byte](1).get; b.toBits == Coll(false, false, false, false, false, false, false, true) }
// todo: scripts with optional / Header values
)

val activatedVersion = 3.toByte
val params = new Parameters(0, LaunchParameters.parametersTable.updated(123, activatedVersion + 1), ErgoValidationSettingsUpdate.empty)
trees.foreach { tree =>
val activatedVersion = 3.toByte
val params = new Parameters(0, LaunchParameters.parametersTable.updated(123, activatedVersion + 1), ErgoValidationSettingsUpdate.empty)

// for next version, rule 1011 should be replaced , otherwise transaction validation will fail
// in this test, the rule is replaced with self, but for real activation this choice should be revised
val ruleId = CheckAndGetMethod.id
val updVs = ErgoValidationSettings.initial.updated(ErgoValidationSettingsUpdate(Seq(), Seq(ruleId -> ReplacedRule(ruleId))))
// for next version, rule 1011 should be replaced , otherwise transaction validation will fail
// in this test, the rule is replaced with self, but for real activation this choice should be revised
val ruleId = CheckAndGetMethod.id
val updVs = ErgoValidationSettings.initial.updated(ErgoValidationSettingsUpdate(Seq(), Seq(ruleId -> ReplacedRule(ruleId), 1007.toShort -> ReplacedRule(ruleId))))

val stateContext = emptyStateContext.copy(currentParameters = params, validationSettings = updVs)(chainSettings)
stateContext.blockVersion shouldBe activatedVersion + 1
val stateContext = emptyStateContext.copy(currentParameters = params, validationSettings = updVs)(chainSettings)
stateContext.blockVersion shouldBe activatedVersion + 1

// the following ergo tree contains SBigInt.nbits method which is not supported by this client (as of 5.x version)
// ergo tree version is 3, less value (e.g. version = 2 which gives 1a130206022edf0580fcf622d193db060873007301)
// also works
val ergoTree = DefaultSerializer.deserializeErgoTree(Base16.decode("1b130206022edf0580fcf622d193db060873007301").get)
// the following ergo tree contains a method or a type which is not supported by this client (as of 5.x version)
val ergoTree = DefaultSerializer.deserializeErgoTree(Base16.decode(tree).get)

ergoTree.root.isLeft shouldBe true // unparsed
ergoTree.root.isLeft shouldBe true // unparsed

val b = new ErgoBox(1000000000L, ergoTree, Colls.emptyColl,
Map.empty, ModifierId @@ "c95c2ccf55e03cac6659f71ca4df832d28e2375569cec178dcb17f3e2e5f7742",
0, 0)
val input = Input(b.id, ProverResult(Array.emptyByteArray, ContextExtension.empty))
val b = new ErgoBox(1000000000L, ergoTree, Colls.emptyColl,
Map.empty, ModifierId @@ "c95c2ccf55e03cac6659f71ca4df832d28e2375569cec178dcb17f3e2e5f7742",
0, 0)
val input = Input(b.id, ProverResult(Array.emptyByteArray, ContextExtension.empty))

val oc = new ErgoBoxCandidate(b.value, b.ergoTree, b.creationHeight)
val oc = new ErgoBoxCandidate(b.value, b.ergoTree, b.creationHeight)

val utx = new ErgoTransaction(IndexedSeq(input), IndexedSeq.empty, IndexedSeq(oc))
val utx = new ErgoTransaction(IndexedSeq(input), IndexedSeq.empty, IndexedSeq(oc))

utx.statefulValidity(IndexedSeq(b), IndexedSeq.empty, stateContext, 0)(defaultProver).isSuccess shouldBe true
utx.statefulValidity(IndexedSeq(b), IndexedSeq.empty, stateContext, 0)(defaultProver).isSuccess shouldBe true
}
}

}
Loading