- use bitcoin_hashes::sha256::Hash as Sha256;
- use lightning::events::Event;
- use lightning::ln::msgs::ChannelMessageHandler;
- use lightning::ln::{PaymentPreimage, PaymentSecret};
- use lightning::ln::functional_test_utils::*;
- use secp256k1::{SecretKey, Secp256k1};
- use std::collections::VecDeque;
- use std::time::{SystemTime, Duration};
-
- struct TestPayer {
- expectations: core::cell::RefCell<VecDeque<Amount>>,
- }
-
- impl TestPayer {
- fn new() -> Self {
- Self {
- expectations: core::cell::RefCell::new(VecDeque::new()),
- }
- }
-
- fn expect_send(self, value_msat: Amount) -> Self {
- self.expectations.borrow_mut().push_back(value_msat);
- self
- }
-
- fn check_value_msats(&self, actual_value_msats: Amount) {
- let expected_value_msats = self.expectations.borrow_mut().pop_front();
- if let Some(expected_value_msats) = expected_value_msats {
- assert_eq!(actual_value_msats, expected_value_msats);
- } else {
- panic!("Unexpected amount: {:?}", actual_value_msats);
- }
- }
- }
-
- #[derive(Clone, Debug, PartialEq, Eq)]
- struct Amount(u64); // msat
-
- impl Payer for TestPayer {
- fn send_payment(
- &self, _payment_hash: PaymentHash, _recipient_onion: RecipientOnionFields,
- _payment_id: PaymentId, route_params: RouteParameters, _retry_strategy: Retry
- ) -> Result<(), PaymentError> {
- self.check_value_msats(Amount(route_params.final_value_msat));
- Ok(())
- }
- }
-
- impl Drop for TestPayer {
- fn drop(&mut self) {
- if std::thread::panicking() {
- return;
- }
-
- if !self.expectations.borrow().is_empty() {
- panic!("Unsatisfied payment expectations: {:?}", self.expectations.borrow());
- }
- }
- }
+ use bitcoin::hashes::sha256::Hash as Sha256;
+ use lightning::ln::types::PaymentSecret;
+ use lightning::routing::router::Payee;
+ use secp256k1::{SecretKey, PublicKey, Secp256k1};
+ use core::time::Duration;
+ #[cfg(feature = "std")]
+ use std::time::SystemTime;