deprecate/improve some factories: arithmetic, scriptConstant, locktimeOperation, StackOperation

This commit is contained in:
Tom McCabe 2016-04-25 15:21:48 -05:00
parent 148675c546
commit 19f552dd15
19 changed files with 108 additions and 73 deletions

View file

@ -218,7 +218,7 @@ trait ScriptParser extends Factory[List[ScriptToken]] with BitcoinSLogger {
if (g.group(1).size <= 16) { if (g.group(1).size <= 16) {
ScriptNumber(g.group(1)) ScriptNumber(g.group(1))
} else { } else {
ScriptConstantFactory.fromHex(g.group(1)) ScriptConstant(g.group(1))
}).toList) }).toList)
scriptConstants scriptConstants
} }
@ -269,7 +269,7 @@ trait ScriptParser extends Factory[List[ScriptToken]] with BitcoinSLogger {
//next byte is size of the script constant //next byte is size of the script constant
val bytesToPushOntoStack = ScriptNumber(Integer.parseInt(BitcoinSUtil.encodeHex(tail.head),16)) val bytesToPushOntoStack = ScriptNumber(Integer.parseInt(BitcoinSUtil.encodeHex(tail.head),16))
val scriptConstantBytes = tail.slice(1,(bytesToPushOntoStack.num+1).toInt) val scriptConstantBytes = tail.slice(1,(bytesToPushOntoStack.num+1).toInt)
val scriptConstant = ScriptConstantFactory.fromBytes(scriptConstantBytes) val scriptConstant = ScriptConstant(scriptConstantBytes)
val restOfBytes = tail.slice((bytesToPushOntoStack.num+1).toInt,tail.size) val restOfBytes = tail.slice((bytesToPushOntoStack.num+1).toInt,tail.size)
buildParsingHelper(op,bytesToPushOntoStack,scriptConstant,restOfBytes,accum) buildParsingHelper(op,bytesToPushOntoStack,scriptConstant,restOfBytes,accum)
case OP_PUSHDATA2 => case OP_PUSHDATA2 =>
@ -277,7 +277,7 @@ trait ScriptParser extends Factory[List[ScriptToken]] with BitcoinSLogger {
val scriptConstantHex = BitcoinSUtil.flipEndianess(tail.slice(0,2)) val scriptConstantHex = BitcoinSUtil.flipEndianess(tail.slice(0,2))
val bytesToPushOntoStack = ScriptNumber(Integer.parseInt(scriptConstantHex,16)) val bytesToPushOntoStack = ScriptNumber(Integer.parseInt(scriptConstantHex,16))
val scriptConstantBytes = tail.slice(2,(bytesToPushOntoStack.num + 2).toInt) val scriptConstantBytes = tail.slice(2,(bytesToPushOntoStack.num + 2).toInt)
val scriptConstant = ScriptConstantFactory.fromBytes(scriptConstantBytes) val scriptConstant = ScriptConstant(scriptConstantBytes)
val restOfBytes = tail.slice((bytesToPushOntoStack.num + 2).toInt,tail.size) val restOfBytes = tail.slice((bytesToPushOntoStack.num + 2).toInt,tail.size)
buildParsingHelper(op,bytesToPushOntoStack,scriptConstant,restOfBytes,accum) buildParsingHelper(op,bytesToPushOntoStack,scriptConstant,restOfBytes,accum)
case OP_PUSHDATA4 => case OP_PUSHDATA4 =>
@ -285,7 +285,7 @@ trait ScriptParser extends Factory[List[ScriptToken]] with BitcoinSLogger {
val scriptConstantHex = BitcoinSUtil.flipEndianess(tail.slice(0,4)) val scriptConstantHex = BitcoinSUtil.flipEndianess(tail.slice(0,4))
val bytesToPushOntoStack = ScriptNumber(Integer.parseInt(scriptConstantHex, 16)) val bytesToPushOntoStack = ScriptNumber(Integer.parseInt(scriptConstantHex, 16))
val scriptConstantBytes = tail.slice(4,bytesToPushOntoStack.num.toInt + 4) val scriptConstantBytes = tail.slice(4,bytesToPushOntoStack.num.toInt + 4)
val scriptConstant = ScriptConstantFactory.fromBytes(scriptConstantBytes) val scriptConstant = ScriptConstant(scriptConstantBytes)
val restOfBytes = tail.slice(bytesToPushOntoStack.num.toInt + 4,tail.size) val restOfBytes = tail.slice(bytesToPushOntoStack.num.toInt + 4,tail.size)
buildParsingHelper(op,bytesToPushOntoStack,scriptConstant,restOfBytes,accum) buildParsingHelper(op,bytesToPushOntoStack,scriptConstant,restOfBytes,accum)
case _ : ScriptToken => throw new RuntimeException("parseOpPushData can only parse OP_PUSHDATA operations") case _ : ScriptToken => throw new RuntimeException("parseOpPushData can only parse OP_PUSHDATA operations")

View file

@ -1,14 +1,15 @@
package org.scalacoin.script package org.scalacoin.script
import org.scalacoin.script.arithmetic.ArithmeticOperationsFactory //import org.scalacoin.script.arithmetic.{ArithmeticOperations}
import org.scalacoin.script.arithmetic.ArithmeticOperation
import org.scalacoin.script.bitwise.BitwiseOperationsFactory import org.scalacoin.script.bitwise.BitwiseOperationsFactory
import org.scalacoin.script.constant._ import org.scalacoin.script.constant._
import org.scalacoin.script.control.ControlOperationsFactory import org.scalacoin.script.control.ControlOperationsFactory
import org.scalacoin.script.crypto.CryptoOperationFactory import org.scalacoin.script.crypto.CryptoOperationFactory
import org.scalacoin.script.locktime.LocktimeOperationFactory import org.scalacoin.script.locktime.LocktimeOperation
import org.scalacoin.script.reserved.ReservedOperationFactory import org.scalacoin.script.reserved.ReservedOperationFactory
import org.scalacoin.script.splice.SpliceOperationsFactory import org.scalacoin.script.splice.SpliceOperationsFactory
import org.scalacoin.script.stack.StackOperationFactory import org.scalacoin.script.stack.StackOperation
import org.scalacoin.util.{BitcoinSUtil, BitcoinSLogger} import org.scalacoin.util.{BitcoinSUtil, BitcoinSLogger}
import org.slf4j.LoggerFactory import org.slf4j.LoggerFactory
@ -21,14 +22,16 @@ trait ScriptOperationFactory[T <: ScriptOperation] extends BitcoinSLogger {
/** /**
* All of the script operations for a particular T * All of the script operations for a particular T
* @tparam T *
* @tparam T
* @return * @return
*/ */
def operations : Seq[T] def operations : Seq[T]
/** /**
* Finds a script operation from a given string * Finds a script operation from a given string
* @param str *
* @param str
* @return * @return
*/ */
def fromString(str : String) : Option[T] = { def fromString(str : String) : Option[T] = {
@ -41,7 +44,8 @@ trait ScriptOperationFactory[T <: ScriptOperation] extends BitcoinSLogger {
/** /**
* Finds a script operation from its hexadecimal representation * Finds a script operation from its hexadecimal representation
* @param hex *
* @param hex
* @return * @return
*/ */
def fromHex(hex : String) : Option[T] = operations.find(_.hex == hex.toLowerCase) def fromHex(hex : String) : Option[T] = operations.find(_.hex == hex.toLowerCase)
@ -49,7 +53,8 @@ trait ScriptOperationFactory[T <: ScriptOperation] extends BitcoinSLogger {
/** /**
* Removes the 'OP_' prefix from a given operation. * Removes the 'OP_' prefix from a given operation.
* Example: OP_EQUALVERIFY would be transformed into EQUALVERIFY * Example: OP_EQUALVERIFY would be transformed into EQUALVERIFY
* @param str *
* @param str
* @return * @return
*/ */
private def removeOP_Prefix(str : String) : String = { private def removeOP_Prefix(str : String) : String = {
@ -58,7 +63,8 @@ trait ScriptOperationFactory[T <: ScriptOperation] extends BitcoinSLogger {
/** /**
* Finds a script operation from a given byte * Finds a script operation from a given byte
* @param byte *
* @param byte
* @return * @return
*/ */
def fromByte(byte : Byte) : Option[T] = { def fromByte(byte : Byte) : Option[T] = {
@ -74,9 +80,9 @@ trait ScriptOperationFactory[T <: ScriptOperation] extends BitcoinSLogger {
object ScriptOperation extends ScriptOperationFactory[ScriptOperation] { object ScriptOperation extends ScriptOperationFactory[ScriptOperation] {
lazy val operations = ScriptNumberOperation.operations ++ Seq(OP_FALSE,OP_PUSHDATA1, OP_PUSHDATA2,OP_PUSHDATA4,OP_TRUE) ++ StackOperationFactory.operations ++ LocktimeOperationFactory.operations ++ lazy val operations = ScriptNumberOperation.operations ++ Seq(OP_FALSE,OP_PUSHDATA1, OP_PUSHDATA2,OP_PUSHDATA4,OP_TRUE) ++ StackOperation.operations ++ LocktimeOperation.operations ++
CryptoOperationFactory.operations ++ ControlOperationsFactory.operations ++ BitwiseOperationsFactory.operations ++ CryptoOperationFactory.operations ++ ControlOperationsFactory.operations ++ BitwiseOperationsFactory.operations ++
ArithmeticOperationsFactory.operations ++ BytesToPushOntoStack.operations ++ SpliceOperationsFactory.operations ++ ArithmeticOperation.operations ++ BytesToPushOntoStack.operations ++ SpliceOperationsFactory.operations ++
ReservedOperationFactory.operations ReservedOperationFactory.operations
} }

View file

@ -1,5 +1,6 @@
package org.scalacoin.script.arithmetic package org.scalacoin.script.arithmetic
import org.scalacoin.script.ScriptOperationFactory
import org.scalacoin.script.constant.ScriptOperation import org.scalacoin.script.constant.ScriptOperation
/** /**
@ -201,7 +202,11 @@ case object OP_RSHIFT extends ArithmeticOperation {
override def opCode = 153 override def opCode = 153
} }
object ArithmeticOperation extends ScriptOperationFactory[ArithmeticOperation] {
override def operations = Seq(OP_0NOTEQUAL, OP_1ADD, OP_1SUB, OP_ABS, OP_ADD, OP_BOOLAND, OP_BOOLOR,
OP_GREATERTHAN, OP_GREATERTHANOREQUAL, OP_LESSTHAN, OP_LESSTHANOREQUAL, OP_MAX, OP_MIN, OP_NEGATE,
OP_NEGATE, OP_NOT, OP_NUMEQUAL, OP_NUMEQUALVERIFY, OP_NUMNOTEQUAL, OP_SUB, OP_WITHIN,
OP_2MUL,OP_2DIV,OP_MUL,OP_DIV, OP_MOD, OP_LSHIFT, OP_RSHIFT)
}

View file

@ -87,7 +87,7 @@ trait ConstantInterpreter extends BitcoinSLogger {
logger.debug("new script: " + newScript) logger.debug("new script: " + newScript)
logger.debug("Bytes to push onto stack" + bytesToPushOntoStack) logger.debug("Bytes to push onto stack" + bytesToPushOntoStack)
val constant : ScriptToken = if (bytesToPushOntoStack.size == 1) bytesToPushOntoStack.head val constant : ScriptToken = if (bytesToPushOntoStack.size == 1) bytesToPushOntoStack.head
else ScriptConstantFactory.fromHex(BitcoinSUtil.flipEndianess(bytesToPushOntoStack.flatMap(_.bytes))) else ScriptConstant(BitcoinSUtil.flipEndianess(bytesToPushOntoStack.flatMap(_.bytes)))
logger.debug("Constant to be pushed onto stack: " + constant) logger.debug("Constant to be pushed onto stack: " + constant)
//check to see if we have the exact amount of bytes needed to be pushed onto the stack //check to see if we have the exact amount of bytes needed to be pushed onto the stack

View file

@ -386,5 +386,18 @@ object ScriptNumberOperation extends ScriptOperationFactory[ScriptNumberOperatio
} }
object ScriptConstant extends Factory[ScriptConstant] {
lazy val zero = ScriptConstant("00")
lazy val negativeZero = ScriptConstant("80")
lazy val negativeOne = ScriptConstant("81")
/**
* Creates a script constant from a sequence of bytes
* @param bytes
* @return
*/
def fromBytes(bytes : Seq[Byte]) : ScriptConstant = ScriptConstantImpl(BitcoinSUtil.encodeHex(bytes))
def apply(hex : String) : ScriptConstant = fromHex(hex)
def apply(bytes : Seq[Byte]) : ScriptConstant = fromBytes(bytes)
}

View file

@ -270,7 +270,7 @@ trait CryptoInterpreter extends ControlOperationsInterpreter with BitcoinSLogger
private def executeHashFunction(program : ScriptProgram, hashFunction : List[Byte] => List[Byte]) : ScriptProgram = { private def executeHashFunction(program : ScriptProgram, hashFunction : List[Byte] => List[Byte]) : ScriptProgram = {
if (program.stack.headOption.isDefined) { if (program.stack.headOption.isDefined) {
val stackTop = program.stack.head val stackTop = program.stack.head
val hash = ScriptConstantFactory.fromBytes(hashFunction(stackTop.bytes)) val hash = ScriptConstant(hashFunction(stackTop.bytes))
ScriptProgram(program, hash :: program.stack.tail, program.script.tail) ScriptProgram(program, hash :: program.stack.tail, program.script.tail)
} else { } else {
logger.error("We must have the stack top defined to execute a hash function") logger.error("We must have the stack top defined to execute a hash function")

View file

@ -1,5 +1,6 @@
package org.scalacoin.script.locktime package org.scalacoin.script.locktime
import org.scalacoin.script.ScriptOperationFactory
import org.scalacoin.script.constant.ScriptOperation import org.scalacoin.script.constant.ScriptOperation
/** /**
@ -19,3 +20,7 @@ sealed trait LocktimeOperation extends ScriptOperation
case object OP_CHECKLOCKTIMEVERIFY extends LocktimeOperation { case object OP_CHECKLOCKTIMEVERIFY extends LocktimeOperation {
override def opCode = 177 override def opCode = 177
} }
object LocktimeOperation extends ScriptOperationFactory[LocktimeOperation] {
override def operations = Seq(OP_CHECKLOCKTIMEVERIFY)
}

View file

@ -143,4 +143,10 @@ case object OP_2SWAP extends StackOperation {
override def opCode = 114 override def opCode = 114
} }
object StackOperation extends ScriptOperationFactory[StackOperation] {
override def operations = Seq(OP_TOALTSTACK,OP_FROMALTSTACK,OP_IFDUP,OP_DEPTH,
OP_DEPTH,OP_DROP,OP_DUP,OP_NIP,OP_OVER,OP_ROLL,OP_ROT,OP_SWAP,OP_TUCK,OP_2DROP,OP_2DUP,
OP_3DUP,OP_2OVER,OP_2ROT,OP_2SWAP, OP_PICK)
}

View file

@ -148,7 +148,7 @@ trait BitcoinScriptUtil {
def isMinimalPush(pushOp : ScriptToken, token : ScriptToken) : Boolean = token match { def isMinimalPush(pushOp : ScriptToken, token : ScriptToken) : Boolean = token match {
case scriptNumOp : ScriptNumberOperation => case scriptNumOp : ScriptNumberOperation =>
scriptNumOp == pushOp scriptNumOp == pushOp
case ScriptConstantFactory.zero | ScriptConstantFactory.negativeZero => case ScriptConstant.zero | ScriptConstant.negativeZero =>
//weird case where OP_0 pushes an empty byte vector on the stack, NOT "00" or "81" //weird case where OP_0 pushes an empty byte vector on the stack, NOT "00" or "81"
//so we can push the constant "00" or "81" onto the stack with a BytesToPushOntoStack pushop //so we can push the constant "00" or "81" onto the stack with a BytesToPushOntoStack pushop
pushOp == BytesToPushOntoStack(1).get pushOp == BytesToPushOntoStack(1).get

View file

@ -62,12 +62,12 @@ class ScriptParserTest extends FlatSpec with MustMatchers with ScriptParser with
it must "parse a script constant from 'Az' EQUAL" in { it must "parse a script constant from 'Az' EQUAL" in {
val str = "'Az' EQUAL" val str = "'Az' EQUAL"
fromString(str) must equal (List(BytesToPushOntoStack(2).get, ScriptConstantFactory.fromHex("417a"), OP_EQUAL)) fromString(str) must equal (List(BytesToPushOntoStack(2).get, ScriptConstant("417a"), OP_EQUAL))
} }
it must "parse a script number that has a leading zero" in { it must "parse a script number that has a leading zero" in {
val str = "0x02 0x0100" val str = "0x02 0x0100"
fromString(str) must equal (List(BytesToPushOntoStack(2).get, ScriptConstantFactory.fromHex("0100"))) fromString(str) must equal (List(BytesToPushOntoStack(2).get, ScriptConstant("0100")))
} }
@ -83,8 +83,8 @@ class ScriptParserTest extends FlatSpec with MustMatchers with ScriptParser with
it must "parse a script that has a decimal and a hexadecimal number in it " in { it must "parse a script that has a decimal and a hexadecimal number in it " in {
val str = "32767 0x02 0xff7f EQUAL" val str = "32767 0x02 0xff7f EQUAL"
fromString(str) must equal (List(BytesToPushOntoStack(2).get, ScriptConstantFactory.fromHex("ff7f"), fromString(str) must equal (List(BytesToPushOntoStack(2).get, ScriptConstant("ff7f"),
BytesToPushOntoStackImpl(2), ScriptConstantFactory.fromHex("ff7f"), OP_EQUAL)) BytesToPushOntoStackImpl(2), ScriptConstant("ff7f"), OP_EQUAL))
} }
it must "parse an OP_1" in { it must "parse an OP_1" in {
val str = "0x51" val str = "0x51"
@ -96,14 +96,14 @@ class ScriptParserTest extends FlatSpec with MustMatchers with ScriptParser with
"'Azzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz' EQUAL" "'Azzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz' EQUAL"
fromString(str) must equal (List(BytesToPushOntoStack(75).get, fromString(str) must equal (List(BytesToPushOntoStack(75).get,
ScriptConstantFactory.fromHex("417a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a"), ScriptConstant("417a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a"),
BytesToPushOntoStack(75).get, BytesToPushOntoStack(75).get,
ScriptConstantFactory.fromHex("417a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a"), OP_EQUAL)) ScriptConstant("417a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a"), OP_EQUAL))
} }
it must "parse an OP_IF OP_ENDIF block" in { it must "parse an OP_IF OP_ENDIF block" in {
val str = "1 0x01 0x80 IF 0 ENDIF" val str = "1 0x01 0x80 IF 0 ENDIF"
fromString(str) must be (List(OP_1, BytesToPushOntoStackImpl(1), ScriptConstantFactory.fromHex("80"), OP_IF, OP_0, OP_ENDIF)) fromString(str) must be (List(OP_1, BytesToPushOntoStackImpl(1), ScriptConstant("80"), OP_IF, OP_0, OP_ENDIF))
} }
@ -119,7 +119,7 @@ class ScriptParserTest extends FlatSpec with MustMatchers with ScriptParser with
val str = "4cf1" + val str = "4cf1" +
"55210269992fb441ae56968e5b77d46a3e53b69f136444ae65a94041fc937bdb28d93321021df31471281d4478df85bfce08a10aab82601dca949a79950f8ddf7002bd915a2102174c82021492c2c6dfcbfa4187d10d38bed06afb7fdcd72c880179fddd641ea121033f96e43d72c33327b6a4631ccaa6ea07f0b106c88b9dc71c9000bb6044d5e88a210313d8748790f2a86fb524579b46ce3c68fedd58d2a738716249a9f7d5458a15c221030b632eeb079eb83648886122a04c7bf6d98ab5dfb94cf353ee3e9382a4c2fab02102fb54a7fcaa73c307cfd70f3fa66a2e4247a71858ca731396343ad30c7c4009ce57ae" "55210269992fb441ae56968e5b77d46a3e53b69f136444ae65a94041fc937bdb28d93321021df31471281d4478df85bfce08a10aab82601dca949a79950f8ddf7002bd915a2102174c82021492c2c6dfcbfa4187d10d38bed06afb7fdcd72c880179fddd641ea121033f96e43d72c33327b6a4631ccaa6ea07f0b106c88b9dc71c9000bb6044d5e88a210313d8748790f2a86fb524579b46ce3c68fedd58d2a738716249a9f7d5458a15c221030b632eeb079eb83648886122a04c7bf6d98ab5dfb94cf353ee3e9382a4c2fab02102fb54a7fcaa73c307cfd70f3fa66a2e4247a71858ca731396343ad30c7c4009ce57ae"
fromString(str) must be (List(OP_PUSHDATA1, ScriptNumber(241), fromString(str) must be (List(OP_PUSHDATA1, ScriptNumber(241),
ScriptConstantFactory.fromHex("55210269992fb441ae56968e5b77d46a3e53b69f136444ae65a94041fc937bdb28d93321021df31471281d4478df85bfce08a10aab82601dca949a79950f8ddf7002bd915a2102174c82021492c2c6dfcbfa4187d10d38bed06afb7fdcd72c880179fddd641ea121033f96e43d72c33327b6a4631ccaa6ea07f0b106c88b9dc71c9000bb6044d5e88a210313d8748790f2a86fb524579b46ce3c68fedd58d2a738716249a9f7d5458a15c221030b632eeb079eb83648886122a04c7bf6d98ab5dfb94cf353ee3e9382a4c2fab02102fb54a7fcaa73c307cfd70f3fa66a2e4247a71858ca731396343ad30c7c4009ce57ae")) ScriptConstant("55210269992fb441ae56968e5b77d46a3e53b69f136444ae65a94041fc937bdb28d93321021df31471281d4478df85bfce08a10aab82601dca949a79950f8ddf7002bd915a2102174c82021492c2c6dfcbfa4187d10d38bed06afb7fdcd72c880179fddd641ea121033f96e43d72c33327b6a4631ccaa6ea07f0b106c88b9dc71c9000bb6044d5e88a210313d8748790f2a86fb524579b46ce3c68fedd58d2a738716249a9f7d5458a15c221030b632eeb079eb83648886122a04c7bf6d98ab5dfb94cf353ee3e9382a4c2fab02102fb54a7fcaa73c307cfd70f3fa66a2e4247a71858ca731396343ad30c7c4009ce57ae"))
) )
} }
@ -135,13 +135,13 @@ class ScriptParserTest extends FlatSpec with MustMatchers with ScriptParser with
"0x4c 0xFF 0x111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 " + "0x4c 0xFF 0x111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 " +
"EQUAL" "EQUAL"
val expectedScript = List(OP_PUSHDATA2, ScriptNumber(255), val expectedScript = List(OP_PUSHDATA2, ScriptNumber(255),
ScriptConstantFactory.fromHex("111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" + ScriptConstant("111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" +
"11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" + "11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" +
"11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" + "11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" +
"11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" + "11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" +
"11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" + "11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" +
"1111111"), OP_PUSHDATA1, ScriptNumber(255), "1111111"), OP_PUSHDATA1, ScriptNumber(255),
ScriptConstantFactory.fromHex("111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" + ScriptConstant("111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" +
"11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" + "11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" +
"11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" + "11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" +
"11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" + "11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" +
@ -195,7 +195,7 @@ class ScriptParserTest extends FlatSpec with MustMatchers with ScriptParser with
it must "parse a large string constant found inside of script_valid.json" in { it must "parse a large string constant found inside of script_valid.json" in {
val str = "'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'" val str = "'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'"
val parsed = fromString(str) val parsed = fromString(str)
parsed must be (List(OP_PUSHDATA2, ScriptNumber(520), ScriptConstantFactory.fromHex( parsed must be (List(OP_PUSHDATA2, ScriptNumber(520), ScriptConstant(
"62626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262" "62626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262"
))) )))
} }

View file

@ -1,7 +1,7 @@
package org.scalacoin.protocol.script package org.scalacoin.protocol.script
import org.scalacoin.crypto._ import org.scalacoin.crypto._
import org.scalacoin.script.constant.{ScriptConstantFactory, ScriptConstant} import org.scalacoin.script.constant.{ScriptConstant}
import org.scalacoin.util.{TestUtil, BitcoinSUtil} import org.scalacoin.util.{TestUtil, BitcoinSUtil}
import org.scalatest.{FlatSpec, MustMatchers} import org.scalatest.{FlatSpec, MustMatchers}

View file

@ -1,6 +1,6 @@
package org.scalacoin.script package org.scalacoin.script
import org.scalacoin.script.constant.ScriptConstantFactory import org.scalacoin.script.constant.ScriptConstant
import org.scalacoin.util.BitcoinSUtil import org.scalacoin.util.BitcoinSUtil
import org.scalatest.{MustMatchers, FlatSpec} import org.scalatest.{MustMatchers, FlatSpec}
@ -11,7 +11,7 @@ class ScriptConstantFactoryTest extends FlatSpec with MustMatchers {
"ScriptConstantFactory" must "create a constant from bytes" in { "ScriptConstantFactory" must "create a constant from bytes" in {
val bytes = BitcoinSUtil.decodeHex("abc123") val bytes = BitcoinSUtil.decodeHex("abc123")
ScriptConstantFactory.fromBytes(bytes).bytes must be (bytes) ScriptConstant(bytes).bytes must be (bytes)
} }
} }

View file

@ -372,8 +372,8 @@ class ArithmeticInterpreterTest extends FlatSpec with MustMatchers with Arithmet
it must "interpret two script constants as numbers and then add them" in { it must "interpret two script constants as numbers and then add them" in {
val scriptConstant1 = ScriptConstantFactory.fromHex("ffffffff") val scriptConstant1 = ScriptConstant("ffffffff")
val scriptConstant2 = ScriptConstantFactory.fromHex("ffffff7f") val scriptConstant2 = ScriptConstant("ffffff7f")
val stack = List(scriptConstant1, scriptConstant2) val stack = List(scriptConstant1, scriptConstant2)
val script = List(OP_ADD) val script = List(OP_ADD)
val program = ScriptProgram(TestUtil.testProgram, stack, script) val program = ScriptProgram(TestUtil.testProgram, stack, script)

View file

@ -5,11 +5,11 @@ import org.scalatest.{MustMatchers, FlatSpec}
/** /**
* Created by chris on 1/8/16. * Created by chris on 1/8/16.
*/ */
class ArithmeticOperationsFactoryTest extends FlatSpec with MustMatchers with ArithmeticOperationsFactory { class ArithmeticOperationsFactoryTest extends FlatSpec with MustMatchers {
"ArithmeticOperationsFactory" must "match strings with arithmetic operations" in { "ArithmeticOperationsFactory" must "match strings with arithmetic operations" in {
fromString("OP_1ADD") must be (Some(OP_1ADD)) ArithmeticOperation.fromString("OP_1ADD") must be (Some(OP_1ADD))
fromString("OP_ADD") must be (Some(OP_ADD)) ArithmeticOperation.fromString("OP_ADD") must be (Some(OP_ADD))
fromString("OP_LESSTHAN") must be (Some(OP_LESSTHAN)) ArithmeticOperation.fromString("OP_LESSTHAN") must be (Some(OP_LESSTHAN))
fromString("OP_RANDOM") must be (None) ArithmeticOperation.fromString("OP_RANDOM") must be (None)
} }
} }

View file

@ -17,7 +17,7 @@ class ConstantInterpreterTest extends FlatSpec with MustMatchers with ConstantIn
"ConstantInterpreter" must "interpret OP_PUSHDATA1 correctly" in { "ConstantInterpreter" must "interpret OP_PUSHDATA1 correctly" in {
val byteConstantSize = 76 val byteConstantSize = 76
val byteConstant = for { x <- 0 until byteConstantSize} yield 0x0.toByte val byteConstant = for { x <- 0 until byteConstantSize} yield 0x0.toByte
val scriptConstant = ScriptConstantFactory.fromBytes(byteConstant) val scriptConstant = ScriptConstant(byteConstant)
val stack = List() val stack = List()
val script = List(OP_PUSHDATA1,ScriptNumber(byteConstantSize), scriptConstant,OP_7,OP_EQUAL) val script = List(OP_PUSHDATA1,ScriptNumber(byteConstantSize), scriptConstant,OP_7,OP_EQUAL)
val program = ScriptProgram(TestUtil.testProgramExecutionInProgress, stack,script) val program = ScriptProgram(TestUtil.testProgramExecutionInProgress, stack,script)
@ -30,7 +30,7 @@ class ConstantInterpreterTest extends FlatSpec with MustMatchers with ConstantIn
it must "interpret OP_PUSHDATA2 correctly" in { it must "interpret OP_PUSHDATA2 correctly" in {
val byteConstantSize = 256 val byteConstantSize = 256
val byteConstant = for { x <- 0 until byteConstantSize} yield 0x0.toByte val byteConstant = for { x <- 0 until byteConstantSize} yield 0x0.toByte
val scriptConstant = ScriptConstantFactory.fromBytes(byteConstant) val scriptConstant = ScriptConstant(byteConstant)
val stack = List() val stack = List()
val script = List(OP_PUSHDATA2, ScriptNumber(256), scriptConstant, OP_8, OP_EQUAL) val script = List(OP_PUSHDATA2, ScriptNumber(256), scriptConstant, OP_8, OP_EQUAL)
val program = ScriptProgram(TestUtil.testProgramExecutionInProgress, stack,script) val program = ScriptProgram(TestUtil.testProgramExecutionInProgress, stack,script)
@ -42,7 +42,7 @@ class ConstantInterpreterTest extends FlatSpec with MustMatchers with ConstantIn
it must "interpret OP_PUSHDATA4 correctly" in { it must "interpret OP_PUSHDATA4 correctly" in {
val byteConstantSize = 65536 val byteConstantSize = 65536
val byteConstant = for { x <- 0 until byteConstantSize} yield 0x0.toByte val byteConstant = for { x <- 0 until byteConstantSize} yield 0x0.toByte
val scriptConstant = ScriptConstantFactory.fromBytes(byteConstant) val scriptConstant = ScriptConstant(byteConstant)
val stack = List() val stack = List()
val script = List(OP_PUSHDATA4, ScriptNumber(byteConstantSize), scriptConstant, OP_9, OP_EQUAL) val script = List(OP_PUSHDATA4, ScriptNumber(byteConstantSize), scriptConstant, OP_9, OP_EQUAL)
val program = ScriptProgram(TestUtil.testProgramExecutionInProgress, stack,script) val program = ScriptProgram(TestUtil.testProgramExecutionInProgress, stack,script)
@ -58,7 +58,7 @@ class ConstantInterpreterTest extends FlatSpec with MustMatchers with ConstantIn
val program = ScriptProgram(TestUtil.testProgram, stack,script) val program = ScriptProgram(TestUtil.testProgram, stack,script)
val newProgram = pushScriptNumberBytesToStack(program) val newProgram = pushScriptNumberBytesToStack(program)
newProgram.script.isEmpty must be (true) newProgram.script.isEmpty must be (true)
newProgram.stack must be (List(ScriptConstantFactory.fromHex("0100"))) newProgram.stack must be (List(ScriptConstant("0100")))
} }
it must "push 0 bytes onto the stack which is OP_0" in { it must "push 0 bytes onto the stack which is OP_0" in {

View file

@ -5,10 +5,10 @@ import org.scalatest.{MustMatchers, FlatSpec}
/** /**
* Created by chris on 1/8/16. * Created by chris on 1/8/16.
*/ */
class LocktimeOperationFactoryTest extends FlatSpec with MustMatchers with LocktimeOperationFactory { class LocktimeOperationFactoryTest extends FlatSpec with MustMatchers {
"LocktimeOperationFactory" must "match lock time operations from strings" in { "LocktimeOperationFactory" must "match lock time operations from strings" in {
fromString("OP_CHECKLOCKTIMEVERIFY") must be (Some(OP_CHECKLOCKTIMEVERIFY)) LocktimeOperation.fromString("OP_CHECKLOCKTIMEVERIFY") must be (Some(OP_CHECKLOCKTIMEVERIFY))
} }
} }

View file

@ -31,7 +31,7 @@ class SpliceInterpreterTest extends FlatSpec with MustMatchers with SpliceInterp
} }
it must "evaluate an OP_SIZE correctly with 0x7f" in { it must "evaluate an OP_SIZE correctly with 0x7f" in {
val stack = List(ScriptConstantFactory.fromHex("7f")) val stack = List(ScriptConstant("7f"))
val script = List(OP_SIZE) val script = List(OP_SIZE)
val program = ScriptProgram(TestUtil.testProgram, stack,script) val program = ScriptProgram(TestUtil.testProgram, stack,script)
val newProgram = opSize(program) val newProgram = opSize(program)

View file

@ -5,12 +5,12 @@ import org.scalatest.{MustMatchers, FlatSpec}
/** /**
* Created by chris on 1/8/16. * Created by chris on 1/8/16.
*/ */
class StackOperationFactoryTest extends FlatSpec with MustMatchers with StackOperationFactory { class StackOperationFactoryTest extends FlatSpec with MustMatchers {
"StackOperationFactory" must "match correct operations with their strings" in { "StackOperationFactory" must "match correct operations with their strings" in {
fromString("OP_DUP") must be (Some(OP_DUP)) StackOperation.fromString("OP_DUP") must be (Some(OP_DUP))
fromString("OP_FROMALTSTACK") must be (Some(OP_FROMALTSTACK)) StackOperation.fromString("OP_FROMALTSTACK") must be (Some(OP_FROMALTSTACK))
fromString("RANDOM_OP") must be (None) StackOperation.fromString("RANDOM_OP") must be (None)
fromString("OP_IFDUP") must be (Some(OP_IFDUP)) StackOperation.fromString("OP_IFDUP") must be (Some(OP_IFDUP))
} }
} }

View file

@ -40,7 +40,7 @@ class BitcoinScriptUtilTest extends FlatSpec with MustMatchers {
} }
it must "not count script constants towards the script count limit" in { it must "not count script constants towards the script count limit" in {
BitcoinScriptUtil.countsTowardsScriptOpLimit(ScriptConstantFactory.fromHex("1234")) must be (false) BitcoinScriptUtil.countsTowardsScriptOpLimit(ScriptConstant("1234")) must be (false)
} }
it must "not count OP_PUSHDATA operations towards the script count" in { it must "not count OP_PUSHDATA operations towards the script count" in {
@ -52,7 +52,7 @@ class BitcoinScriptUtilTest extends FlatSpec with MustMatchers {
it must "count 0 sigops where there are none in a script" in { it must "count 0 sigops where there are none in a script" in {
val script = Seq() val script = Seq()
BitcoinScriptUtil.countSigOps(script) must be (0) BitcoinScriptUtil.countSigOps(script) must be (0)
BitcoinScriptUtil.countSigOps(Seq(OP_1,OP_2,ScriptConstantFactory.fromHex("1234"))) BitcoinScriptUtil.countSigOps(Seq(OP_1,OP_2,ScriptConstant("1234")))
} }
@ -101,7 +101,7 @@ class BitcoinScriptUtilTest extends FlatSpec with MustMatchers {
} }
it must "determine that a script is push only if it only contains pushing an empty script constant" in { it must "determine that a script is push only if it only contains pushing an empty script constant" in {
BitcoinScriptUtil.isMinimalPush(OP_0,ScriptConstantFactory.fromHex("")) must be (true) BitcoinScriptUtil.isMinimalPush(OP_0,ScriptConstant("")) must be (true)
} }
it must "determine that a script is not push only if it uses an OP_PUSHDATA operation while pushing < 75 bytes" in { it must "determine that a script is not push only if it uses an OP_PUSHDATA operation while pushing < 75 bytes" in {
@ -111,63 +111,63 @@ class BitcoinScriptUtilTest extends FlatSpec with MustMatchers {
it must "determine that a OP_PUSHDATA1 operation is the minimal push op for a 76 byte script constant" in { it must "determine that a OP_PUSHDATA1 operation is the minimal push op for a 76 byte script constant" in {
val byteConstantSize = 76 val byteConstantSize = 76
val byteConstant = for { x <- 0 to byteConstantSize} yield 0x0.toByte val byteConstant = for { x <- 0 to byteConstantSize} yield 0x0.toByte
val scriptConstant = ScriptConstantFactory.fromBytes(byteConstant) val scriptConstant = ScriptConstant(byteConstant)
BitcoinScriptUtil.isMinimalPush(OP_PUSHDATA1, scriptConstant) must be (true) BitcoinScriptUtil.isMinimalPush(OP_PUSHDATA1, scriptConstant) must be (true)
} }
it must "determine that a OP_PUSHDATA1 operation is NOT the minimal push op for a 75 byte script constant" in { it must "determine that a OP_PUSHDATA1 operation is NOT the minimal push op for a 75 byte script constant" in {
val byteConstantSize = 75 val byteConstantSize = 75
val byteConstant = for { x <- 0 until byteConstantSize } yield 0x0.toByte val byteConstant = for { x <- 0 until byteConstantSize } yield 0x0.toByte
val scriptConstant = ScriptConstantFactory.fromBytes(byteConstant) val scriptConstant = ScriptConstant(byteConstant)
BitcoinScriptUtil.isMinimalPush(OP_PUSHDATA1, scriptConstant) must be (false) BitcoinScriptUtil.isMinimalPush(OP_PUSHDATA1, scriptConstant) must be (false)
} }
it must "determine that a OP_PUSHDATA2 operation is NOT the minimal push op for a 255 byte script constant" in { it must "determine that a OP_PUSHDATA2 operation is NOT the minimal push op for a 255 byte script constant" in {
val byteConstantSize = 255 val byteConstantSize = 255
val byteConstant = for { x <- 0 until byteConstantSize } yield 0x0.toByte val byteConstant = for { x <- 0 until byteConstantSize } yield 0x0.toByte
val scriptConstant = ScriptConstantFactory.fromBytes(byteConstant) val scriptConstant = ScriptConstant(byteConstant)
BitcoinScriptUtil.isMinimalPush(OP_PUSHDATA2, scriptConstant) must be (false) BitcoinScriptUtil.isMinimalPush(OP_PUSHDATA2, scriptConstant) must be (false)
} }
it must "determine that a OP_PUSHDATA2 operation is the minimal push op for a 256 byte script constant" in { it must "determine that a OP_PUSHDATA2 operation is the minimal push op for a 256 byte script constant" in {
val byteConstantSize = 256 val byteConstantSize = 256
val byteConstant = for { x <- 0 until byteConstantSize } yield 0x0.toByte val byteConstant = for { x <- 0 until byteConstantSize } yield 0x0.toByte
val scriptConstant = ScriptConstantFactory.fromBytes(byteConstant) val scriptConstant = ScriptConstant(byteConstant)
BitcoinScriptUtil.isMinimalPush(OP_PUSHDATA2, scriptConstant) must be (true) BitcoinScriptUtil.isMinimalPush(OP_PUSHDATA2, scriptConstant) must be (true)
} }
it must "determine that a OP_PUSHDATA4 operation is NOT the minimal push op for a 65535 byte script constant" in { it must "determine that a OP_PUSHDATA4 operation is NOT the minimal push op for a 65535 byte script constant" in {
val byteConstantSize = 65535 val byteConstantSize = 65535
val byteConstant = for { x <- 0 until byteConstantSize } yield 0x0.toByte val byteConstant = for { x <- 0 until byteConstantSize } yield 0x0.toByte
val scriptConstant = ScriptConstantFactory.fromBytes(byteConstant) val scriptConstant = ScriptConstant(byteConstant)
BitcoinScriptUtil.isMinimalPush(OP_PUSHDATA4, scriptConstant) must be (false) BitcoinScriptUtil.isMinimalPush(OP_PUSHDATA4, scriptConstant) must be (false)
} }
it must "determine that a OP_PUSHDATA4 operation is the minimal push op for a 65536 byte script constant" in { it must "determine that a OP_PUSHDATA4 operation is the minimal push op for a 65536 byte script constant" in {
val byteConstantSize = 65536 val byteConstantSize = 65536
val byteConstant = for { x <- 0 until byteConstantSize } yield 0x0.toByte val byteConstant = for { x <- 0 until byteConstantSize } yield 0x0.toByte
val scriptConstant = ScriptConstantFactory.fromBytes(byteConstant) val scriptConstant = ScriptConstant(byteConstant)
BitcoinScriptUtil.isMinimalPush(OP_PUSHDATA4, scriptConstant) must be (true) BitcoinScriptUtil.isMinimalPush(OP_PUSHDATA4, scriptConstant) must be (true)
} }
it must "determine if a number is encoded in the shortest way possible" in { it must "determine if a number is encoded in the shortest way possible" in {
BitcoinScriptUtil.isShortestEncoding(ScriptConstantFactory.fromHex("00")) must be (false) BitcoinScriptUtil.isShortestEncoding(ScriptConstant("00")) must be (false)
BitcoinScriptUtil.isShortestEncoding(ScriptConstantFactory.fromHex("0000")) must be (false) BitcoinScriptUtil.isShortestEncoding(ScriptConstant("0000")) must be (false)
BitcoinScriptUtil.isShortestEncoding(ScriptConstantFactory.fromHex("80")) must be (false) BitcoinScriptUtil.isShortestEncoding(ScriptConstant("80")) must be (false)
BitcoinScriptUtil.isShortestEncoding(ScriptConstantFactory.fromHex("0080")) must be (false) BitcoinScriptUtil.isShortestEncoding(ScriptConstant("0080")) must be (false)
BitcoinScriptUtil.isShortestEncoding(ScriptConstantFactory.fromHex("0500")) must be (false) BitcoinScriptUtil.isShortestEncoding(ScriptConstant("0500")) must be (false)
BitcoinScriptUtil.isShortestEncoding(ScriptConstantFactory.fromHex("050000")) must be (false) BitcoinScriptUtil.isShortestEncoding(ScriptConstant("050000")) must be (false)
BitcoinScriptUtil.isShortestEncoding(ScriptConstantFactory.fromHex("0580")) must be (false) BitcoinScriptUtil.isShortestEncoding(ScriptConstant("0580")) must be (false)
BitcoinScriptUtil.isShortestEncoding(ScriptConstantFactory.fromHex("050080")) must be (false) BitcoinScriptUtil.isShortestEncoding(ScriptConstant("050080")) must be (false)
BitcoinScriptUtil.isShortestEncoding(ScriptConstantFactory.fromHex("ff7f80")) must be (false) BitcoinScriptUtil.isShortestEncoding(ScriptConstant("ff7f80")) must be (false)
BitcoinScriptUtil.isShortestEncoding(ScriptConstantFactory.fromHex("ff7f00")) must be (false) BitcoinScriptUtil.isShortestEncoding(ScriptConstant("ff7f00")) must be (false)
BitcoinScriptUtil.isShortestEncoding(ScriptConstantFactory.fromHex("ffff7f80")) must be (false) BitcoinScriptUtil.isShortestEncoding(ScriptConstant("ffff7f80")) must be (false)
BitcoinScriptUtil.isShortestEncoding(ScriptConstantFactory.fromHex("ffff7f00")) must be (false) BitcoinScriptUtil.isShortestEncoding(ScriptConstant("ffff7f00")) must be (false)
} }
} }