Browse Source

Test

etomic
jl777 8 years ago
parent
commit
d811364082
  1. 7
      basilisk/basilisk.c
  2. 2
      basilisk/basilisk_DEX.c
  3. 2
      basilisk/basilisk_swap.c
  4. 8
      iguana/exchanges/mm.c
  5. 2
      iguana/tests/dexkvsearch

7
basilisk/basilisk.c

@ -1897,7 +1897,8 @@ int32_t InstantDEX_process_channelget(struct supernet_info *myinfo,void *ptr,int
INT_ARG(InstantDEX,incoming,requestid)
{
cJSON *retjson,*retarray; bits256 zero; uint32_t DEX_channel,msgid,now; int32_t retval,width,drift=3; uint8_t data[32768];
static uint32_t counter;
cJSON *retjson,*retarray; bits256 zero; uint32_t DEX_channel,msgid,now,n = myinfo->numsmartaddrs+1; int32_t retval,width,drift=3; bits256 pubkey; uint8_t data[32768];
now = (uint32_t)time(NULL);
memset(&zero,0,sizeof(zero));
width = (now - myinfo->DEXpoll) + 2*drift;
@ -1905,6 +1906,10 @@ INT_ARG(InstantDEX,incoming,requestid)
width = 2*drift+1;
else if ( width > 64 )
width = 64;
if ( (counter % n) == n-1 )
pubkey = myinfo->myaddr.persistent;
else pubkey = myinfo->smartaddrs[counter % n].pubkey;
counter++;
myinfo->DEXpoll = now;
retjson = cJSON_CreateObject();
DEX_channel = 'D' + ((uint32_t)'E' << 8) + ((uint32_t)'X' << 16);

2
basilisk/basilisk_DEX.c

@ -286,7 +286,7 @@ int32_t basilisk_requests_poll(struct supernet_info *myinfo)
{
static uint32_t lastpoll;
char *retstr,typestr[64]; uint8_t data[32768]; cJSON *outerarray,*retjson; uint32_t msgid,channel; int32_t datalen,i,n,retval = 0; struct basilisk_request issueR; bits256 privkey; double bidasks[2],hwm = 0.;
if ( myinfo->IAMNOTARY != 0 || time(NULL) < lastpoll+20 || (myinfo->IAMLP == 0 && myinfo->DEXactive < time(NULL)) )
if ( myinfo->IAMNOTARY != 0 || time(NULL) < lastpoll+5 || (myinfo->IAMLP == 0 && myinfo->DEXactive < time(NULL)) )
return(retval);
lastpoll = (uint32_t)time(NULL);
memset(&issueR,0,sizeof(issueR));

2
basilisk/basilisk_swap.c

@ -2772,7 +2772,7 @@ struct basilisk_swap *basilisk_thread_start(struct supernet_info *myinfo,bits256
m = n = 0;
if ( bitcoin_swapinit(myinfo,privkey,pubkey33,pubkey25519,swap,optionduration,statebits,reinit) != 0 )
{
for (iter=0; iter<1; iter++)
for (iter=0; iter<5; iter++)
{
basilisk_psockinit(myinfo,swap,statebits == 0);
sleep(3);

8
iguana/exchanges/mm.c

@ -323,7 +323,8 @@ void marketmaker_pendingupdate(char *exchange,char *base,char *rel)
void marketmaker_pendinginit(char *exchange,char *base,char *rel)
{
char *retstr,*orderid; cJSON *retjson,*array,*item; int32_t i,j,n,dir; struct mmpending_order *ptr;
char *retstr,*orderid,*pairstr,relbase[64]; cJSON *retjson,*array,*item; int32_t i,j,n,dir; struct mmpending_order *ptr;
sprintf(relbase,"%s-%s",rel,base);
if ( (retstr= DEX_openorders(exchange)) != 0 )
{
if ( (retjson= cJSON_Parse(retstr)) != 0 )
@ -334,6 +335,11 @@ void marketmaker_pendinginit(char *exchange,char *base,char *rel)
for (i=0; i<n; i++)
{
item = jitem(array,i);
if ( (pairstr= jstr(item,"Exchange")) == 0 )
continue;
if ( strcmp(pairstr,relbase) != 0 )
printf("skip %s when %s\n",pairstr,relbase);
else printf("matches %s vs %s\n",pairstr,relbase);
//printf("(%s)\n",jprint(item,0));
//{"success":true,"message":"","result":[{"Uuid":null,"OrderUuid":"81ad3e37-65d4-4fee-9c29-03b050f5192b","Exchange":"BTC-KMD","OrderType":"LIMIT_BUY","Quantity":885.19934578,"QuantityRemaining":885.19934578,"Limit":0.00011184,"CommissionPaid":0,"Price":0,"PricePerUnit":null,"Opened":"2017-02-19T19:14:02.94","Closed":null,"CancelInitiated":false,"ImmediateOrCancel":false,"IsConditional":false,"Condition":"NONE","ConditionTarget":null}],"tag":"10056789044100011414"}
if ( (orderid= jstr(item,"OrderUuid")) != 0 && is_cJSON_Null(jobj(item,"Closed")) != 0 && is_cJSON_False(jobj(item,"CancelInitiated")) != 0 )

2
iguana/tests/dexkvsearch

@ -1,4 +1,4 @@
#!/bin/bash
#curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"kvsearch\",\"key\":\"foo\",\"symbol\":\"KMD\"}"
#curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"kvsearch\",\"key\":\"test\",\"symbol\":\"KV\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"kvsearch\",\"key\":\"2aa52428-fd9df866\",\"symbol\":\"KV\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"kvsearch\",\"key\":\"89bb7bb9-e6857af8\",\"symbol\":\"KV\"}"

Loading…
Cancel
Save