Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
679a03d1bc
  1. 3
      basilisk/basilisk.c
  2. 38
      basilisk/basilisk_CMD.c
  3. 2
      iguana/tests/get
  4. 2
      iguana/tests/set

3
basilisk/basilisk.c

@ -374,6 +374,8 @@ char *basilisk_standardservice(char *CMD,basilisk_requestfunc *func,struct super
ptr = (*func)(&Lptr,myinfo,pubkey,vals,data,datalen); ptr = (*func)(&Lptr,myinfo,pubkey,vals,data,datalen);
if ( allocptr != 0 ) if ( allocptr != 0 )
free(allocptr); free(allocptr);
if ( ptr != 0 )
{
if ( blockflag != 0 ) if ( blockflag != 0 )
{ {
ptr->vals = jduplicate(vals); ptr->vals = jduplicate(vals);
@ -386,6 +388,7 @@ char *basilisk_standardservice(char *CMD,basilisk_requestfunc *func,struct super
jaddstr(retjson,"result","success"); jaddstr(retjson,"result","success");
jaddnum(retjson,"numsent",ptr->numsent); jaddnum(retjson,"numsent",ptr->numsent);
} else jaddstr(retjson,"error","didnt find any nodes to send to"); } else jaddstr(retjson,"error","didnt find any nodes to send to");
} else jaddstr(retjson,"error","couldnt create basilisk item");
return(jprint(retjson,1)); return(jprint(retjson,1));
} }

38
basilisk/basilisk_CMD.c

@ -31,11 +31,11 @@ void basilisk_request_goodbye(struct supernet_info *myinfo)
free_json(valsobj); free_json(valsobj);
} }
char *basilisk_respond_publish(struct supernet_info *myinfo,char *CMD,struct iguana_peer *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen,bits256 prevhash,int32_t from_basilisk) char *basilisk_respond_setfield(struct supernet_info *myinfo,char *CMD,struct iguana_peer *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen,bits256 prevhash,int32_t from_basilisk)
{ {
bits256 hash,cathash; struct category_info *cat,*prevcat=0; char *category; char str[65]; bits256 hash,cathash; struct category_info *cat,*prevcat=0; char *category; char str[65];
printf("from.(%s) PUB.(%s) datalen.%d\n",remoteaddr,jprint(valsobj,0),datalen); printf("from.(%s) SET.(%s) datalen.%d\n",remoteaddr,jprint(valsobj,0),datalen);
if ( datalen <= 0 || (category= jstr(valsobj,"cat")) == 0 ) if ( datalen <= 0 || (category= jstr(valsobj,"category")) == 0 )
return(0); return(0);
vcalc_sha256(0,cathash.bytes,(uint8_t *)category,(int32_t)strlen(category)); vcalc_sha256(0,cathash.bytes,(uint8_t *)category,(int32_t)strlen(category));
vcalc_sha256(0,hash.bytes,data,datalen); vcalc_sha256(0,hash.bytes,data,datalen);
@ -55,16 +55,16 @@ char *basilisk_respond_publish(struct supernet_info *myinfo,char *CMD,struct igu
return(0); return(0);
} }
struct basilisk_item *basilisk_request_publish(struct basilisk_item *Lptr,struct supernet_info *myinfo,bits256 pubkey,cJSON *valsobj,uint8_t *data,int32_t datalen) struct basilisk_item *basilisk_request_setfield(struct basilisk_item *Lptr,struct supernet_info *myinfo,bits256 pubkey,cJSON *valsobj,uint8_t *data,int32_t datalen)
{ {
return(basilisk_requestservice(Lptr,myinfo,"PUB",0,valsobj,pubkey)); return(basilisk_requestservice(Lptr,myinfo,"SET",0,valsobj,pubkey));
} }
char *basilisk_respond_subscribe(struct supernet_info *myinfo,char *CMD,struct iguana_peer *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen,bits256 prevhash,int32_t from_basilisk) char *basilisk_respond_getfield(struct supernet_info *myinfo,char *CMD,struct iguana_peer *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen,bits256 prevhash,int32_t from_basilisk)
{ {
bits256 cathash; struct category_info *cat; char *category,*hexstr; cJSON *retjson; bits256 cathash; struct category_info *cat; char *category,*hexstr; cJSON *retjson;
printf("from.(%s) SUB.(%s) datalen.%d\n",remoteaddr,jprint(valsobj,0),datalen); printf("from.(%s) GET.(%s) datalen.%d\n",remoteaddr,jprint(valsobj,0),datalen);
if ( (category= jstr(valsobj,"cat")) == 0 ) if ( (category= jstr(valsobj,"category")) == 0 )
return(0); return(0);
vcalc_sha256(0,cathash.bytes,(uint8_t *)category,(int32_t)strlen(category)); vcalc_sha256(0,cathash.bytes,(uint8_t *)category,(int32_t)strlen(category));
if ( (cat= category_find(cathash,prevhash)) == 0 ) if ( (cat= category_find(cathash,prevhash)) == 0 )
@ -79,37 +79,37 @@ char *basilisk_respond_subscribe(struct supernet_info *myinfo,char *CMD,struct i
return(jprint(retjson,1)); return(jprint(retjson,1));
} }
struct basilisk_item *basilisk_request_subscribe(struct basilisk_item *Lptr,struct supernet_info *myinfo,bits256 prevhash,cJSON *valsobj,uint8_t *data,int32_t datalen) struct basilisk_item *basilisk_request_getfield(struct basilisk_item *Lptr,struct supernet_info *myinfo,bits256 prevhash,cJSON *valsobj,uint8_t *data,int32_t datalen)
{ {
bits256 cathash; char *category; bits256 cathash; char *category;
if ( datalen <= 0 || (category= jstr(valsobj,"cat")) == 0 ) if ( datalen <= 0 || (category= jstr(valsobj,"category")) == 0 )
return(0); return(0);
vcalc_sha256(0,cathash.bytes,(uint8_t *)category,(int32_t)strlen(category)); vcalc_sha256(0,cathash.bytes,(uint8_t *)category,(int32_t)strlen(category));
return(basilisk_requestservice(Lptr,myinfo,"SUB",0,valsobj,prevhash)); return(basilisk_requestservice(Lptr,myinfo,"GET",0,valsobj,prevhash));
} }
char *basilisk_respond_setfield(struct supernet_info *myinfo,char *CMD,struct iguana_peer *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen,bits256 pubkey,int32_t from_basilisk) char *basilisk_respond_publish(struct supernet_info *myinfo,char *CMD,struct iguana_peer *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen,bits256 pubkey,int32_t from_basilisk)
{ {
char *retstr=0; char *retstr=0;
printf("from.(%s) SET.(%s) datalen.%d\n",remoteaddr,jprint(valsobj,0),datalen); printf("from.(%s) PUB.(%s) datalen.%d\n",remoteaddr,jprint(valsobj,0),datalen);
return(retstr); return(retstr);
} }
struct basilisk_item *basilisk_request_setfield(struct basilisk_item *Lptr,struct supernet_info *myinfo,bits256 pubkey,cJSON *valsobj,uint8_t *data,int32_t datalen) struct basilisk_item *basilisk_request_publish(struct basilisk_item *Lptr,struct supernet_info *myinfo,bits256 pubkey,cJSON *valsobj,uint8_t *data,int32_t datalen)
{ {
return(basilisk_requestservice(Lptr,myinfo,"SET",0,valsobj,pubkey)); return(basilisk_requestservice(Lptr,myinfo,"PUB",0,valsobj,pubkey));
} }
char *basilisk_respond_getfield(struct supernet_info *myinfo,char *CMD,struct iguana_peer *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen,bits256 pubkey,int32_t from_basilisk) char *basilisk_respond_subscribe(struct supernet_info *myinfo,char *CMD,struct iguana_peer *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen,bits256 pubkey,int32_t from_basilisk)
{ {
char *retstr=0; char *retstr=0;
printf("from.(%s) GET.(%s) datalen.%d\n",remoteaddr,jprint(valsobj,0),datalen); printf("from.(%s) SUB.(%s) datalen.%d\n",remoteaddr,jprint(valsobj,0),datalen);
return(retstr); return(retstr);
} }
struct basilisk_item *basilisk_request_getfield(struct basilisk_item *Lptr,struct supernet_info *myinfo,bits256 pubkey,cJSON *valsobj,uint8_t *data,int32_t datalen) struct basilisk_item *basilisk_request_subscribe(struct basilisk_item *Lptr,struct supernet_info *myinfo,bits256 pubkey,cJSON *valsobj,uint8_t *data,int32_t datalen)
{ {
return(basilisk_requestservice(Lptr,myinfo,"GET",0,valsobj,pubkey)); return(basilisk_requestservice(Lptr,myinfo,"SUB",0,valsobj,pubkey));
} }
char *basilisk_respond_dispatch(struct supernet_info *myinfo,char *CMD,struct iguana_peer *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen,bits256 pubkey,int32_t from_basilisk) char *basilisk_respond_dispatch(struct supernet_info *myinfo,char *CMD,struct iguana_peer *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen,bits256 pubkey,int32_t from_basilisk)

2
iguana/tests/get

@ -1 +1 @@
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"basilisk\",\"method\":\"getfield\"}" curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"basilisk\",\"method\":\"getfield\",\"category\":\"test\"}"

2
iguana/tests/set

@ -1 +1 @@
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"basilisk\",\"method\":\"setfield\",\"vals\":{\"setfield\":\"setthis\"},\"hexstr\":\"beefdead\"}" curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"basilisk\",\"method\":\"setfield\",\"vals\":{\"setfield\":\"setthis\"},\"hexstr\":\"beefdead\",\"category\":\"test\"}"

Loading…
Cancel
Save