test(machine): integer overflow
This commit is contained in:
@@ -33,6 +33,7 @@ itertools = "0.10.5"
|
||||
indexmap = "1.9.2"
|
||||
secp256k1 = { version = "0.26.0", optional = true }
|
||||
k256 = { version = "0.12.0", optional = true }
|
||||
num-bigint = "0.4.3"
|
||||
|
||||
[dev-dependencies]
|
||||
hex = "0.4.3"
|
||||
|
||||
@@ -730,3 +730,33 @@ impl From<&Constant> for Type {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use crate::{
|
||||
ast::{Constant, NamedDeBruijn, Program, Term},
|
||||
builtins::DefaultFunction,
|
||||
machine::Error,
|
||||
};
|
||||
|
||||
use super::cost_model::ExBudget;
|
||||
|
||||
#[test]
|
||||
fn add_big_ints() {
|
||||
let program: Program<NamedDeBruijn> = Program {
|
||||
version: (0, 0, 0),
|
||||
term: Term::Apply {
|
||||
function: Term::Apply {
|
||||
function: Term::Builtin(DefaultFunction::AddInteger).into(),
|
||||
argument: Term::Constant(Constant::Integer(i128::MAX).into()).into(),
|
||||
}
|
||||
.into(),
|
||||
argument: Term::Constant(Constant::Integer(i128::MAX).into()).into(),
|
||||
},
|
||||
};
|
||||
|
||||
let (eval_result, _, _) = program.eval(ExBudget::default());
|
||||
|
||||
assert!(!matches!(eval_result, Err(Error::OverflowError)));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user