diff --git a/__tests__/fixtures/testnet-sarafu.csv b/__tests__/fixtures/testnet-sarafu.csv index 2c25018..9699c3a 100644 --- a/__tests__/fixtures/testnet-sarafu.csv +++ b/__tests__/fixtures/testnet-sarafu.csv @@ -6,4 +6,14 @@ 6 4 0.5 4 6 100.0 4 6 200.0 -3 6 100.0 \ No newline at end of file +3 6 100.0 +4 3 2.0 +4 6 2.0 +3 6 23.0 +5 7 400.0 +7 3 12.0 +4 7 10.0 +7 6 10.0 +4 6 20.0 +0 8 621.6898006764151 +0 9 714.3782984916287 \ No newline at end of file diff --git a/src/run.ts b/src/run.ts index 561ae68..bdf6fc6 100644 --- a/src/run.ts +++ b/src/run.ts @@ -6,6 +6,12 @@ import { BatchedNetworkSimulator, Badger as Node } from './main.js'; const TESTNET_CSV = '__tests__/fixtures/testnet-sarafu.csv'; const NUM_ROUNDS_PER_LINE = 50; +function reversePath(path: string): string { + const hops = path.split('.'); + const innerHops = hops.slice(1, hops.length - 1); + const reverseInnerHops = innerHops.reverse(); + return [].concat(hops[0], reverseInnerHops, hops[0]).join('.'); +} async function run(): Promise { console.log("This simulation will take about 60 seconds to complete."); @@ -94,12 +100,18 @@ async function run(): Promise { paths[path].push(loopId); } }); - console.log(`Found ${Object.keys(paths).length} paths:`); - Object.keys(paths).sort().forEach((path) => { + const reverses = []; + const deduplicated = Object.keys(paths).sort().filter(path => { + reverses.push(reversePath(path)); + return (reverses.indexOf(path) === -1); + }); + console.log(`Found ${deduplicated.length} paths:`); + deduplicated.forEach((path) => { // console.log(path, paths[path]); console.log(path); }); - console.log(networkSimulator.getPlantUml('possible')); + // console.log(reverses); + // console.log(networkSimulator.getPlantUml('possible')); }