(Exchange exchange, Object... optionalArgs)
| 776 | } |
| 777 | |
| 778 | public java.util.concurrent.CompletableFuture<Object> testExchange(Exchange exchange, Object... optionalArgs) |
| 779 | { |
| 780 | |
| 781 | return java.util.concurrent.CompletableFuture.supplyAsync(() -> { |
| 782 | |
| 783 | Object providedSymbol = Helpers.getArg(optionalArgs, 0, null); |
| 784 | Object spotSymbols = null; |
| 785 | Object swapSymbols = null; |
| 786 | if (Helpers.isTrue(!Helpers.isEqual(providedSymbol, null))) |
| 787 | { |
| 788 | Object market = exchange.market(providedSymbol); |
| 789 | if (Helpers.isTrue(Helpers.GetValue(market, "spot"))) |
| 790 | { |
| 791 | spotSymbols = new java.util.ArrayList<Object>(java.util.Arrays.asList(providedSymbol)); |
| 792 | } else |
| 793 | { |
| 794 | swapSymbols = new java.util.ArrayList<Object>(java.util.Arrays.asList(providedSymbol)); |
| 795 | } |
| 796 | } else |
| 797 | { |
| 798 | if (Helpers.isTrue(Helpers.GetValue(exchange.has, "spot"))) |
| 799 | { |
| 800 | Object primarySymbol = this.getValidSymbol(exchange, true); |
| 801 | if (Helpers.isTrue(!Helpers.isEqual(primarySymbol, null))) |
| 802 | { |
| 803 | Object secondarySymbol = Helpers.replace((String)primarySymbol, (String)"BTC", (String)"ETH"); // this should work any exchange |
| 804 | spotSymbols = new java.util.ArrayList<Object>(java.util.Arrays.asList(primarySymbol, secondarySymbol)); |
| 805 | } |
| 806 | } |
| 807 | if (Helpers.isTrue(Helpers.GetValue(exchange.has, "swap"))) |
| 808 | { |
| 809 | Object primarySymbol = this.getValidSymbol(exchange, false); |
| 810 | // some exchanges advertise has['swap']=true via describe() but |
| 811 | // the live market list contains no swap entries (e.g. bequant |
| 812 | // inherits hitbtc swap support but exposes only spot pairs). |
| 813 | // getValidSymbol returns undefined in that case — skip swap |
| 814 | // tests rather than crashing on `undefined.replace(...)`. |
| 815 | if (Helpers.isTrue(!Helpers.isEqual(primarySymbol, null))) |
| 816 | { |
| 817 | Object secondarySymbol = Helpers.replace((String)primarySymbol, (String)"BTC", (String)"ETH"); // this should work any exchange |
| 818 | swapSymbols = new java.util.ArrayList<Object>(java.util.Arrays.asList(primarySymbol, secondarySymbol)); |
| 819 | } |
| 820 | } |
| 821 | } |
| 822 | if (Helpers.isTrue(!Helpers.isEqual(spotSymbols, null))) |
| 823 | { |
| 824 | dump("[INFO:MAIN] Selected SPOT SYMBOL:", exchange.json(spotSymbols)); |
| 825 | } |
| 826 | if (Helpers.isTrue(!Helpers.isEqual(swapSymbols, null))) |
| 827 | { |
| 828 | dump("[INFO:MAIN] Selected SWAP SYMBOL:", exchange.json(swapSymbols)); |
| 829 | } |
| 830 | if (!Helpers.isTrue(this.privateTestOnly)) |
| 831 | { |
| 832 | // note, spot & swap tests should run sequentially, because of conflicting `exchange.options['defaultType']` setting |
| 833 | if (Helpers.isTrue(Helpers.isTrue(Helpers.GetValue(exchange.has, "spot")) && Helpers.isTrue(!Helpers.isEqual(spotSymbols, null)))) |
| 834 | { |
| 835 | if (Helpers.isTrue(this.info)) |
no test coverage detected