Rollback of nip44 changes, and added ability to modify timestamps in giftwraps.
This commit is contained in:
BIN
tests/nip17_test
BIN
tests/nip17_test
Binary file not shown.
BIN
tests/nip44_test
BIN
tests/nip44_test
Binary file not shown.
@@ -46,7 +46,7 @@ static nip44_test_vector_t test_vectors[] = {
|
||||
NULL
|
||||
},
|
||||
{
|
||||
"1MB payload test",
|
||||
"64KB payload test",
|
||||
"91ba716fa9e7ea2fcbad360cf4f8e0d312f73984da63d90f524ad61a6a1e7dbe", // Same keys as basic test
|
||||
"96f6fa197aa07477ab88f6981118466ae3a982faab8ad5db9d5426870c73d220",
|
||||
NULL, // Will be generated dynamically
|
||||
@@ -99,12 +99,12 @@ static int test_nip44_round_trip(const nip44_test_vector_t* tv) {
|
||||
|
||||
// Special handling for large payload tests
|
||||
char* test_plaintext;
|
||||
if (strcmp(tv->name, "1MB payload test") == 0) {
|
||||
// Generate exactly 1MB (1,048,576 bytes) of predictable content
|
||||
const size_t payload_size = 1048576;
|
||||
if (strcmp(tv->name, "64KB payload test") == 0) {
|
||||
// Generate exactly 64KB (65,535 bytes) of predictable content - max NIP-44 size
|
||||
const size_t payload_size = 65535;
|
||||
test_plaintext = malloc(payload_size + 1);
|
||||
if (!test_plaintext) {
|
||||
printf(" FAIL: Memory allocation failed for 1MB test payload\n");
|
||||
printf(" FAIL: Memory allocation failed for 64KB test payload\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ static int test_nip44_round_trip(const nip44_test_vector_t* tv) {
|
||||
}
|
||||
test_plaintext[payload_size] = '\0';
|
||||
|
||||
printf(" Generated 1MB test payload (%zu bytes)\n", payload_size);
|
||||
printf(" Generated 64KB test payload (%zu bytes)\n", payload_size);
|
||||
printf(" Pattern: \"%s\" repeated\n", pattern);
|
||||
printf(" First 64 chars: \"%.64s...\"\n", test_plaintext);
|
||||
printf(" Last 64 chars: \"...%.64s\"\n", test_plaintext + payload_size - 64);
|
||||
@@ -158,10 +158,10 @@ static int test_nip44_round_trip(const nip44_test_vector_t* tv) {
|
||||
}
|
||||
|
||||
// Test decryption - use recipient private key + sender public key
|
||||
char* decrypted = malloc(1048576 + 1); // 1MB + 1 for null terminator
|
||||
char* decrypted = malloc(65536 + 1); // 64KB + 1 for null terminator
|
||||
if (!decrypted) {
|
||||
printf(" FAIL: Memory allocation failed for decrypted buffer\n");
|
||||
if (strcmp(tv->name, "1MB payload test") == 0) free(test_plaintext);
|
||||
if (strcmp(tv->name, "64KB payload test") == 0) free(test_plaintext);
|
||||
free(encrypted);
|
||||
return -1;
|
||||
}
|
||||
@@ -170,7 +170,7 @@ static int test_nip44_round_trip(const nip44_test_vector_t* tv) {
|
||||
sender_public_key,
|
||||
encrypted,
|
||||
decrypted,
|
||||
1048576 + 1
|
||||
65536 + 1
|
||||
);
|
||||
|
||||
if (decrypt_result != NOSTR_SUCCESS) {
|
||||
@@ -192,17 +192,17 @@ static int test_nip44_round_trip(const nip44_test_vector_t* tv) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (strcmp(tv->name, "1MB payload test") == 0) {
|
||||
printf(" ✅ 1MB payload round-trip: PASS\n");
|
||||
if (strcmp(tv->name, "64KB payload test") == 0) {
|
||||
printf(" ✅ 64KB payload round-trip: PASS\n");
|
||||
printf(" ✅ Content verification: All %zu bytes match perfectly!\n", strlen(test_plaintext));
|
||||
printf(" Encrypted length: %zu bytes\n", strlen(encrypted));
|
||||
printf(" 🎉 1MB NIP-44 STRESS TEST COMPLETED SUCCESSFULLY! 🎉\n");
|
||||
printf(" 🎉 64KB NIP-44 STRESS TEST COMPLETED SUCCESSFULLY! 🎉\n");
|
||||
} else {
|
||||
printf(" PASS: Expected: \"%s\", Actual: \"%s\"\n", test_plaintext, decrypted);
|
||||
printf(" Encrypted output: %s\n", encrypted);
|
||||
}
|
||||
|
||||
if (strcmp(tv->name, "1MB payload test") == 0) free(test_plaintext);
|
||||
if (strcmp(tv->name, "64KB payload test") == 0) free(test_plaintext);
|
||||
free(encrypted);
|
||||
free(decrypted);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user