Browse Source

Test

etomic
jl777 8 years ago
parent
commit
6ef9485e44
  1. 10
      iguana/dpow/dpow_network.c
  2. 10
      iguana/exchanges/DEXstats.h
  3. 21
      iguana/exchanges/LP_unspents.c
  4. 17
      iguana/exchanges/mm.c
  5. 4
      iguana/exchanges/stats.c
  6. 27
      iguana/m_test
  7. 2
      iguana/tests/dexgetinfo
  8. 2
      iguana/tests/dexlistunspent

10
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 )

10
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);

21
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 <stdio.h>
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();
}

17
iguana/exchanges/mm.c

@ -19,9 +19,11 @@
// Copyright © 2017 SuperNET. All rights reserved.
//
#define FROM_MARKETMAKER
#include <stdio.h>
#include <stdint.h>
#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");

4
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<sizeof(urlmethod)-1&&urlstr[i]!=0&&urlstr[i]!=' '; i++)
urlmethod[i] = urlstr[i];
@ -701,6 +701,7 @@ void stats_rpcloop(void *args)
}
}
#ifndef FROM_MARKETMAKER
void stats_kvjson(FILE *logfp,int32_t height,int32_t savedheight,uint32_t timestamp,char *key,cJSON *kvjson,bits256 pubkey,bits256 sigprev)
{
struct tai T; int32_t seconds,datenum,n;
@ -1059,3 +1060,4 @@ int main(int argc, const char * argv[])
}
return 0;
}
#endif

27
iguana/m_test

@ -1,28 +1,9 @@
#!/bin/bash
pkill iguana
#./configure --enable-endomorphism --enable-module-ecdh --enable-module-schnorr --enable-module-rangeproof --enable-experimental --enable-module_recovery
rm -f ../agents/iguana *.o
git pull
cd secp256k1; ./m_unix; cd ..
cd ../crypto777; ./m_LP; cd ../iguana
gcc -g -fno-aggressive-loop-optimizations -Wno-deprecated -c -O2 -DISNOTARYNODE=1 -DLIQUIDITY_PROVIDER=1 *.c ../basilisk/basilisk.c ../gecko/gecko.c ../datachain/datachain.c
gcc -g -fno-aggressive-loop-optimizations -Wno-deprecated -c -DISNOTARYNODE=1 -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 -lnanomsg -lcurl -lssl -lcrypto -lpthread -lz -lm
../agents/iguana notary & #> 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

2
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\"}"

2
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\"}"

Loading…
Cancel
Save