Skip to content

Commit

Permalink
add test for Address:new_p2pk for non-ProveDlog tree;
Browse files Browse the repository at this point in the history
  • Loading branch information
greenhat committed Nov 9, 2020
1 parent a0d95ad commit 0fd2fdd
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion ergo-lib/src/chain/address.rs
Expand Up @@ -316,6 +316,8 @@ impl AddressEncoder {

#[cfg(test)]
mod tests {
use crate::types::SType;

use super::*;
use proptest::prelude::*;

Expand All @@ -332,6 +334,15 @@ mod tests {
}
}

#[test]
fn new_p2pk_non_provedlog_error() {
let tree = ErgoTree::from(Rc::new(Expr::Const(Constant {
tpe: SType::SBoolean,
v: ConstantVal::Boolean(true),
})));
assert!(Address::new_p2pk(&tree).is_err());
}

proptest! {

#[test]
Expand All @@ -342,7 +353,6 @@ mod tests {
let address_copy = Address::new_p2pk(&ergo_tree).unwrap();
let encoded_addr = encoder.address_to_str(&address);
let encoded_addr_copy = encoder.address_to_str(&address_copy);

prop_assert_eq![encoded_addr, encoded_addr_copy];
}

Expand Down

0 comments on commit 0fd2fdd

Please sign in to comment.