Skip to content

Commit

Permalink
WIP: Add tests and docs for payment amount normalization
Browse files Browse the repository at this point in the history
  • Loading branch information
jkilpatr committed Apr 9, 2024
1 parent 37bd591 commit 063ac06
Show file tree
Hide file tree
Showing 8 changed files with 316 additions and 122 deletions.
240 changes: 205 additions & 35 deletions integration_tests/src/five_nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,49 +75,51 @@ pub fn five_node_config() -> (NamespaceInfo, HashMap<Namespace, RouteHop>) {
*/
let testa = Namespace {
id: 1,
cost: 25,
// two and a half cents / gb in wei / byte
cost: 25_000_000,
node_type: NodeType::Client {
exit_name: "test_4".to_string(),
},
};
let testb = Namespace {
id: 2,
cost: 500,
// 20 cents / gb in wei / byte
cost: 500_000_000,
node_type: NodeType::Client {
exit_name: "test_4".to_string(),
},
};
let testc = Namespace {
id: 3,
cost: 15,
cost: 15_000_000,
node_type: NodeType::Client {
exit_name: "test_4".to_string(),
},
};
let testd = Namespace {
id: 4,
cost: 10,
cost: 10_000_000,
node_type: NodeType::Exit {
instance_name: "test_4".to_string(),
},
};
let teste = Namespace {
id: 5,
cost: 40,
cost: 40_000_000,
node_type: NodeType::Client {
exit_name: "test_4".to_string(),
},
};
let testf = Namespace {
id: 6,
cost: 20,
cost: 20_000_000,
node_type: NodeType::Client {
exit_name: "test_4".to_string(),
},
};
let testg = Namespace {
id: 7,
cost: 15,
cost: 15_000_000,
node_type: NodeType::Client {
exit_name: "test_4".to_string(),
},
Expand Down Expand Up @@ -152,10 +154,34 @@ pub fn five_node_config() -> (NamespaceInfo, HashMap<Namespace, RouteHop>) {
destination: [
(2, PriceId { price: 0, id: 2 }),
(3, PriceId { price: 0, id: 3 }),
(4, PriceId { price: 35, id: 3 }),
(5, PriceId { price: 15, id: 3 }),
(6, PriceId { price: 15, id: 3 }),
(7, PriceId { price: 45, id: 3 }),
(
4,
PriceId {
price: 35_000_000,
id: 3,
},
),
(
5,
PriceId {
price: 15_000_000,
id: 3,
},
),
(
6,
PriceId {
price: 15_000_000,
id: 3,
},
),
(
7,
PriceId {
price: 45_000_000,
id: 3,
},
),
]
.iter()
.cloned()
Expand All @@ -164,11 +190,35 @@ pub fn five_node_config() -> (NamespaceInfo, HashMap<Namespace, RouteHop>) {
let testb_routes = RouteHop {
destination: [
(1, PriceId { price: 0, id: 1 }),
(3, PriceId { price: 25, id: 1 }),
(
3,
PriceId {
price: 25_000_000,
id: 1,
},
),
(4, PriceId { price: 0, id: 4 }),
(5, PriceId { price: 40, id: 1 }),
(6, PriceId { price: 10, id: 4 }),
(7, PriceId { price: 10, id: 4 }),
(
5,
PriceId {
price: 40_000_000,
id: 1,
},
),
(
6,
PriceId {
price: 10_000_000,
id: 4,
},
),
(
7,
PriceId {
price: 10_000_000,
id: 4,
},
),
]
.iter()
.cloned()
Expand All @@ -177,22 +227,58 @@ pub fn five_node_config() -> (NamespaceInfo, HashMap<Namespace, RouteHop>) {
let testc_routes = RouteHop {
destination: [
(1, PriceId { price: 0, id: 1 }),
(2, PriceId { price: 25, id: 1 }),
(4, PriceId { price: 20, id: 6 }),
(
2,
PriceId {
price: 25_000_000,
id: 1,
},
),
(
4,
PriceId {
price: 20_000_000,
id: 6,
},
),
(5, PriceId { price: 0, id: 5 }),
(6, PriceId { price: 0, id: 6 }),
(7, PriceId { price: 30, id: 6 }),
(
7,
PriceId {
price: 30_000_000,
id: 6,
},
),
]
.iter()
.cloned()
.collect(),
};
let testd_routes = RouteHop {
destination: [
(1, PriceId { price: 35, id: 6 }),
(
1,
PriceId {
price: 35_000_000,
id: 6,
},
),
(2, PriceId { price: 0, id: 2 }),
(3, PriceId { price: 20, id: 6 }),
(5, PriceId { price: 35, id: 6 }),
(
3,
PriceId {
price: 20_000_000,
id: 6,
},
),
(
5,
PriceId {
price: 35_000_000,
id: 6,
},
),
(6, PriceId { price: 0, id: 6 }),
(7, PriceId { price: 0, id: 7 }),
]
Expand All @@ -202,38 +288,122 @@ pub fn five_node_config() -> (NamespaceInfo, HashMap<Namespace, RouteHop>) {
};
let teste_routes = RouteHop {
destination: [
(1, PriceId { price: 15, id: 3 }),
(2, PriceId { price: 40, id: 3 }),
(
1,
PriceId {
price: 15_000_000,
id: 3,
},
),
(
2,
PriceId {
price: 40_000_000,
id: 3,
},
),
(3, PriceId { price: 0, id: 3 }),
(4, PriceId { price: 35, id: 3 }),
(6, PriceId { price: 15, id: 3 }),
(7, PriceId { price: 45, id: 3 }),
(
4,
PriceId {
price: 35_000_000,
id: 3,
},
),
(
6,
PriceId {
price: 15_000_000,
id: 3,
},
),
(
7,
PriceId {
price: 45_000_000,
id: 3,
},
),
]
.iter()
.cloned()
.collect(),
};
let testf_routes = RouteHop {
destination: [
(1, PriceId { price: 15, id: 3 }),
(2, PriceId { price: 10, id: 4 }),
(
1,
PriceId {
price: 15_000_000,
id: 3,
},
),
(
2,
PriceId {
price: 10_000_000,
id: 4,
},
),
(3, PriceId { price: 0, id: 3 }),
(4, PriceId { price: 0, id: 4 }),
(5, PriceId { price: 15, id: 3 }),
(7, PriceId { price: 10, id: 4 }),
(
5,
PriceId {
price: 15_000_000,
id: 3,
},
),
(
7,
PriceId {
price: 10_000_000,
id: 4,
},
),
]
.iter()
.cloned()
.collect(),
};
let testg_routes = RouteHop {
destination: [
(1, PriceId { price: 45, id: 4 }),
(2, PriceId { price: 10, id: 4 }),
(3, PriceId { price: 30, id: 4 }),
(
1,
PriceId {
price: 45_000_000,
id: 4,
},
),
(
2,
PriceId {
price: 10_000_000,
id: 4,
},
),
(
3,
PriceId {
price: 30_000_000,
id: 4,
},
),
(4, PriceId { price: 0, id: 4 }),
(5, PriceId { price: 45, id: 4 }),
(6, PriceId { price: 10, id: 4 }),
(
5,
PriceId {
price: 45_000_000,
id: 4,
},
),
(
6,
PriceId {
price: 10_000_000,
id: 4,
},
),
]
.iter()
.cloned()
Expand Down
Loading

0 comments on commit 063ac06

Please sign in to comment.