Skip to content

Commit

Permalink
merge main and resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyukang committed Nov 25, 2024
2 parents 157e5a5 + 6b0a5a8 commit d4a5369
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 266 deletions.
28 changes: 14 additions & 14 deletions src/fiber/tests/history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::fiber::history::output_direction;
use crate::fiber::history::{Direction, DEFAULT_BIMODAL_DECAY_TIME};
use crate::fiber::history::{InternalPairResult, InternalResult};
use crate::fiber::history::{PaymentHistory, TimedResult};
use crate::fiber::tests::test_utils::{generate_pubkey, MemoryStore};
use crate::fiber::tests::test_utils::{generate_pubkey, generate_store};
use crate::now_timestamp_as_millis_u64;
use crate::store::Store;
use ckb_types::packed::OutPoint;
Expand All @@ -27,7 +27,7 @@ fn gen_rand_outpoint() -> OutPoint {

#[test]
fn test_history() {
let mut history = PaymentHistory::new(generate_pubkey().into(), None, MemoryStore::default());
let mut history = PaymentHistory::new(generate_pubkey().into(), None, generate_store());
let channel_outpoint = OutPoint::default();
let direction = Direction::Forward;

Expand Down Expand Up @@ -64,7 +64,7 @@ fn test_history() {

#[test]
fn test_history_apply_channel_result() {
let mut history = PaymentHistory::new(generate_pubkey().into(), None, MemoryStore::default());
let mut history = PaymentHistory::new(generate_pubkey().into(), None, generate_store());
let channel_outpoint = OutPoint::default();
let direction = Direction::Forward;

Expand Down Expand Up @@ -294,7 +294,7 @@ fn test_history_internal_result_fail_range_pair() {
assert_eq!(res.amount, 0);
assert_eq!(res.success, false);

let mut history = PaymentHistory::new(generate_pubkey().into(), None, MemoryStore::default());
let mut history = PaymentHistory::new(generate_pubkey().into(), None, generate_store());
history.apply_internal_result(internal_result);

assert!(matches!(
Expand Down Expand Up @@ -341,7 +341,7 @@ fn test_history_internal_result_fail_range_pair() {
#[test]
fn test_history_apply_internal_result_fail_node() {
let mut internal_result = InternalResult::default();
let mut history = PaymentHistory::new(generate_pubkey().into(), None, MemoryStore::default());
let mut history = PaymentHistory::new(generate_pubkey().into(), None, generate_store());
let node1 = generate_pubkey();
let node2 = generate_pubkey();
let node3 = generate_pubkey();
Expand Down Expand Up @@ -437,7 +437,7 @@ fn test_history_apply_internal_result_fail_node() {
#[test]
fn test_history_fail_node_with_multiple_channels() {
let mut internal_result = InternalResult::default();
let mut history = PaymentHistory::new(generate_pubkey().into(), None, MemoryStore::default());
let mut history = PaymentHistory::new(generate_pubkey().into(), None, generate_store());
let node1 = generate_pubkey();
let node2 = generate_pubkey();
let node3 = generate_pubkey();
Expand Down Expand Up @@ -579,7 +579,7 @@ fn test_history_fail_node_with_multiple_channels() {

#[test]
fn test_history_interal_success_fail() {
let mut history = PaymentHistory::new(generate_pubkey().into(), None, MemoryStore::default());
let mut history = PaymentHistory::new(generate_pubkey().into(), None, generate_store());
let from = generate_pubkey();
let target = generate_pubkey();
let channel_outpoint = OutPoint::default();
Expand Down Expand Up @@ -642,7 +642,7 @@ fn test_history_interal_success_fail() {

#[test]
fn test_history_probability() {
let mut history = PaymentHistory::new(generate_pubkey().into(), None, MemoryStore::default());
let mut history = PaymentHistory::new(generate_pubkey().into(), None, generate_store());
let from = generate_pubkey();
let target = generate_pubkey();
let channel_outpoint = OutPoint::default();
Expand Down Expand Up @@ -731,7 +731,7 @@ fn test_history_probability() {

#[test]
fn test_history_direct_probability() {
let mut history = PaymentHistory::new(generate_pubkey().into(), None, MemoryStore::default());
let mut history = PaymentHistory::new(generate_pubkey().into(), None, generate_store());
let from = generate_pubkey();
let target = generate_pubkey();
let channel_outpoint = OutPoint::default();
Expand Down Expand Up @@ -765,7 +765,7 @@ fn test_history_direct_probability() {

#[test]
fn test_history_small_fail_amount_probability() {
let mut history = PaymentHistory::new(generate_pubkey().into(), None, MemoryStore::default());
let mut history = PaymentHistory::new(generate_pubkey().into(), None, generate_store());
let from = generate_pubkey();
let target = generate_pubkey();
let channel_outpoint = OutPoint::default();
Expand All @@ -789,7 +789,7 @@ fn test_history_small_fail_amount_probability() {

#[test]
fn test_history_channel_probability_range() {
let mut history = PaymentHistory::new(generate_pubkey().into(), None, MemoryStore::default());
let mut history = PaymentHistory::new(generate_pubkey().into(), None, generate_store());
let from = generate_pubkey();
let target = generate_pubkey();
let channel_outpoint = OutPoint::default();
Expand Down Expand Up @@ -829,7 +829,7 @@ fn test_history_channel_probability_range() {

#[test]
fn test_history_eval_probability_range() {
let mut history = PaymentHistory::new(generate_pubkey().into(), None, MemoryStore::default());
let mut history = PaymentHistory::new(generate_pubkey().into(), None, generate_store());
let from = generate_pubkey();
let target = generate_pubkey();
let channel_outpoint = OutPoint::default();
Expand Down Expand Up @@ -947,7 +947,7 @@ fn test_history_load_store() {
fn test_history_can_send_with_time() {
use crate::fiber::history::DEFAULT_BIMODAL_DECAY_TIME;

let history = PaymentHistory::new(generate_pubkey().into(), None, MemoryStore::default());
let history = PaymentHistory::new(generate_pubkey().into(), None, generate_store());
let now = now_timestamp_as_millis_u64();
let res = history.can_send(100, now);
assert_eq!(res, 100);
Expand All @@ -969,7 +969,7 @@ fn test_history_can_send_with_time() {
fn test_history_can_not_send_with_time() {
use crate::fiber::history::DEFAULT_BIMODAL_DECAY_TIME;

let history = PaymentHistory::new(generate_pubkey().into(), None, MemoryStore::default());
let history = PaymentHistory::new(generate_pubkey().into(), None, generate_store());
let now = now_timestamp_as_millis_u64();
let res = history.cannot_send(90, now, 100);
assert_eq!(res, 90);
Expand Down
Loading

0 comments on commit d4a5369

Please sign in to comment.