Skip to content

Commit

Permalink
Merge pull request #301 from LimpSquid/add-more-tests
Browse files Browse the repository at this point in the history
Add more integration tests.
  • Loading branch information
stevenroose authored May 5, 2023
2 parents 2017d6d + 186438d commit 7bd815f
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions integration_test/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,11 @@ fn main() {
test_get_descriptor_info(&cl);
test_derive_addresses(&cl);
test_get_mempool_info(&cl);
test_add_multisig_address(&cl);
//TODO import_multi(
//TODO verify_message(
//TODO encrypt_wallet(&self, passphrase: &str) -> Result<()> {
//TODO get_by_id<T: queryable::Queryable<Self>>(
//TODO add_multisig_address(
test_add_node(&cl);
test_get_added_node_info(&cl);
test_get_node_addresses(&cl);
Expand Down Expand Up @@ -1191,8 +1191,12 @@ fn test_add_node(cl: &Client) {

fn test_get_added_node_info(cl: &Client) {
cl.add_node("127.0.0.1:1234").unwrap();
let added_info = cl.get_added_node_info(None).unwrap();
assert_eq!(added_info.len(), 1);
cl.add_node("127.0.0.1:4321").unwrap();

assert!(cl.get_added_node_info(Some("127.0.0.1:1111")).is_err());
assert_eq!(cl.get_added_node_info(None).unwrap().len(), 2);
assert_eq!(cl.get_added_node_info(Some("127.0.0.1:1234")).unwrap().len(), 1);
assert_eq!(cl.get_added_node_info(Some("127.0.0.1:4321")).unwrap().len(), 1);
}

fn test_get_node_addresses(cl: &Client) {
Expand Down Expand Up @@ -1345,6 +1349,24 @@ fn test_get_descriptor_info(cl: &Client) {
assert!(cl.get_descriptor_info("abcdef").is_err());
}

fn test_add_multisig_address(cl: &Client) {
let addr1 = cl.get_new_address(None, Some(json::AddressType::Bech32)).unwrap().assume_checked();
let addr2 = cl.get_new_address(None, Some(json::AddressType::Bech32)).unwrap().assume_checked();
let addresses = [
json::PubKeyOrAddress::Address(&addr1),
json::PubKeyOrAddress::Address(&addr2),
];

assert!(cl.add_multisig_address(addresses.len(), &addresses, None, None).is_ok());
assert!(cl.add_multisig_address(addresses.len() - 1, &addresses, None, None).is_ok());
assert!(cl.add_multisig_address(addresses.len() + 1, &addresses, None, None).is_err());
assert!(cl.add_multisig_address(0, &addresses, None, None).is_err());
assert!(cl.add_multisig_address(addresses.len(), &addresses, Some("test_label"), None).is_ok());
assert!(cl.add_multisig_address(addresses.len(), &addresses, None, Some(json::AddressType::Legacy)).is_ok());
assert!(cl.add_multisig_address(addresses.len(), &addresses, None, Some(json::AddressType::P2shSegwit)).is_ok());
assert!(cl.add_multisig_address(addresses.len(), &addresses, None, Some(json::AddressType::Bech32)).is_ok());
}

fn test_derive_addresses(cl: &Client) {
let descriptor = r"pkh(02e96fe52ef0e22d2f131dd425ce1893073a3c6ad20e8cac36726393dfb4856a4c)#62k9sn4x";
assert_eq!(cl.derive_addresses(descriptor, None).unwrap(), vec!["mrkwtj5xpYQjHeJe5wsweNjVeTKkvR5fCr".parse().unwrap()]);
Expand Down

0 comments on commit 7bd815f

Please sign in to comment.