From 8e80ced6cea5c50e628c1931f6b3b764b97efb41 Mon Sep 17 00:00:00 2001 From: irungentoo Date: Fri, 22 May 2015 18:23:56 -0400 Subject: Move savedata to options struct. Add a way to select the type of savedata (normal savedata, load a secret key, potentially others?) to load. --- auto_tests/encryptsave_test.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'auto_tests/encryptsave_test.c') diff --git a/auto_tests/encryptsave_test.c b/auto_tests/encryptsave_test.c index a239bcee..b0828964 100644 --- a/auto_tests/encryptsave_test.c +++ b/auto_tests/encryptsave_test.c @@ -55,8 +55,8 @@ END_TEST START_TEST(test_save_friend) { - Tox *tox1 = tox_new(0, 0, 0, 0); - Tox *tox2 = tox_new(0, 0, 0, 0); + Tox *tox1 = tox_new(0, 0); + Tox *tox2 = tox_new(0, 0); ck_assert_msg(tox1 || tox2, "Failed to create 2 tox instances"); uint32_t to_compare = 974536; tox_callback_friend_request(tox2, accept_friend_request, &to_compare); @@ -75,15 +75,23 @@ START_TEST(test_save_friend) ck_assert_msg(ret, "failed to encrypted save: %u", error1); ck_assert_msg(tox_is_data_encrypted(enc_data), "magic number missing"); + struct Tox_Options options; + tox_options_default(&options); + options.savedata_type = TOX_SAVEDATA_TYPE_TOX_SAVE; + options.savedata_data = enc_data; + options.savedata_length = size2; + TOX_ERR_NEW err2; - Tox *tox3 = tox_new(0, enc_data, size2, &err2); + Tox *tox3 = tox_new(&options, &err2); ck_assert_msg(err2 == TOX_ERR_NEW_LOAD_ENCRYPTED, "wrong error! %u. should fail with %u", err2, TOX_ERR_NEW_LOAD_ENCRYPTED); uint8_t dec_data[size]; TOX_ERR_DECRYPTION err3; ret = tox_pass_decrypt(enc_data, size2, "correcthorsebatterystaple", 25, dec_data, &err3); ck_assert_msg(ret, "failed to decrypt save: %u", err3); - tox3 = tox_new(0, dec_data, size, &err2); + options.savedata_data = dec_data; + options.savedata_length = size; + tox3 = tox_new(&options, &err2); ck_assert_msg(err2 == TOX_ERR_NEW_OK, "failed to load from decrypted data: %u", err2); uint8_t address2[TOX_PUBLIC_KEY_SIZE]; ret = tox_friend_get_public_key(tox3, 0, address2, 0); @@ -111,7 +119,9 @@ START_TEST(test_save_friend) // and now with the code in use (I only bothered with manually to debug this, and it seems a waste // to remove the manual check now that it's there) - Tox *tox4 = tox_new(0, out1, size, &err2); + options.savedata_data = out1; + options.savedata_length = size; + Tox *tox4 = tox_new(&options, &err2); ck_assert_msg(err2 == TOX_ERR_NEW_OK, "failed to new the third"); uint8_t address5[TOX_PUBLIC_KEY_SIZE]; ret = tox_friend_get_public_key(tox4, 0, address5, 0); -- cgit v1.2.3