projects
/
rust-lightning
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Use correct to_remote script in counterparty commitments
[rust-lightning]
/
lightning
/
src
/
util
/
test_utils.rs
diff --git
a/lightning/src/util/test_utils.rs
b/lightning/src/util/test_utils.rs
index 8e2be87d8bef820b4bf56b19829aa09450a9f1d6..18c3db76f18efac38cb0ebf529f42c32b7ef4757 100644
(file)
--- a/
lightning/src/util/test_utils.rs
+++ b/
lightning/src/util/test_utils.rs
@@
-62,7
+62,6
@@
use regex;
use crate::io;
use crate::prelude::*;
use core::cell::RefCell;
use crate::io;
use crate::prelude::*;
use core::cell::RefCell;
-use core::ops::Deref;
use core::time::Duration;
use crate::sync::{Mutex, Arc};
use core::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
use core::time::Duration;
use crate::sync::{Mutex, Arc};
use core::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
@@
-125,6
+124,7
@@
impl<'a> Router for TestRouter<'a> {
if let Some((find_route_query, find_route_res)) = self.next_routes.lock().unwrap().pop_front() {
assert_eq!(find_route_query, *params);
if let Ok(ref route) = find_route_res {
if let Some((find_route_query, find_route_res)) = self.next_routes.lock().unwrap().pop_front() {
assert_eq!(find_route_query, *params);
if let Ok(ref route) = find_route_res {
+ assert_eq!(route.route_params.as_ref().unwrap().final_value_msat, find_route_query.final_value_msat);
let scorer = self.scorer.read().unwrap();
let scorer = ScorerAccountingForInFlightHtlcs::new(scorer, &inflight_htlcs);
for path in &route.paths {
let scorer = self.scorer.read().unwrap();
let scorer = ScorerAccountingForInFlightHtlcs::new(scorer, &inflight_htlcs);
for path in &route.paths {
@@
-226,7
+226,7
@@
impl<'a> TestChainMonitor<'a> {
}
}
impl<'a> chain::Watch<TestChannelSigner> for TestChainMonitor<'a> {
}
}
impl<'a> chain::Watch<TestChannelSigner> for TestChainMonitor<'a> {
- fn watch_channel(&self, funding_txo: OutPoint, monitor: channelmonitor::ChannelMonitor<TestChannelSigner>) ->
chain::ChannelMonitorUpdateStatus
{
+ fn watch_channel(&self, funding_txo: OutPoint, monitor: channelmonitor::ChannelMonitor<TestChannelSigner>) ->
Result<chain::ChannelMonitorUpdateStatus, ()>
{
// At every point where we get a monitor update, we should be able to send a useful monitor
// to a watchtower and disk...
let mut w = TestVecWriter(Vec::new());
// At every point where we get a monitor update, we should be able to send a useful monitor
// to a watchtower and disk...
let mut w = TestVecWriter(Vec::new());
@@
-297,6
+297,7
@@
pub(crate) struct WatchtowerPersister {
}
impl WatchtowerPersister {
}
impl WatchtowerPersister {
+ #[cfg(test)]
pub(crate) fn new(destination_script: Script) -> Self {
WatchtowerPersister {
persister: TestPersister::new(),
pub(crate) fn new(destination_script: Script) -> Self {
WatchtowerPersister {
persister: TestPersister::new(),
@@
-306,6
+307,7
@@
impl WatchtowerPersister {
}
}
}
}
+ #[cfg(test)]
pub(crate) fn justice_tx(&self, funding_txo: OutPoint, commitment_txid: &Txid)
-> Option<Transaction> {
self.watchtower_state.lock().unwrap().get(&funding_txo).unwrap().get(commitment_txid).cloned()
pub(crate) fn justice_tx(&self, funding_txo: OutPoint, commitment_txid: &Txid)
-> Option<Transaction> {
self.watchtower_state.lock().unwrap().get(&funding_txo).unwrap().get(commitment_txid).cloned()
@@
-426,7
+428,7
@@
impl<Signer: sign::WriteableEcdsaChannelSigner> chainmonitor::Persist<Signer> fo
}
}
}
}
-pub
(crate)
struct TestStore {
+pub struct TestStore {
persisted_bytes: Mutex<HashMap<String, HashMap<String, Vec<u8>>>>,
read_only: bool,
}
persisted_bytes: Mutex<HashMap<String, HashMap<String, Vec<u8>>>>,
read_only: bool,
}
@@
-439,12
+441,12
@@
impl TestStore {
}
impl KVStore for TestStore {
}
impl KVStore for TestStore {
- fn read(&self,
namespace: &str, sub
_namespace: &str, key: &str) -> io::Result<Vec<u8>> {
+ fn read(&self,
primary_namespace: &str, secondary
_namespace: &str, key: &str) -> io::Result<Vec<u8>> {
let persisted_lock = self.persisted_bytes.lock().unwrap();
let persisted_lock = self.persisted_bytes.lock().unwrap();
- let prefixed = if s
ub
_namespace.is_empty() {
- namespace.to_string()
+ let prefixed = if s
econdary
_namespace.is_empty() {
+
primary_
namespace.to_string()
} else {
} else {
- format!("{}/{}",
namespace, sub
_namespace)
+ format!("{}/{}",
primary_namespace, secondary
_namespace)
};
if let Some(outer_ref) = persisted_lock.get(&prefixed) {
};
if let Some(outer_ref) = persisted_lock.get(&prefixed) {
@@
-459,7
+461,7
@@
impl KVStore for TestStore {
}
}
}
}
- fn write(&self,
namespace: &str, sub
_namespace: &str, key: &str, buf: &[u8]) -> io::Result<()> {
+ fn write(&self,
primary_namespace: &str, secondary
_namespace: &str, key: &str, buf: &[u8]) -> io::Result<()> {
if self.read_only {
return Err(io::Error::new(
io::ErrorKind::PermissionDenied,
if self.read_only {
return Err(io::Error::new(
io::ErrorKind::PermissionDenied,
@@
-468,10
+470,10
@@
impl KVStore for TestStore {
}
let mut persisted_lock = self.persisted_bytes.lock().unwrap();
}
let mut persisted_lock = self.persisted_bytes.lock().unwrap();
- let prefixed = if s
ub
_namespace.is_empty() {
- namespace.to_string()
+ let prefixed = if s
econdary
_namespace.is_empty() {
+
primary_
namespace.to_string()
} else {
} else {
- format!("{}/{}",
namespace, sub
_namespace)
+ format!("{}/{}",
primary_namespace, secondary
_namespace)
};
let outer_e = persisted_lock.entry(prefixed).or_insert(HashMap::new());
let mut bytes = Vec::new();
};
let outer_e = persisted_lock.entry(prefixed).or_insert(HashMap::new());
let mut bytes = Vec::new();
@@
-480,7
+482,7
@@
impl KVStore for TestStore {
Ok(())
}
Ok(())
}
- fn remove(&self,
namespace: &str, sub
_namespace: &str, key: &str, _lazy: bool) -> io::Result<()> {
+ fn remove(&self,
primary_namespace: &str, secondary
_namespace: &str, key: &str, _lazy: bool) -> io::Result<()> {
if self.read_only {
return Err(io::Error::new(
io::ErrorKind::PermissionDenied,
if self.read_only {
return Err(io::Error::new(
io::ErrorKind::PermissionDenied,
@@
-490,10
+492,10
@@
impl KVStore for TestStore {
let mut persisted_lock = self.persisted_bytes.lock().unwrap();
let mut persisted_lock = self.persisted_bytes.lock().unwrap();
- let prefixed = if s
ub
_namespace.is_empty() {
- namespace.to_string()
+ let prefixed = if s
econdary
_namespace.is_empty() {
+
primary_
namespace.to_string()
} else {
} else {
- format!("{}/{}",
namespace, sub
_namespace)
+ format!("{}/{}",
primary_namespace, secondary
_namespace)
};
if let Some(outer_ref) = persisted_lock.get_mut(&prefixed) {
outer_ref.remove(&key.to_string());
};
if let Some(outer_ref) = persisted_lock.get_mut(&prefixed) {
outer_ref.remove(&key.to_string());
@@
-502,13
+504,13
@@
impl KVStore for TestStore {
Ok(())
}
Ok(())
}
- fn list(&self,
namespace: &str, sub
_namespace: &str) -> io::Result<Vec<String>> {
+ fn list(&self,
primary_namespace: &str, secondary
_namespace: &str) -> io::Result<Vec<String>> {
let mut persisted_lock = self.persisted_bytes.lock().unwrap();
let mut persisted_lock = self.persisted_bytes.lock().unwrap();
- let prefixed = if s
ub
_namespace.is_empty() {
- namespace.to_string()
+ let prefixed = if s
econdary
_namespace.is_empty() {
+
primary_
namespace.to_string()
} else {
} else {
- format!("{}/{}",
namespace, sub
_namespace)
+ format!("{}/{}",
primary_namespace, secondary
_namespace)
};
match persisted_lock.entry(prefixed) {
hash_map::Entry::Occupied(e) => Ok(e.get().keys().cloned().collect()),
};
match persisted_lock.entry(prefixed) {
hash_map::Entry::Occupied(e) => Ok(e.get().keys().cloned().collect()),