diff --git a/.github/workflows/e2e-test.yaml b/.github/workflows/e2e-test.yaml
new file mode 100644
index 0000000..06022c5
--- /dev/null
+++ b/.github/workflows/e2e-test.yaml
@@ -0,0 +1,52 @@
+name: End-to-End Test
+
+on:
+ push:
+ branches: [main]
+ pull_request:
+ branches: [main]
+
+jobs:
+ e2e-test:
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v2
+
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v1
+
+ - name: Copy .env.docker to .env
+ run: cp .env.docker .env
+
+ - name: Install Docker Compose
+ run: |
+ sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
+ sudo chmod +x /usr/local/bin/docker-compose
+
+ - name: Build and start services
+ run: docker-compose up -d --build
+
+ - name: Wait for services to be ready
+ run: |
+ timeout 60s bash -c 'until curl -s http://localhost:8080 > /dev/null; do sleep 1; done'
+ sleep 10 # Additional wait time for other services to initialize
+
+ - name: Run end-to-end test
+ run: |
+ docker-compose exec -T user-cli /bin/sh -c "cargo test --test e2e_test -- --nocapture"
+
+ - name: Collect logs
+ if: always()
+ run: docker-compose logs > docker-compose-logs.txt
+
+ - name: Upload logs
+ if: always()
+ uses: actions/upload-artifact@v2
+ with:
+ name: docker-compose-logs
+ path: docker-compose-logs.txt
+
+ - name: Stop services
+ if: always()
+ run: docker-compose down
diff --git a/README.md b/README.md
index 93e9e32..8fdc845 100644
--- a/README.md
+++ b/README.md
@@ -2,9 +2,11 @@
Askeladd
Censorship-resistant global proving network.
-
+
-
+
+
+
## About
diff --git a/tests/e2e_test.rs b/tests/e2e_test.rs
new file mode 100644
index 0000000..16fba8c
--- /dev/null
+++ b/tests/e2e_test.rs
@@ -0,0 +1,46 @@
+use askeladd::config::Settings;
+use askeladd::types::{FibonnacciProvingRequest, FibonnacciProvingResponse};
+use nostr_sdk::prelude::*;
+use std::time::Duration;
+
+#[tokio::test]
+async fn test_e2e_flow() {
+ let settings = Settings::new().expect("Failed to load settings");
+
+ let secret_key = SecretKey::from_bech32(&settings.user_bech32_sk).unwrap();
+ let keys = Keys::new(secret_key);
+
+ let client = Client::new(&keys);
+ client.add_relay("ws://nostr-relay:8080").await.unwrap();
+ client.connect().await;
+ // Create and publish a proving request
+ let request = FibonnacciProvingRequest {
+ request_id: "test-request-id".to_string(),
+ log_size: 5,
+ claim: 443693538,
+ };
+ let request_json = serde_json::to_string(&request).unwrap();
+ let event_id = client.publish_text_note(request_json, &[]).await.unwrap();
+
+ // Wait for the response
+ let filter = Filter::new()
+ .kind(Kind::TextNote)
+ .custom_tag("e", vec![event_id.to_string()]);
+ let mut notifications = client.notifications();
+
+ let mut response_received = false;
+ for _ in 0..30 { // Wait up to 30 seconds
+ if let Ok(notification) = tokio::time::timeout(Duration::from_secs(1), notifications.next()).await {
+ if let Some(RelayPoolNotification::Event { event, .. }) = notification {
+ if let Ok(response) = serde_json::from_str::(&event.content) {
+ assert_eq!(response.request_id, request.request_id);
+ assert!(response.proof.is_some());
+ response_received = true;
+ break;
+ }
+ }
+ }
+ }
+
+ assert!(response_received, "Did not receive a response within the timeout period");
+}
\ No newline at end of file