#define _DEFAULT_SOURCE #include "../nostr_core/nostr_core.h" #include "../cjson/cJSON.h" #include #include #include #include int main() { printf("๐Ÿงช Backward Compatibility Test\n"); printf("===============================\n"); // Create pool nostr_relay_pool_t* pool = nostr_relay_pool_create(NULL); if (!pool) { printf("โŒ Failed to create pool\n"); return 1; } // Create a test event cJSON* event = cJSON_CreateObject(); cJSON_AddStringToObject(event, "id", "test_event_sync"); cJSON_AddNumberToObject(event, "kind", 1); cJSON_AddStringToObject(event, "content", "Test sync publish"); cJSON_AddNumberToObject(event, "created_at", time(NULL)); cJSON_AddStringToObject(event, "pubkey", "test_pubkey"); cJSON_AddStringToObject(event, "sig", "test_signature"); // Test with non-existent relay (should return 0 successful publishes) const char* test_relays[] = {"ws://nonexistent.example.com"}; printf("๐Ÿš€ Testing synchronous publish (backward compatibility)...\n"); // Call synchronous publish (old API) int result = nostr_relay_pool_publish_async(pool, test_relays, 1, event, NULL, NULL); printf("๐Ÿ“Š Synchronous publish result: %d successful publishes\n", result); // Cleanup cJSON_Delete(event); nostr_relay_pool_destroy(pool); printf("\nโœ… Backward compatibility test completed!\n"); printf(" Expected: 0 successful publishes (connection failure)\n"); printf(" Actual: %d successful publishes\n", result); printf(" Result: %s\n", result == 0 ? "PASS" : "FAIL"); return result == 0 ? 0 : 1; }