From 0a2ffb8635c5459627453937c2701928555a58f0 Mon Sep 17 00:00:00 2001 From: Orbital Date: Fri, 16 Aug 2024 12:58:52 -0500 Subject: [PATCH] tests: update test pubkey to return two keys --- src/lndk_offers.rs | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/lndk_offers.rs b/src/lndk_offers.rs index eff7044e..b8283382 100644 --- a/src/lndk_offers.rs +++ b/src/lndk_offers.rs @@ -718,8 +718,12 @@ mod tests { .unwrap() } - fn get_pubkey() -> String { - "0313ba7ccbd754c117962b9afab6c2870eb3ef43f364a9f6c43d0fabb4553776ba".to_string() + fn get_pubkeys() -> Vec { + let pubkey1 = + "0313ba7ccbd754c117962b9afab6c2870eb3ef43f364a9f6c43d0fabb4553776ba".to_string(); + let pubkey2 = + "03b060a3b572ab060532fbe49506fe25b5957195733788aab01ab3c0f40bb52602".to_string(); + vec![pubkey1, pubkey2] } fn get_invoice_request(offer: Offer, amount: u64) -> InvoiceRequest { @@ -745,7 +749,7 @@ mod tests { let entropy_source = MessengerUtilities::new(); let secp_ctx = Secp256k1::new(); BlindedPath::new_for_message( - &[PublicKey::from_str(&get_pubkey()).unwrap()], + &[PublicKey::from_str(&get_pubkeys()[0]).unwrap()], &entropy_source, &secp_ctx, ) @@ -791,7 +795,7 @@ mod tests { signer_mock.expect_derive_next_key().returning(|_| { Ok(KeyDescriptor { - raw_key_bytes: PublicKey::from_str(&get_pubkey()) + raw_key_bytes: PublicKey::from_str(&get_pubkeys()[0]) .unwrap() .serialize() .to_vec(), @@ -859,7 +863,7 @@ mod tests { signer_mock.expect_derive_next_key().returning(|_| { Ok(KeyDescriptor { - raw_key_bytes: PublicKey::from_str(&get_pubkey()) + raw_key_bytes: PublicKey::from_str(&get_pubkeys()[0]) .unwrap() .serialize() .to_vec(), @@ -936,7 +940,7 @@ mod tests { .expect_connect_peer() .returning(|_, _| Ok(())); - let pubkey = PublicKey::from_str(&get_pubkey()).unwrap(); + let pubkey = PublicKey::from_str(&get_pubkeys()[0]).unwrap(); assert!(connect_to_peer(connector_mock, pubkey).await.is_ok()); } @@ -945,7 +949,7 @@ mod tests { let mut connector_mock = MockTestPeerConnector::new(); connector_mock.expect_list_peers().returning(|| { let peer = tonic_lnd::lnrpc::Peer { - pub_key: get_pubkey(), + pub_key: get_pubkeys()[0].clone(), ..Default::default() }; @@ -968,7 +972,7 @@ mod tests { Ok(Some(node)) }); - let pubkey = PublicKey::from_str(&get_pubkey()).unwrap(); + let pubkey = PublicKey::from_str(&get_pubkeys()[0]).unwrap(); assert!(connect_to_peer(connector_mock, pubkey).await.is_ok()); } @@ -998,7 +1002,7 @@ mod tests { .expect_connect_peer() .returning(|_, _| Err(Status::unknown(""))); - let pubkey = PublicKey::from_str(&get_pubkey()).unwrap(); + let pubkey = PublicKey::from_str(&get_pubkeys()[0]).unwrap(); assert!(connect_to_peer(connector_mock, pubkey).await.is_err()); } @@ -1014,14 +1018,14 @@ mod tests { feature_entry.insert(38, feature); let peer = tonic_lnd::lnrpc::Peer { - pub_key: get_pubkey(), + pub_key: get_pubkeys()[0].clone(), features: feature_entry, ..Default::default() }; Ok(ListPeersResponse { peers: vec![peer] }) }); - let receiver_node_id = PublicKey::from_str(&get_pubkey()).unwrap(); + let receiver_node_id = PublicKey::from_str(&get_pubkeys()[0]).unwrap(); let handler = OfferHandler::default(); assert!(handler .create_reply_path(connector_mock, receiver_node_id) @@ -1038,7 +1042,7 @@ mod tests { .expect_list_peers() .returning(|| Ok(ListPeersResponse { peers: vec![] })); - let receiver_node_id = PublicKey::from_str(&get_pubkey()).unwrap(); + let receiver_node_id = PublicKey::from_str(&get_pubkeys()[0]).unwrap(); let handler = OfferHandler::default(); assert!(handler .create_reply_path(connector_mock, receiver_node_id) @@ -1054,7 +1058,7 @@ mod tests { .expect_list_peers() .returning(|| Err(Status::unknown("unknown error"))); - let receiver_node_id = PublicKey::from_str(&get_pubkey()).unwrap(); + let receiver_node_id = PublicKey::from_str(&get_pubkeys()[0]).unwrap(); let handler = OfferHandler::default(); assert!(handler .create_reply_path(connector_mock, receiver_node_id)