Skip to content

Commit

Permalink
tests: update test pubkey to return two keys
Browse files Browse the repository at this point in the history
  • Loading branch information
orbitalturtle committed Aug 26, 2024
1 parent 259de8b commit 0a2ffb8
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions src/lndk_offers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -718,8 +718,12 @@ mod tests {
.unwrap()
}

fn get_pubkey() -> String {
"0313ba7ccbd754c117962b9afab6c2870eb3ef43f364a9f6c43d0fabb4553776ba".to_string()
fn get_pubkeys() -> Vec<String> {
let pubkey1 =
"0313ba7ccbd754c117962b9afab6c2870eb3ef43f364a9f6c43d0fabb4553776ba".to_string();
let pubkey2 =
"03b060a3b572ab060532fbe49506fe25b5957195733788aab01ab3c0f40bb52602".to_string();
vec![pubkey1, pubkey2]
}

fn get_invoice_request(offer: Offer, amount: u64) -> InvoiceRequest {
Expand All @@ -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,
)
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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());
}

Expand All @@ -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()
};

Expand All @@ -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());
}

Expand Down Expand Up @@ -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());
}

Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 0a2ffb8

Please sign in to comment.