Change tests to use the safe db.

This commit is contained in:
chriseth 2023-01-05 20:00:05 +01:00
parent a677c3a9a0
commit 287666fa05
3 changed files with 16 additions and 31 deletions

View file

@ -29,8 +29,8 @@ jobs:
run: curl -L https://foundry.paradigm.xyz | bash && foundryup run: curl -L https://foundry.paradigm.xyz | bash && foundryup
- name: Build - name: Build
run: cargo build --verbose run: cargo build --verbose
- name: Download edges - name: Download safes
run: wget -q -c https://chriseth.github.io/pathfinder2/edges.dat run: wget -q -c https://rpc.circlesubi.id/pathfinder-db/capacity_graph.db
- name: Run tests - name: Run tests
run: cargo test --verbose run: cargo test --verbose
- name: Lint - name: Lint

View file

@ -41,7 +41,7 @@ fn main() {
return; return;
} }
if args.len() < 5 { if args.len() < 4 {
println!("Usage: cli [--csv] [--safes] <from> <to> <edges.dat> [--dot <dotfile>]"); println!("Usage: cli [--csv] [--safes] <from> <to> <edges.dat> [--dot <dotfile>]");
println!( println!(
"Usage: cli [--csv] [--safes] <from> <to> <edges.dat> <max_hops> [--dot <dotfile>]" "Usage: cli [--csv] [--safes] <from> <to> <edges.dat> <max_hops> [--dot <dotfile>]"

View file

@ -1,5 +1,5 @@
use pathfinder2::graph::compute_flow; use pathfinder2::graph::compute_flow;
use pathfinder2::io::read_edges_binary; use pathfinder2::io::import_from_safes_binary;
use pathfinder2::types::edge::EdgeDB; use pathfinder2::types::edge::EdgeDB;
use pathfinder2::types::{Address, U256}; use pathfinder2::types::{Address, U256};
use std::process::Command; use std::process::Command;
@ -9,51 +9,36 @@ const TRANSFER_THROUGH_SIG: &str = "transferThrough(address[],address[],address[
const RPC_URL: &str = "https://rpc.gnosischain.com"; const RPC_URL: &str = "https://rpc.gnosischain.com";
#[test] #[test]
#[ignore = "This seems to generate VM errors"]
fn test_flow_chris_martin() { fn test_flow_chris_martin() {
let edges = read_edges();
let chriseth = Address::from("0x8DC7e86fF693e9032A0F41711b5581a04b26Be2E"); let chriseth = Address::from("0x8DC7e86fF693e9032A0F41711b5581a04b26Be2E");
let martin = Address::from("0x42cEDde51198D1773590311E2A340DC06B24cB37"); let martin = Address::from("0x42cEDde51198D1773590311E2A340DC06B24cB37");
test_flow(&chriseth, &martin, &read_edges(), U256::MAX, None); test_flow(&chriseth, &martin, &edges, U256::MAX, None);
test_flow(&chriseth, &martin, &read_edges(), U256::MAX, Some(2)); test_flow(&chriseth, &martin, &edges, U256::MAX, Some(2));
test_flow( test_flow(
&chriseth, &chriseth,
&martin, &martin,
&read_edges(), &edges,
U256::from(71152921504606846976), U256::from(71152921504606846976),
Some(2), Some(2),
); );
test_flow( test_flow(&chriseth, &martin, &read_edges(), U256::MAX, Some(2));
&chriseth,
&martin,
&read_edges(),
U256::from(51152921504606846976),
Some(2),
);
} }
#[test] #[test]
#[ignore = "This seems to generate VM errors"]
fn test_flow_large() { fn test_flow_large() {
let edges = read_edges();
let large_source = Address::from("0x9BA1Bcd88E99d6E1E03252A70A63FEa83Bf1208c"); let large_source = Address::from("0x9BA1Bcd88E99d6E1E03252A70A63FEa83Bf1208c");
let large_dest = Address::from("0x939b2731997922f21ab0a0bab500a949c0fc3550"); let large_dest = Address::from("0x939b2731997922f21ab0a0bab500a949c0fc3550");
test_flow( test_flow(&large_source, &large_dest, &edges, U256::MAX, Some(4));
&large_source, test_flow(&large_source, &large_dest, &edges, U256::MAX, Some(6));
&large_dest,
&read_edges(),
U256::MAX,
Some(4),
);
test_flow(
&large_source,
&large_dest,
&read_edges(),
U256::MAX,
Some(6),
);
} }
fn read_edges() -> EdgeDB { fn read_edges() -> EdgeDB {
read_edges_binary(&"edges.dat".to_string()).unwrap() import_from_safes_binary("capacity_graph.db")
.unwrap()
.edges()
.clone()
} }
fn test_flow( fn test_flow(