From 82d5713549b58980a2b6701c31e775d71a9e7ce6 Mon Sep 17 00:00:00 2001 From: Chris Stewart Date: Mon, 21 Mar 2016 15:41:15 -0500 Subject: [PATCH] Fixing bug where single OP_0 was being classified as a MultiSignatureScriptSig --- .../protocol/script/ScriptSignatureFactoryTest.scala | 11 +++++++++++ .../script/interpreter/ScriptInterpreterTest.scala | 6 +++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/test/scala/org/scalacoin/protocol/script/ScriptSignatureFactoryTest.scala b/src/test/scala/org/scalacoin/protocol/script/ScriptSignatureFactoryTest.scala index 6eece03a8f..d20fb9379e 100644 --- a/src/test/scala/org/scalacoin/protocol/script/ScriptSignatureFactoryTest.scala +++ b/src/test/scala/org/scalacoin/protocol/script/ScriptSignatureFactoryTest.scala @@ -22,6 +22,15 @@ class ScriptSignatureFactoryTest extends FlatSpec with MustMatchers { } + it must "given a single 0 a scriptSignature type of non standard" in { + val scriptSig = ScriptSignatureFactory.fromHex("00") + val result = scriptSig match { + case _ : NonStandardScriptSignature => true + case _ => false + } + + result must be (true) + } it must "build a script signature from a digital signature and a public key" in { val digitalSignatureBytes = TestUtil.p2pkhInputScriptAsm(1).bytes val digitalSignature : ECDigitalSignature = ECFactory.digitalSignature(digitalSignatureBytes) @@ -51,4 +60,6 @@ class ScriptSignatureFactoryTest extends FlatSpec with MustMatchers { } + + } diff --git a/src/test/scala/org/scalacoin/script/interpreter/ScriptInterpreterTest.scala b/src/test/scala/org/scalacoin/script/interpreter/ScriptInterpreterTest.scala index ec194eee00..778818ba56 100644 --- a/src/test/scala/org/scalacoin/script/interpreter/ScriptInterpreterTest.scala +++ b/src/test/scala/org/scalacoin/script/interpreter/ScriptInterpreterTest.scala @@ -84,7 +84,7 @@ class ScriptInterpreterTest extends FlatSpec with MustMatchers with ScriptInterp val source = scala.io.Source.fromFile("src/test/scala/org/scalacoin/script/interpreter/script_valid.json") //use this to represent a single test case from script_valid.json - val lines = +/* val lines = """ | |[[ @@ -93,9 +93,9 @@ class ScriptInterpreterTest extends FlatSpec with MustMatchers with ScriptInterp "P2SH", "P2SH(2-of-3)" ]] - """.stripMargin + """.stripMargin*/ - //val lines = try source.getLines.filterNot(_.isEmpty).map(_.trim) mkString "\n" finally source.close() + val lines = try source.getLines.filterNot(_.isEmpty).map(_.trim) mkString "\n" finally source.close() val json = lines.parseJson val testCasesOpt : Seq[Option[CoreTestCase]] = json.convertTo[Seq[Option[CoreTestCase]]] val testCases : Seq[CoreTestCase] = testCasesOpt.flatten