Skip to content

Commit

Permalink
Fix linter offences
Browse files Browse the repository at this point in the history
  • Loading branch information
sponomarev committed Dec 5, 2023
1 parent 8fdd925 commit c160ed1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
11 changes: 5 additions & 6 deletions libsol/token_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -545,15 +545,14 @@ const struct token_info token_infos[] = {
{{{0xfb, 0xff, 0xbe, 0x51, 0xe1, 0x73, 0x11, 0x60, 0xaa, 0x8e, 0xb9,
0x1c, 0xbf, 0xe3, 0x1d, 0x8d, 0x67, 0xbd, 0x25, 0xcf, 0xc2, 0xee,
0x12, 0x01, 0x97, 0x8e, 0x5c, 0x1a, 0xb3, 0x22, 0xfc, 0xcc}},
"HXRO"}
};
"HXRO"}};

const char* get_token_symbol(const Pubkey* mint_address) {
for (size_t i = 0; i < ARRAY_LEN(token_infos); i++) {
const struct token_info* ti = &token_infos[i];
if (memcmp(&(ti->mint_address), mint_address, PUBKEY_SIZE) == 0) {
return ti->symbol;
}
const struct token_info* ti = &token_infos[i];
if (memcmp(&(ti->mint_address), mint_address, PUBKEY_SIZE) == 0) {
return ti->symbol;
}
}
return "???";
}
8 changes: 6 additions & 2 deletions libsol/token_info_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,18 @@ void test_get_token_symbol_unknown() {
}

void test_get_token_symbol_USDC() {
Pubkey pubkey = {{0xc6,0xfa,0x7a,0xf3,0xbe,0xdb,0xad,0x3a,0x3d,0x65,0xf3,0x6a,0xab,0xc9,0x74,0x31,0xb1,0xbb,0xe4,0xc2,0xd2,0xf6,0xe0,0xe4,0x7c,0xa6,0x02,0x03,0x45,0x2f,0x5d,0x61}};
Pubkey pubkey = {{0xc6, 0xfa, 0x7a, 0xf3, 0xbe, 0xdb, 0xad, 0x3a, 0x3d, 0x65, 0xf3,
0x6a, 0xab, 0xc9, 0x74, 0x31, 0xb1, 0xbb, 0xe4, 0xc2, 0xd2, 0xf6,
0xe0, 0xe4, 0x7c, 0xa6, 0x02, 0x03, 0x45, 0x2f, 0x5d, 0x61}};
const char* symbol = get_token_symbol(&pubkey);

assert_string_equal(symbol, "USDC");
}

void test_get_token_symbol_SOL() {
Pubkey pubkey = {{0x06,0x9b,0x88,0x57,0xfe,0xab,0x81,0x84,0xfb,0x68,0x7f,0x63,0x46,0x18,0xc0,0x35,0xda,0xc4,0x39,0xdc,0x1a,0xeb,0x3b,0x55,0x98,0xa0,0xf0,0x00,0x00,0x00,0x00,0x01}};
Pubkey pubkey = {{0x06, 0x9b, 0x88, 0x57, 0xfe, 0xab, 0x81, 0x84, 0xfb, 0x68, 0x7f,
0x63, 0x46, 0x18, 0xc0, 0x35, 0xda, 0xc4, 0x39, 0xdc, 0x1a, 0xeb,
0x3b, 0x55, 0x98, 0xa0, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x01}};
const char* symbol = get_token_symbol(&pubkey);

assert_string_equal(symbol, "SOL");
Expand Down

0 comments on commit c160ed1

Please sign in to comment.