Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
57d585e8ed
  1. 18
      crypto777/iguana_serdes.c
  2. 9
      crypto777/iguana_utils.c
  3. 7
      iguana/exchanges/bitcoin.c
  4. 18
      iguana/iguana_peers.c
  5. 2
      iguana/main.c
  6. 42
      iguana/tests/jsoncmp.c
  7. 1
      iguana/tests/make_jsoncmp

18
crypto777/iguana_serdes.c

@ -52,24 +52,6 @@ int32_t iguana_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endian
return(len);
}
int32_t iguana_validatehdr(char *symbol,struct iguana_msghdr *H)
{
int32_t i = 0,len = -1;
if ( strcmp(symbol,"VPN") != 0 )
{
for (i=0; Iguana_validcommands[i]!=0&&Iguana_validcommands[i][0]!=0; i++)
if ( strcmp(H->command,Iguana_validcommands[i]) == 0 )
break;
}
if ( Iguana_validcommands[i][0] != 0 )
{
iguana_rwnum(0,H->serdatalen,sizeof(H->serdatalen),(uint32_t *)&len);
if ( len > IGUANA_MAXPACKETSIZE )
return(-1);
}
return(len);
}
int32_t iguana_rwbignum(int32_t rwflag,uint8_t *serialized,int32_t len,uint8_t *endianedp)
{
int32_t i;

9
crypto777/iguana_utils.c

@ -190,7 +190,7 @@ double dxblend(double *destp,double val,double decay)
return(slope);
}
int32_t TerminateQ_queued;
int32_t TerminateQ_queued; queue_t TerminateQ;
/*void iguana_terminator(void *arg)
{
struct iguana_thread *t; uint32_t lastdisp = 0; int32_t terminated = 0;
@ -1062,3 +1062,10 @@ void calc_curve25519_str(char *hexstr,uint8_t *buf,uint8_t *msg,int32_t len)
x = curve25519(priv,curve25519_basepoint9());
init_hexbytes_noT(hexstr,x.bytes,sizeof(x));
}
void calc_rmd160_sha256(uint8_t rmd160[20],uint8_t *data,int32_t datalen)
{
bits256 hash;
vcalc_sha256(0,hash.bytes,data,datalen);
calc_rmd160(0,rmd160,hash.bytes,sizeof(hash));
}

7
iguana/exchanges/bitcoin.c

@ -59,13 +59,6 @@ int32_t bitcoin_addr2rmd160(uint8_t *addrtypep,uint8_t rmd160[20],char *coinaddr
return(0);
}
void calc_rmd160_sha256(uint8_t rmd160[20],uint8_t *data,int32_t datalen)
{
bits256 hash;
vcalc_sha256(0,hash.bytes,data,datalen);
calc_rmd160(0,rmd160,hash.bytes,sizeof(hash));
}
char *bitcoin_address(char *coinaddr,uint8_t addrtype,uint8_t *pubkey,int32_t len)
{
int32_t i; uint8_t data[25]; bits256 hash;// char checkaddr[65];

18
iguana/iguana_peers.c

@ -18,6 +18,24 @@
#define _iguana_hashfind(coin,ipbits) _iguana_hashset(coin,ipbits,-1)
struct iguana_iAddr *iguana_iAddrhashfind(struct iguana_info *coin,uint64_t ipbits,int32_t createflag);
int32_t iguana_validatehdr(char *symbol,struct iguana_msghdr *H)
{
int32_t i = 0,len = -1;
if ( strcmp(symbol,"VPN") != 0 )
{
for (i=0; Iguana_validcommands[i]!=0&&Iguana_validcommands[i][0]!=0; i++)
if ( strcmp(H->command,Iguana_validcommands[i]) == 0 )
break;
}
if ( Iguana_validcommands[i][0] != 0 )
{
iguana_rwnum(0,H->serdatalen,sizeof(H->serdatalen),(uint32_t *)&len);
if ( len > IGUANA_MAXPACKETSIZE )
return(-1);
}
return(len);
}
struct iguana_iAddr *_iguana_hashset(struct iguana_info *coin,uint32_t ipbits,int32_t itemind)
{
struct iguana_iAddr *ptr = 0; int32_t allocsize; char str[65]; struct OS_memspace *mem = 0;

2
iguana/main.c

@ -61,7 +61,7 @@ struct iguana_info *Coins[IGUANA_MAXCOINS];
char Userhome[512];
int32_t USE_JAY,FIRST_EXTERNAL,IGUANA_disableNXT,Debuglevel,BIGENDIAN;
uint32_t prices777_NXTBLOCK,MAX_DEPTH = 100;
queue_t helperQ,jsonQ,finishedQ,bundlesQ,emitQ,TerminateQ;
queue_t helperQ,jsonQ,finishedQ,bundlesQ,emitQ;
struct supernet_info MYINFO,**MYINFOS;
static int32_t initflag;
int32_t HDRnet,netBLOCKS;

42
iguana/tests/jsoncmp.c

@ -0,0 +1,42 @@
#include <stdio.h>
#include <stdint.h>
#include "../../includes/cJSON.h"
#include "../../crypto777/OS_portable.h"
int32_t main(int32_t argc,char **argv)
{
cJSON *argjson,*array,*filejson,*obj,*fobj; char *fname,*filestr,*fstr,*str,*field; int32_t i,n; long filesize;
if ( argc > 2 && (argjson= cJSON_Parse(argv[2])) != 0 )
{
fname = argv[1];
if ( (filestr= OS_filestr(&filesize,fname)) != 0 )
{
if ( (filejson= cJSON_Parse(filestr)) != 0 )
{
if ( (array= jarray(&n,argjson,"fields")) == 0 )
obj = jobj(argjson,"field"), n = 1;
else obj = jitem(array,0);
for (i=0; i<n; i++)
{
if ( (field= jfieldname(obj)) != 0 )
{
if ( (fobj= jobj(filejson,field)) != 0 )
{
fstr = jprint(fobj,0);
str = jprint(obj,0);
if ( strcmp(fstr,str) != 0 )
printf("field.(%s) in (%s) mismatch (%s) != (%s)\n",field,fname,fstr,str);
free(str);
free(fstr);
} else printf("cant find field.(%s) in (%s)\n",field,fname);
}
if ( i < n-1 )
obj = jitem(array,i+1);
}
free_json(filejson);
}
free(filestr);
}
}
}

1
iguana/tests/make_jsoncmp

@ -0,0 +1 @@
gcc -o jsoncmp jsoncmp.c ../../agents/libcrypto777.a
Loading…
Cancel
Save