diff --git a/cmd/bazaar/main_test.go b/cmd/bazaar/main_test.go index 24b59b3..8be4de4 100644 --- a/cmd/bazaar/main_test.go +++ b/cmd/bazaar/main_test.go @@ -93,7 +93,11 @@ func TestNewWatchdog(t *testing.T) { wd := watchdog.New(cfg, eth, swaps) wd.Start() - AssertExpectedJSON(t, swaps, "test/expected/swaps_wd.json") + for _, swp := range swaps { + if swp.Token0Reserve == 0 || swp.Token1Reserve == 0 { + t.Errorf("error, watchdog updated zero reserves: %f, %f", swp.Token0Reserve, swp.Token1Reserve) + } + } } func TestNewArbiter(t *testing.T) { @@ -117,18 +121,25 @@ func TestNewArbiter(t *testing.T) { arb.Start() out := ReadFile(t, cfg.OutputFilename) - exp := ReadFile(t, "test/expected/arbiter.json") + arbs := make([]arbiter.Arbitration, 0) - AssertString(t, string(out), string(exp)) + err := utils.FromJSON(out, &arbs) + if err != nil { + t.Errorf("invalid arbitration json: %v", err) + } + + if len(arbs) == 0 { + t.Errorf("failed to build arbitrations") + } } func ReadFile(t *testing.T, inputFile string) []byte { - inputJSON, err := ioutil.ReadFile(inputFile) + input, err := ioutil.ReadFile(inputFile) if err != nil { t.Errorf("could not open test file. details: %v", err) } - return inputJSON + return input } func AssertExpectedJSON(t *testing.T, obj interface{}, filename string) { diff --git a/test/expected/arbiter.json b/test/expected/arbiter.json deleted file mode 100644 index a5ff4b4..0000000 --- a/test/expected/arbiter.json +++ /dev/null @@ -1 +0,0 @@ -[{"Balance":1.02331141506,"Path":[{"Target":{"Address":"0x476c5e26a75bd202a9683ffd34359c0cc15be0ff","Symbol":"SRM","Name":"Serum","Decimals":"6"},"Swap":{"Address":"0xcc3d1ecef1f9fd25599dbea2755019dc09db3c54","Token0":{"Address":"0x476c5e26a75bd202a9683ffd34359c0cc15be0ff","Symbol":"SRM","Name":"Serum","Decimals":"6"},"Token1":{"Address":"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","Symbol":"WETH","Name":"Wrapped Ether","Decimals":"18"},"Token0Reserve":23392.839509999998,"Token1Reserve":13.57880549976845,"Rate0to1":0.00058,"Rate1to0":1722.74649}},{"Target":{"Address":"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","Symbol":"WETH","Name":"Wrapped Ether","Decimals":"18"},"Swap":{"Address":"0x117d4288b3635021a3d612fe05a3cbf5c717fef2","Token0":{"Address":"0x476c5e26a75bd202a9683ffd34359c0cc15be0ff","Symbol":"SRM","Name":"Serum","Decimals":"6"},"Token1":{"Address":"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","Symbol":"WETH","Name":"Wrapped Ether","Decimals":"18"},"Token0Reserve":575636.6473899999,"Token1Reserve":342.0198619382404,"Rate0to1":0.000594,"Rate1to0":1683.050347}}]}] \ No newline at end of file diff --git a/test/expected/swaps_wd.json b/test/expected/swaps_wd.json deleted file mode 100644 index 91bfc5b..0000000 --- a/test/expected/swaps_wd.json +++ /dev/null @@ -1 +0,0 @@ -[{"Address":"0xcc3d1ecef1f9fd25599dbea2755019dc09db3c54","Token0":{"Address":"0x476c5e26a75bd202a9683ffd34359c0cc15be0ff","Symbol":"SRM","Name":"Serum","Decimals":"6"},"Token1":{"Address":"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","Symbol":"WETH","Name":"Wrapped Ether","Decimals":"18"},"Token0Reserve":23392.839509999998,"Token1Reserve":13.57880549976845,"Rate0to1":0.00058,"Rate1to0":1722.74649},{"Address":"0x117d4288b3635021a3d612fe05a3cbf5c717fef2","Token0":{"Address":"0x476c5e26a75bd202a9683ffd34359c0cc15be0ff","Symbol":"SRM","Name":"Serum","Decimals":"6"},"Token1":{"Address":"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","Symbol":"WETH","Name":"Wrapped Ether","Decimals":"18"},"Token0Reserve":575636.6473899999,"Token1Reserve":342.0198619382404,"Rate0to1":0.00059,"Rate1to0":1683.05035},{"Address":"0xcc3d1ecef1f9fd25599dbea2755019dc09db3c54","Token0":{"Address":"0x476c5e26a75bd202a9683ffd34359c0cc15be0ff","Symbol":"SRM","Name":"Serum","Decimals":"6"},"Token1":{"Address":"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","Symbol":"WETH","Name":"Wrapped Ether","Decimals":"18"},"Token0Reserve":23392.839509999998,"Token1Reserve":13.57880549976845,"Rate0to1":0.00058,"Rate1to0":1722.74649},{"Address":"0x117d4288b3635021a3d612fe05a3cbf5c717fef2","Token0":{"Address":"0x476c5e26a75bd202a9683ffd34359c0cc15be0ff","Symbol":"SRM","Name":"Serum","Decimals":"6"},"Token1":{"Address":"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","Symbol":"WETH","Name":"Wrapped Ether","Decimals":"18"},"Token0Reserve":575636.6473899999,"Token1Reserve":342.0198619382404,"Rate0to1":0.00059,"Rate1to0":1683.05035}] \ No newline at end of file