Squashed 'external/toxcore/c-toxcore/' changes from d4b06edc2a..adbd5b32d8
adbd5b32d8 feat: add ngc events 15ee46d431 add simple test for max sized lossy custom group packet 01e7950c67 increase lossy custom packet size in ngc to the toxcore common max of 1373 9b3c1089f1 Make group saving/loading more forgiving with data errors 55a76003b0 Replace memset(int32_t*, -1, _) with a for-loop 66453439ac fix: also Install header for private/experimental API functions with autotools 3983369103 fix: Enable debug flag for ubsan. 4d1db21102 Update tox-boostrapd hash e700c31b70 Fix memory leak in group connection 2994441d9c Fix memory leak in save-generator d0400df13d Fix memory leak in tox-bootstrapd 7a6d50ebe3 Install header for private/experimental API functions d89677fb5f Remove defunct IRC channel from README.md 26d41fc604 Replace DEFAULT_TCP_RELAY_PORTS_COUNT with a compile-time calculation 63fb2941ca Clarify disabling of static assert checks 65b3375b98 refactor: Use Bin_Pack for packing Node_format. 84ba154f6a group connection queries now return our own connection type a4df2862ed Replace tabs with spaces 1b6dee7594 Update tox-bootstrapd's base Docker images a030cdee5c Fix Docker tox-bootstrapd hash update failing when using BuildKit 7cfe35dff2 cleanup: Remove explicit layering_check feature. d390947245 chore: Upgrade sonar-scan jvm to java 17. d1e850c56c fix: Add missing `htons` call when adding configured TCP relay. 814090f2b8 chore: Cancel old PR builds on docker and sonar-scan workflows. 83efb17367 perf: Add a KVM FreeBSD build on cirrus ci. a927183233 test: Add a test for encrypting 100MB of data. 28f39049f6 chore: Retry freebsd tests 2 times. 47e77d1bb0 chore: Use C99 on MSVC instead of C11. 7155f7f60e test: Add an s390x build (on alpine) for CI. 6c35cef63f chore: Add a compcert docker run script. 41e6ea865e cleanup: Use tcc docker image for CI. e726b197b0 refactor: Store time in Mono_Time in milliseconds. REVERT: d4b06edc2a feat: add ngc events git-subtree-dir: external/toxcore/c-toxcore git-subtree-split: adbd5b32d85d9c13800f5ece17c0a9dce99faacd
This commit is contained in:
@ -1,7 +1,5 @@
|
||||
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
|
||||
|
||||
package(features = ["layering_check"])
|
||||
|
||||
cc_library(
|
||||
name = "check_compat",
|
||||
testonly = True,
|
||||
|
@ -269,6 +269,30 @@ static void test_large_data_symmetric(void)
|
||||
free(m1);
|
||||
}
|
||||
|
||||
static void test_very_large_data(void)
|
||||
{
|
||||
const Random *rng = system_random();
|
||||
ck_assert(rng != nullptr);
|
||||
|
||||
uint8_t nonce[CRYPTO_NONCE_SIZE] = {0};
|
||||
uint8_t pk[CRYPTO_PUBLIC_KEY_SIZE];
|
||||
uint8_t sk[CRYPTO_SECRET_KEY_SIZE];
|
||||
crypto_new_keypair(rng, pk, sk);
|
||||
|
||||
// 100 MiB of data (all zeroes, doesn't matter what's inside).
|
||||
const uint32_t plain_size = 100 * 1024 * 1024;
|
||||
uint8_t *plain = (uint8_t *)malloc(plain_size);
|
||||
uint8_t *encrypted = (uint8_t *)malloc(plain_size + CRYPTO_MAC_SIZE);
|
||||
|
||||
ck_assert(plain != nullptr);
|
||||
ck_assert(encrypted != nullptr);
|
||||
|
||||
encrypt_data(pk, sk, nonce, plain, plain_size, encrypted);
|
||||
|
||||
free(encrypted);
|
||||
free(plain);
|
||||
}
|
||||
|
||||
static void increment_nonce_number_cmp(uint8_t *nonce, uint32_t num)
|
||||
{
|
||||
uint32_t num1 = 0;
|
||||
@ -340,6 +364,7 @@ int main(void)
|
||||
test_endtoend(); /* waiting up to 15 seconds */
|
||||
test_large_data();
|
||||
test_large_data_symmetric();
|
||||
test_very_large_data();
|
||||
test_increment_nonce();
|
||||
test_memzero();
|
||||
|
||||
|
@ -123,7 +123,7 @@ static void test_dht_getnodes(AutoTox *autotoxes)
|
||||
tox_self_get_dht_id(autotoxes[i].tox, public_key_list[i]);
|
||||
tox_callback_dht_get_nodes_response(autotoxes[i].tox, getnodes_response_cb);
|
||||
|
||||
printf("Peer %zu dht closenode count total/annouce-capable: %d/%d\n",
|
||||
printf("Peer %zu dht closenode count total/announce-capable: %d/%d\n",
|
||||
i,
|
||||
tox_dht_get_num_closelist(autotoxes[i].tox),
|
||||
tox_dht_get_num_closelist_announce_capable(autotoxes[i].tox)
|
||||
|
@ -44,6 +44,10 @@ typedef struct State {
|
||||
#define TEST_CUSTOM_PACKET "Why'd ya spill yer beans?"
|
||||
#define TEST_CUSTOM_PACKET_LEN (sizeof(TEST_CUSTOM_PACKET) - 1)
|
||||
|
||||
#define TEST_CUSTOM_PACKET_LARGE "Where is it I've read that someone condemned to death says or thinks, an hour before his death, that if he had to live on some high rock, on such a narrow ledge that he'd only room to stand, and the ocean, everlasting darkness, everlasting solitude, everlasting tempest around him, if he had to remain standing on a square yard of space all his life, a thousand years, eternity, it were better to live so than to die at once. Only to live, to live and live! Life, whatever it may be! ...............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................0123456789"
|
||||
#define TEST_CUSTOM_PACKET_LARGE_LEN (sizeof(TEST_CUSTOM_PACKET_LARGE) - 1)
|
||||
static_assert(TEST_CUSTOM_PACKET_LARGE_LEN == TOX_GROUP_MAX_CUSTOM_LOSSY_PACKET_LENGTH, "Should be max");
|
||||
|
||||
#define TEST_CUSTOM_PRIVATE_PACKET "This is a custom private packet. Enjoy."
|
||||
#define TEST_CUSTOM_PRIVATE_PACKET_LEN (sizeof(TEST_CUSTOM_PRIVATE_PACKET) - 1)
|
||||
|
||||
@ -187,6 +191,21 @@ static void group_custom_packet_handler(Tox *tox, uint32_t groupnumber, uint32_t
|
||||
++state->custom_packets_received;
|
||||
}
|
||||
|
||||
static void group_custom_packet_large_handler(Tox *tox, uint32_t groupnumber, uint32_t peer_id, const uint8_t *data,
|
||||
size_t length, void *user_data)
|
||||
{
|
||||
ck_assert_msg(length == TEST_CUSTOM_PACKET_LARGE_LEN, "Failed to receive large custom packet. Invalid length: %zu\n", length);
|
||||
|
||||
ck_assert(memcmp(data, TEST_CUSTOM_PACKET_LARGE, length) == 0);
|
||||
|
||||
AutoTox *autotox = (AutoTox *)user_data;
|
||||
ck_assert(autotox != nullptr);
|
||||
|
||||
State *state = (State *)autotox->state;
|
||||
|
||||
++state->custom_packets_received;
|
||||
}
|
||||
|
||||
static void group_message_handler(Tox *tox, uint32_t groupnumber, uint32_t peer_id, TOX_MESSAGE_TYPE type,
|
||||
const uint8_t *message, size_t length, uint32_t pseudo_msg_id, void *user_data)
|
||||
{
|
||||
@ -450,6 +469,19 @@ static void group_message_test(AutoTox *autotoxes)
|
||||
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL);
|
||||
}
|
||||
|
||||
// tox0 sends a large max sized lossy custom packet
|
||||
|
||||
// overwrite callback for larger packet
|
||||
tox_callback_group_custom_packet(tox0, group_custom_packet_large_handler);
|
||||
|
||||
tox_group_send_custom_packet(tox1, group_number, false, (const uint8_t *)TEST_CUSTOM_PACKET_LARGE, TEST_CUSTOM_PACKET_LARGE_LEN,
|
||||
&c_err);
|
||||
ck_assert_msg(c_err == TOX_ERR_GROUP_SEND_CUSTOM_PACKET_OK, "%d", c_err);
|
||||
|
||||
while (state0->custom_packets_received < 3) {
|
||||
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL);
|
||||
}
|
||||
|
||||
uint8_t m[TOX_GROUP_MAX_MESSAGE_LENGTH] = {0};
|
||||
|
||||
fprintf(stderr, "Doing lossless packet test...\n");
|
||||
@ -538,6 +570,8 @@ int main(void)
|
||||
#undef TEST_PRIVATE_MESSAGE_LEN
|
||||
#undef TEST_CUSTOM_PACKET
|
||||
#undef TEST_CUSTOM_PACKET_LEN
|
||||
#undef TEST_CUSTOM_PACKET_LARGE
|
||||
#undef TEST_CUSTOM_PACKET_LARGE_LEN
|
||||
#undef TEST_CUSTOM_PRIVATE_PACKET
|
||||
#undef TEST_CUSTOM_PRIVATE_PACKET_LEN
|
||||
#undef IGNORE_MESSAGE
|
||||
|
Reference in New Issue
Block a user