Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
282d2e5291
  1. 11
      basilisk/basilisk_MSG.c
  2. 2
      iguana/tests/request

11
basilisk/basilisk_MSG.c

@ -171,7 +171,7 @@ HASH_ARRAY_STRING(basilisk,sendmessage,hash,vals,hexstr)
int32_t basilisk_channelsend(struct supernet_info *myinfo,bits256 hash,uint32_t channel,uint32_t msgid,uint8_t *data,int32_t datalen) int32_t basilisk_channelsend(struct supernet_info *myinfo,bits256 hash,uint32_t channel,uint32_t msgid,uint8_t *data,int32_t datalen)
{ {
char *retstr,*hexstr,strbuf[16384],*ptr = 0; int32_t retval = -1; cJSON *retjson,*valsobj; char *retstr,*hexstr,strbuf[16384],*ptr = 0; int32_t retval = -1; cJSON *retarray,*item,*valsobj;
if ( (hexstr= basilisk_addhexstr(&ptr,0,strbuf,sizeof(strbuf),data,datalen)) != 0 ) if ( (hexstr= basilisk_addhexstr(&ptr,0,strbuf,sizeof(strbuf),data,datalen)) != 0 )
{ {
valsobj = cJSON_CreateObject(); valsobj = cJSON_CreateObject();
@ -179,11 +179,14 @@ int32_t basilisk_channelsend(struct supernet_info *myinfo,bits256 hash,uint32_t
jaddnum(valsobj,"msgid",msgid); jaddnum(valsobj,"msgid",msgid);
if ( (retstr= basilisk_sendmessage(myinfo,0,0,0,hash,valsobj,hexstr)) != 0 ) if ( (retstr= basilisk_sendmessage(myinfo,0,0,0,hash,valsobj,hexstr)) != 0 )
{ {
if ( (retjson= cJSON_Parse(retstr)) != 0 ) if ( (retarray= cJSON_Parse(retstr)) != 0 )
{ {
if ( jobj(retjson,"error") == 0 ) if ( is_cJSON_Array(retarray) != 0 )
item = jitem(retarray,0);
else item = retarray;
if ( jobj(item,"error") == 0 )
retval = 0; retval = 0;
free_json(retjson); free_json(retarray);
} }
free(retstr); free(retstr);
} }

2
iguana/tests/request

@ -1,2 +1,2 @@
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"InstantDEX\",\"method\":\"request\",\"vals\":{\"source\":\"BTCD\",\"amount\":1,\"dest\":\"BTC\",\"minprice\":0.0025,\"autoflag\":1}}" curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"InstantDEX\",\"method\":\"request\",\"vals\":{\"source\":\"BTCD\",\"amount\":1,\"dest\":\"BTC\",\"minprice\":0.0025}}"

Loading…
Cancel
Save