From 7159df8e6bbc922b534004b2b3b6b2fb7f3255f5 Mon Sep 17 00:00:00 2001 From: Chris Stewart Date: Thu, 7 Jan 2016 22:07:03 -0600 Subject: [PATCH] fixing compliation issue, adding unit tests for parsing --- .../org/scalacoin/script/parsing/ScriptParser.scala | 2 +- .../scalacoin/script/parsing/ScriptParserTest.scala | 7 ++++++- src/test/scala/org/scalacoin/util/TestUtil.scala | 12 ++++++------ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/main/scala/org/scalacoin/script/parsing/ScriptParser.scala b/src/main/scala/org/scalacoin/script/parsing/ScriptParser.scala index a8422f16d8..6a23323a7e 100644 --- a/src/main/scala/org/scalacoin/script/parsing/ScriptParser.scala +++ b/src/main/scala/org/scalacoin/script/parsing/ScriptParser.scala @@ -7,7 +7,7 @@ trait ScriptParser { /** - * Parses a script inside of a transaction + * Parses a script inside of a transaction * @param str * @tparam T * @return diff --git a/src/test/scala/org/scalacoin/script/parsing/ScriptParserTest.scala b/src/test/scala/org/scalacoin/script/parsing/ScriptParserTest.scala index 682dc2222d..b095bbce03 100644 --- a/src/test/scala/org/scalacoin/script/parsing/ScriptParserTest.scala +++ b/src/test/scala/org/scalacoin/script/parsing/ScriptParserTest.scala @@ -10,7 +10,12 @@ class ScriptParserTest extends FlatSpec with MustMatchers with ScriptParser { "ScriptParser" must "parse an input script" in { - val parsedInput = parse(TestUtil.p2khInputScriptNotParsed) + val parsedInput = parse(TestUtil.p2pkhInputScriptNotParsed) parsedInput must be (TestUtil.p2pkhInputScript) } + + it must "parse an output script" in { + val parsedOutput = parse(TestUtil.p2pkhOutputScriptNotParsed) + parsedOutput must be (TestUtil.p2pkhOutputScript) + } } diff --git a/src/test/scala/org/scalacoin/util/TestUtil.scala b/src/test/scala/org/scalacoin/util/TestUtil.scala index 94e1470fbf..df1590e3e4 100644 --- a/src/test/scala/org/scalacoin/util/TestUtil.scala +++ b/src/test/scala/org/scalacoin/util/TestUtil.scala @@ -17,11 +17,11 @@ object TestUtil { val multiSigAddress = BitcoinAddress("342ftSRCvFHfCeFFBuz4xwbeqnDw6BGUey") val assetAddress = AssetAddress("akJsoCcyh34FGPotxfEoSXGwFPCNAkyCgTA") - val p2khInputScriptNotParsed = + val p2pkhInputScriptNotParsed = "3044022016ffdbb7c57634903c5e018fcfc48d59f4e37dc4bc3bbc9ba4e6ee39150bca030220119c2241a931819bc1a75d3596e4029d803d1cd6de123bf8a1a1a2c3665e1fac01" + - " 02af7dad03e682fcd0427b5c24140c220ac9d8abe286c15f8cf5bf77eed19c365 - val p2khInputScript = List("3044022016ffdbb7c57634903c5e018fcfc48d59f4e37dc4bc3bbc9ba4e6ee39150bca030220119c2241a931819bc1a75d3596e4029d803d1cd6de123bf8a1a1a2c3665e1fac01", - "02af7dad03e682fcd0427b5c24140c220ac9d8abe286c15f8cf5bf77eed19c3652")2" - val p2pkhOutputScriptNotParsed = "OP_DUP OP_HASH160 e2e7c1ab3f807151e832dd1accb3d4f5d7d19b4b OP_EQUALVERIFY OP_CHECKSI - val p2khOutputScript = List(OP_DUP,OP_HASH160,ConstantImpl("e2e7c1ab3f807151e832dd1accb3d4f5d7d19b4b"),OP_EQUALVERIFY, OP_CHECKSIG) + " 02af7dad03e682fcd0427b5c24140c220ac9d8abe286c15f8cf5bf77eed19c365" + val p2pkhInputScript = List("3044022016ffdbb7c57634903c5e018fcfc48d59f4e37dc4bc3bbc9ba4e6ee39150bca030220119c2241a931819bc1a75d3596e4029d803d1cd6de123bf8a1a1a2c3665e1fac01", + "02af7dad03e682fcd0427b5c24140c220ac9d8abe286c15f8cf5bf77eed19c3652") + val p2pkhOutputScriptNotParsed = "OP_DUP OP_HASH160 e2e7c1ab3f807151e832dd1accb3d4f5d7d19b4b OP_EQUALVERIFY OP_CHECKSIG" + val p2pkhOutputScript = List(OP_DUP,OP_HASH160,ConstantImpl("e2e7c1ab3f807151e832dd1accb3d4f5d7d19b4b"),OP_EQUALVERIFY, OP_CHECKSIG) }