Fixing a couple bugs in setting ScriptUnknownError instead of ScriptErrorMinimalData

This commit is contained in:
Chris Stewart 2016-05-02 14:16:04 -05:00
parent 01b9aaf077
commit 83bce905a1
5 changed files with 8 additions and 8 deletions

View file

@ -281,7 +281,7 @@ trait ArithmeticInterpreter extends ControlOperationsInterpreter {
!BitcoinScriptUtil.isShortestEncoding(b) || !BitcoinScriptUtil.isShortestEncoding(a))) {
logger.error("The constant you gave us is not encoded in the shortest way possible")
ScriptProgram(program, ScriptErrorMinimalData)
ScriptProgram(program, ScriptErrorUnknownError)
} else if (isLargerThan4Bytes(c) || isLargerThan4Bytes(b) || isLargerThan4Bytes(a)) {
//pretty sure that an error is thrown inside of CScriptNum which in turn is caught by interpreter.cpp here
//https://github.com/bitcoin/bitcoin/blob/master/src/script/interpreter.cpp#L999-L1002
@ -369,7 +369,7 @@ trait ArithmeticInterpreter extends ControlOperationsInterpreter {
case (x : ScriptNumber, y : ScriptNumber) =>
if (ScriptFlagUtil.requireMinimalData(program.flags) && (!BitcoinScriptUtil.isShortestEncoding(x) || !BitcoinScriptUtil.isShortestEncoding(y))) {
logger.error("The constant you gave us is not encoded in the shortest way possible")
ScriptProgram(program, ScriptErrorMinimalData)
ScriptProgram(program, ScriptErrorUnknownError)
} else if (isLargerThan4Bytes(x) || isLargerThan4Bytes(y)) {
//pretty sure that an error is thrown inside of CScriptNum which in turn is caught by interpreter.cpp here
//https://github.com/bitcoin/bitcoin/blob/master/src/script/interpreter.cpp#L999-L1002
@ -420,7 +420,7 @@ trait ArithmeticInterpreter extends ControlOperationsInterpreter {
if (ScriptFlagUtil.requireMinimalData(program.flags) &&
(!BitcoinScriptUtil.isShortestEncoding(x) || !BitcoinScriptUtil.isShortestEncoding(y))) {
logger.error("The constant you gave us is not encoded in the shortest way possible")
ScriptProgram(program, ScriptErrorMinimalData)
ScriptProgram(program, ScriptErrorUnknownError)
} else if (isLargerThan4Bytes(x) || isLargerThan4Bytes(y)) {
//pretty sure that an error is thrown inside of CScriptNum which in turn is caught by interpreter.cpp here
//https://github.com/bitcoin/bitcoin/blob/master/src/script/interpreter.cpp#L999-L1002

View file

@ -170,7 +170,7 @@ trait CryptoInterpreter extends ControlOperationsInterpreter with BitcoinSLogger
ScriptProgram(program,ScriptErrorPubKeyCount)
} else if (ScriptFlagUtil.requireMinimalData(program.flags) && !nPossibleSignatures.isShortestEncoding) {
logger.error("The required signatures and the possible signatures must be encoded as the shortest number possible")
ScriptProgram(program, ScriptErrorMinimalData)
ScriptProgram(program, ScriptErrorUnknownError)
} else if (program.stack.size < 2) {
logger.error("We need at least 2 operations on the stack")
ScriptProgram(program,ScriptErrorInvalidStackOperation)
@ -179,7 +179,7 @@ trait CryptoInterpreter extends ControlOperationsInterpreter with BitcoinSLogger
if (ScriptFlagUtil.requireMinimalData(program.flags) && !mRequiredSignatures.isShortestEncoding) {
logger.error("The required signatures val must be the shortest encoding as possible")
return ScriptProgram(program,ScriptErrorMinimalData)
return ScriptProgram(program,ScriptErrorUnknownError)
}
if (mRequiredSignatures < ScriptNumber.zero) {

View file

@ -381,7 +381,7 @@ trait StackInterpreter extends BitcoinSLogger {
case Success(n) => op(n)
case Failure(_) =>
logger.error("Script number was not minimally encoded")
ScriptProgram(program,ScriptErrorMinimalData)
ScriptProgram(program,ScriptErrorUnknownError)
}
}

View file

@ -478,7 +478,7 @@ class ArithmeticInterpreterTest extends FlatSpec with MustMatchers with Arithmet
val program = ScriptProgram(TestUtil.testProgramExecutionInProgress, stack,script)
val newProgram = opWithin(program)
newProgram.isInstanceOf[ExecutedScriptProgram] must be (true)
newProgram.asInstanceOf[ExecutedScriptProgram].error must be (Some(ScriptErrorMinimalData))
newProgram.asInstanceOf[ExecutedScriptProgram].error must be (Some(ScriptErrorUnknownError))
}
it must "mark the script as invalid for OP_WITHIN if one of the numbers is larger than 4 bytes" in {

View file

@ -214,7 +214,7 @@ class StackInterpreterTest extends FlatSpec with MustMatchers with StackInterpre
val newProgram = opRoll(program)
newProgram.isInstanceOf[ExecutedScriptProgram] must be (true)
newProgram.asInstanceOf[ExecutedScriptProgram].error must be (Some(ScriptErrorMinimalData))
newProgram.asInstanceOf[ExecutedScriptProgram].error must be (Some(ScriptErrorUnknownError))
}
it must "evaluate an OP_ROT correctly" in {