Skip to content

Commit

Permalink
tmp fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
chcmedeiros committed Sep 7, 2023
1 parent 87192f6 commit 080fb78
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
16 changes: 10 additions & 6 deletions fuzz/parser_parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <cstdio>

#include "parser.h"
#include "zxformat.h"


#ifdef NDEBUG
Expand All @@ -11,9 +12,11 @@


using std::size_t;
namespace {
char PARSER_KEY[16384];
char PARSER_VALUE[16384];
}

static char PARSER_KEY[16384];
static char PARSER_VALUE[16384];

extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
Expand All @@ -24,9 +27,10 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
MEMZERO(&tx_obj, sizeof(tx_obj));
char buffer[1000];
array_to_hexstr(buffer, sizeof(buffer), data, size);
fprintf(stderr, "%s\n", buffer);

(void)fprintf(stderr, "%s\n", buffer);

fprintf(stderr, "----------------------------------------------\n");
(void)fprintf(stderr, "----------------------------------------------\n");

rc = parser_parse(&ctx, data, size, &tx_obj);
if (rc != parser_ok) {
Expand All @@ -41,7 +45,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
uint8_t num_items;
rc = parser_getNumItems(&ctx, &num_items);
if (rc != parser_ok) {
fprintf(stderr,
(void)fprintf(stderr,
"error in parser_getNumItems: %s\n",
parser_getErrorDescription(rc));
assert(false);
Expand All @@ -59,7 +63,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
// fprintf(stderr, "%s = %s\n", PARSER_KEY, PARSER_VALUE);

if (rc != parser_ok) {
fprintf(stderr,
(void)fprintf(stderr,
"error getting item %u at page index %u: %s\n",
(unsigned)i,
(unsigned)page_idx,
Expand Down
4 changes: 3 additions & 1 deletion tests/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ TEST(Address, EVMAddressEvmos) {
const char bech32_hrp[] = "evmos";
char address[100] = {0};
const zxerr_t err = bech32EncodeFromBytes(address, sizeof(address), bech32_hrp, eth_address, 20, 0, BECH32_ENCODING_BECH32);
EXPECT_EQ(err, parser_ok);

const std::string evm_address(address, address + strnlen(address, sizeof(address)));
EXPECT_EQ(evm_address, "evmos1dj7dw0xcazjzs3rx9u9quakh77d0myeamrkupf");
Expand All @@ -125,7 +126,8 @@ TEST(Address, EVMAddressCosmos) {
const char bech32_hrp[] = "cosmos";
char address[100] = {0};
const zxerr_t err = bech32EncodeFromBytes(address, sizeof(address), bech32_hrp, eth_address, 20, 0, BECH32_ENCODING_BECH32);

EXPECT_EQ(err, parser_ok);

const std::string evm_address(address, address + strnlen(address, sizeof(address)));
EXPECT_EQ(evm_address, "cosmos15n2h0lzvfgc8x4fm6fdya89n78x6ee2fm7fxr3");
}

0 comments on commit 080fb78

Please sign in to comment.