From 6ef9485e444c3b3acb5a3831a1b1f235eeced320 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 23 May 2017 10:21:48 +0300 Subject: [PATCH] Test --- iguana/dpow/dpow_network.c | 10 ++++++++-- iguana/exchanges/DEXstats.h | 10 +++++----- iguana/exchanges/LP_unspents.c | 21 +++++++++++++++++++++ iguana/exchanges/mm.c | 17 +++++++++++++++-- iguana/exchanges/stats.c | 4 +++- iguana/m_test | 27 ++++----------------------- iguana/tests/dexgetinfo | 2 +- iguana/tests/dexlistunspent | 2 +- 8 files changed, 58 insertions(+), 35 deletions(-) create mode 100644 iguana/exchanges/LP_unspents.c diff --git a/iguana/dpow/dpow_network.c b/iguana/dpow/dpow_network.c index f357fb887..bab487d4e 100755 --- a/iguana/dpow/dpow_network.c +++ b/iguana/dpow/dpow_network.c @@ -88,9 +88,15 @@ void dex_init(struct supernet_info *myinfo) break; } mask |= (1 << j); +#ifdef NOTARY_TESTMODE + seeds[j] = NOTARY_TESTMODE; +#endif printf("seed.[%d] <- %s\n",i,seeds[j]); strcpy(myinfo->dexseed_ipaddrs[i],seeds[j]); myinfo->dexipbits[i] = (uint32_t)calc_ipbits(myinfo->dexseed_ipaddrs[i]); +#ifdef NOTARY_TESTMODE + break; +#endif } myinfo->numdexipbits = i; portable_mutex_init(&myinfo->dexmutex); @@ -526,14 +532,14 @@ char *_dex_reqsend(struct supernet_info *myinfo,char *handler,uint8_t *key,int32 printf("%d: subscribe connect (%s)\n",myinfo->numdexipbits,str); } } -//#ifndef __APPLE__ +#ifndef NOTARY_TESTMODE if ( (rand() % 100) < 40 ) { nanomsg_tcpname(0,str,ipaddr,REP_SOCK); nn_connect(myinfo->reqsock,str); printf("%d: req connect (%s)\n",myinfo->numdexipbits,str); } -//#endif +#endif } } if ( freeptr != 0 ) diff --git a/iguana/exchanges/DEXstats.h b/iguana/exchanges/DEXstats.h index 38c2d1fa3..16889c2e1 100644 --- a/iguana/exchanges/DEXstats.h +++ b/iguana/exchanges/DEXstats.h @@ -754,7 +754,7 @@ void stats_updatedisp(struct DEXstats_disp *disp,double price,double volume) void stats_dispprices(struct DEXstats_disp *prices,int32_t leftdatenum,int32_t numdates,struct DEXstats_datenuminfo *date,char *dest,int32_t current_daysecond) { - int32_t i,j,seconds,hour,offset,datenum = date->datenum; struct DEXstats_pairinfo *pair; struct DEXstats_pricepoint *ptr; uint32_t timestamp,lefttimestamp,righttimestamp; + int32_t i,j,offset,datenum = date->datenum; struct DEXstats_pairinfo *pair; struct DEXstats_pricepoint *ptr; uint32_t timestamp,lefttimestamp,righttimestamp; offset = datenum - leftdatenum; lefttimestamp = OS_conv_datenum(leftdatenum,0,0,0); righttimestamp = OS_conv_datenum(leftdatenum+numdates,0,0,0); @@ -782,9 +782,9 @@ void stats_dispprices(struct DEXstats_disp *prices,int32_t leftdatenum,int32_t n } } -#include "../crypto777/jpeg/jinclude.h" -#include "../crypto777/jpeg/jpeglib.h" -#include "../crypto777/jpeg/jerror.h" +#include "../../crypto777/jpeg/jinclude.h" +#include "../../crypto777/jpeg/jpeglib.h" +#include "../../crypto777/jpeg/jerror.h" void gen_jpegfile(char *fname,int32_t quality,uint8_t *bitmap,int32_t width,int32_t height) { @@ -821,7 +821,7 @@ void gen_jpegfile(char *fname,int32_t quality,uint8_t *bitmap,int32_t width,int3 char *stats_prices(char *symbol,char *dest,struct DEXstats_disp *prices,int32_t leftdatenum,int32_t numdates) { - int32_t i,j,datenum,n,seconds; struct DEXstats_priceinfo *pp; uint32_t *utc32,tmp,timestamp,lefttimestamp,righttimestamp; double *splinevals,total; char fname[1024]; struct tai T; cJSON *retjson,*array,*item; + int32_t i,j,n; struct DEXstats_priceinfo *pp; uint32_t *utc32,tmp,timestamp,lefttimestamp,righttimestamp; double *splinevals,total; char fname[1024]; cJSON *retjson,*array,*item; timestamp = (uint32_t)time(NULL); if ( Num_priceinfos >= sizeof(Prices)/sizeof(*Prices) ) return(0); diff --git a/iguana/exchanges/LP_unspents.c b/iguana/exchanges/LP_unspents.c new file mode 100644 index 000000000..aab4d8283 --- /dev/null +++ b/iguana/exchanges/LP_unspents.c @@ -0,0 +1,21 @@ +// +// LP_unspents.c +// marketmaker +// +// Created by Mac on 5/23/17. +// Copyright © 2017 SuperNET. All rights reserved. +// + +#include + +void LPinit() +{ + char *retstr; + retstr = iguana_listunspent("KMD","RRyBxbrAPRUBCUpiJgJZYrkxqrh8x5ta9Z"); + if ( retstr != 0 ) + { + printf("listunspent.(%s)\n",retstr); + free(retstr); + } else printf("null retstr\n"); + getchar(); +} diff --git a/iguana/exchanges/mm.c b/iguana/exchanges/mm.c index b49298d2c..92356d660 100644 --- a/iguana/exchanges/mm.c +++ b/iguana/exchanges/mm.c @@ -19,9 +19,11 @@ // Copyright © 2017 SuperNET. All rights reserved. // +#define FROM_MARKETMAKER #include #include #include "OS_portable.h" +#include "stats.c" #define MAX(a,b) ((a) > (b) ? (a) : (b)) char DEX_baseaddr[64],DEX_reladdr[64]; @@ -37,9 +39,9 @@ int32_t Num_Pending; #define IGUANA_URL "http://127.0.0.1:7778" -char CURRENCIES[][8] = { "USD", "EUR", "JPY", "GBP", "AUD", "CAD", "CHF", "NZD", // major currencies +/*char CURRENCIES[][8] = { "USD", "EUR", "JPY", "GBP", "AUD", "CAD", "CHF", "NZD", // major currencies "CNY", "RUB", "MXN", "BRL", "INR", "HKD", "TRY", "ZAR", "PLN", "NOK", "SEK", "DKK", "CZK", "HUF", "ILS", "KRW", "MYR", "PHP", "RON", "SGD", "THB", "BGN", "IDR", "HRK", // end of currencies -}; +};*/ double PAXPRICES[sizeof(CURRENCIES)/sizeof(*CURRENCIES)]; uint32_t PAXACTIVE; @@ -148,6 +150,14 @@ char *iguana_walletpassphrase(char *passphrase,int32_t timeout) return(bitcoind_RPC(0,"",url,0,"walletpassphrase",postdata)); } +char *iguana_listunspent(char *coin,char *coinaddr) +{ + char url[512],postdata[1024]; + sprintf(url,"%s/coin=%s&agent=bitcoinrpc&method=listunspent?",IGUANA_URL,coin); + sprintf(postdata,"[\"%s\"]",coinaddr); + return(bitcoind_RPC(0,"",url,0,"listunspent",postdata)); +} + double bittrex_balance(char *base,char *coinaddr) { char *retstr; cJSON *retjson; double balance = 0.; @@ -700,11 +710,14 @@ void marketmaker(double minask,double maxbid,char *baseaddr,char *reladdr,double } } +#include "LP_unspents.c" + int main(int argc, const char * argv[]) { char *base,*rel,*name,*exchange,*apikey,*apisecret,*blocktrail,*retstr,*baseaddr,*reladdr,*passphrase; double profitmargin,maxexposure,incrratio,start_rel,start_base,minask,maxbid; cJSON *retjson,*loginjson; int32_t i; + LPinit(); if ( argc > 1 && (retjson= cJSON_Parse(argv[1])) != 0 ) { minask = jdouble(retjson,"minask"); diff --git a/iguana/exchanges/stats.c b/iguana/exchanges/stats.c index d69e369c1..890c157bb 100644 --- a/iguana/exchanges/stats.c +++ b/iguana/exchanges/stats.c @@ -305,7 +305,7 @@ cJSON *SuperNET_urlconv(char *value,int32_t bufsize,char *urlstr) char *stats_rpcparse(char *retbuf,int32_t bufsize,int32_t *jsonflagp,int32_t *postflagp,char *urlstr,char *remoteaddr,char *filetype,uint16_t port) { cJSON *tokens,*argjson,*origargjson,*tmpjson=0,*json = 0; long filesize; - char symbol[64],buf[4096],*originstr,*fieldstr,*userpass=0,urlmethod[16],*data,url[8192],furl[8192],*retstr,*filestr,*token = 0; int32_t i,j,n,iter,num=0; + char symbol[64],buf[4096],*userpass=0,urlmethod[16],*data,url[8192],furl[8192],*retstr,*filestr,*token = 0; int32_t i,j,n,num=0; //printf("rpcparse.(%s)\n",urlstr); for (i=0; i iguana.log 2> error.log & - -myip=`curl -s4 checkip.amazonaws.com` -source pubkey.txt - -coins/kmd_7776 -coins/revs_7776 -sleep 4 -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"SuperNET\",\"method\":\"myipaddr\",\"ipaddr\":\"$myip\"}" -sleep 3 - -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnotary\",\"ipaddr\":\"$myip\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnotary\",\"ipaddr\":\"78.47.196.146\"}" -#curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnotary\",\"ipaddr\":\"5.9.102.210\"}" -#curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnotary\",\"ipaddr\":\"89.248.160.237\"}" -#curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnotary\",\"ipaddr\":\"89.248.160.238\"}" -./wp_7776 -curl --url "http://127.0.0.1:7776" --data "{\"timeout\":60000,\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"REVS\",\"pubkey\":\"$pubkey\"}" +gcc -DNOTARY_TESTMODE=\"78.47.196.146\" -g -Wno-aggressive-loop-optimizations -Wno-deprecated -c -O2 -DLIQUIDITY_PROVIDER=1 *.c ../basilisk/basilisk.c ../gecko/gecko.c ../datachain/datachain.c +gcc -DNOTARY_TESTMODE=\"78.47.196.146\" -g -Wno-aggressive-loop-optimizations -Wno-deprecated -c -DLIQUIDITY_PROVIDER=1 main.c iguana777.c iguana_bundles.c ../basilisk/basilisk.c iguana_ramchain.c +gcc -g -o ../agents/iguana *.o ../agents/libcrypto777.a /usr/local/lib/libnanomsg.so -lcurl -lssl -lcrypto -lpthread -lz -lm diff --git a/iguana/tests/dexgetinfo b/iguana/tests/dexgetinfo index 8aa05a403..0d89dba21 100755 --- a/iguana/tests/dexgetinfo +++ b/iguana/tests/dexgetinfo @@ -1,3 +1,3 @@ #!/bin/bash curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"getinfo\",\"symbol\":\"KMD\"}" -curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"getinfo\",\"symbol\":\"WLC\"}" +curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"getinfo\",\"symbol\":\"LTC\"}" diff --git a/iguana/tests/dexlistunspent b/iguana/tests/dexlistunspent index 2aa0e56ab..7347339da 100755 --- a/iguana/tests/dexlistunspent +++ b/iguana/tests/dexlistunspent @@ -1,2 +1,2 @@ #!/bin/bash -curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"listunspent\",\"address\":\"RSZ7dc164T9gpDLmXU7spYEScru1mGzPMB\",\"symbol\":\"KMD\"}" +curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"listunspent\",\"address\":\"RRyBxbrAPRUBCUpiJgJZYrkxqrh8x5ta9Z\",\"symbol\":\"KMD\"}"