From da1c003f3283f1978f7f23e1fc35b9be688a7e90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillem=20C=C3=B3rdoba?= Date: Thu, 28 Dec 2023 17:10:53 +0100 Subject: [PATCH] Happs and tests --- Cargo.lock | 381 +++++++++++++++++- Cargo.toml | 6 +- package.json | 4 +- .../dnas/notifications/workdir/dna.yaml | 7 +- .../workdir/dna.yaml | 4 +- tests/Cargo.toml | 4 +- tests/tests/complex_flow.rs | 88 ++-- 7 files changed, 450 insertions(+), 44 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7076658..ce85337 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -33,6 +33,17 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234" +[[package]] +name = "aes" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac1f845298e95f983ff1944b728ae08b8cebab80d684f0a832ed0fc74dfa27e2" +dependencies = [ + "cfg-if 1.0.0", + "cipher", + "cpufeatures", +] + [[package]] name = "ahash" version = "0.3.8" @@ -503,6 +514,12 @@ version = "0.21.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" +[[package]] +name = "base64ct" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" + [[package]] name = "bimap" version = "0.6.3" @@ -683,6 +700,27 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" +[[package]] +name = "bzip2" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdb116a6ef3f6c3698828873ad02c3014b3c85cadb88496095628e3ef1e347f8" +dependencies = [ + "bzip2-sys", + "libc", +] + +[[package]] +name = "bzip2-sys" +version = "0.1.11+1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "736a955f3fa7875102d57c82b8cac37ec45224a07fd32d58f9f7a186b6cd4cdc" +dependencies = [ + "cc", + "libc", + "pkg-config", +] + [[package]] name = "c_linked_list" version = "1.1.1" @@ -727,6 +765,7 @@ version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" dependencies = [ + "jobserver", "libc", ] @@ -767,6 +806,16 @@ dependencies = [ "windows-targets 0.48.5", ] +[[package]] +name = "cipher" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" +dependencies = [ + "crypto-common", + "inout", +] + [[package]] name = "clap" version = "2.34.0" @@ -819,6 +868,7 @@ dependencies = [ "anstyle", "clap_lex 0.6.0", "strsim 0.10.0", + "terminal_size", ] [[package]] @@ -1387,6 +1437,7 @@ checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer 0.10.4", "crypto-common", + "subtle", ] [[package]] @@ -2348,6 +2399,21 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "hex-literal" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest 0.10.7", +] + [[package]] name = "holo_hash" version = "0.2.4" @@ -2374,9 +2440,9 @@ dependencies = [ [[package]] name = "holochain" -version = "0.2.2" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7557f2e6d4e64912264b16befa6144da01c2484459492d8a71560d20024178d8" +checksum = "acdcb7d66c3a2bc1cfaaaebe86b4991f731278d16b86aac31cf3e46ca4c17e89" dependencies = [ "anyhow", "arbitrary", @@ -2402,6 +2468,7 @@ dependencies = [ "holochain_cascade", "holochain_conductor_api", "holochain_keystore", + "holochain_metrics", "holochain_p2p", "holochain_serialized_bytes", "holochain_sqlite", @@ -2430,6 +2497,7 @@ dependencies = [ "num_cpus", "once_cell", "one_err", + "opentelemetry_api", "parking_lot 0.10.2", "predicates 1.0.8", "rand 0.8.5", @@ -2455,6 +2523,8 @@ dependencies = [ "tracing", "tracing-futures", "tracing-subscriber", + "tx5-go-pion-turn", + "tx5-signal-srv", "unwrap_to", "url 2.5.0", "url2", @@ -2465,9 +2535,9 @@ dependencies = [ [[package]] name = "holochain_cascade" -version = "0.2.2" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8611a6406313dd46692c97cbf0025dc4ad77a27ac4da622441dec69408054a0" +checksum = "898139f876ea83b4ed8e9996234125a95c2c7866aa7930922cc53694573e6ae9" dependencies = [ "async-trait", "derive_more", @@ -2489,6 +2559,8 @@ dependencies = [ "holochain_zome_types", "kitsune_p2p", "mockall", + "once_cell", + "opentelemetry_api", "serde", "serde_derive", "thiserror", @@ -2568,6 +2640,18 @@ dependencies = [ "tracing", ] +[[package]] +name = "holochain_metrics" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bf1a9e96ab255be9c88aa56cb93088b074799a832c1943b08db051054b34363" +dependencies = [ + "influxive", + "opentelemetry_api", + "reqwest", + "tracing", +] + [[package]] name = "holochain_p2p" version = "0.2.4" @@ -2720,9 +2804,9 @@ dependencies = [ [[package]] name = "holochain_test_wasm_common" -version = "0.2.2" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a1a19d8dca8938fcb55e4ae43bb57887f2887155677e7906a1e0bc3160a2124" +checksum = "dc14ddf8c521aa78c57d2e56e9bba16b334d910cfb9c1741504c67d890958be4" dependencies = [ "hdk", "serde", @@ -3043,6 +3127,19 @@ dependencies = [ "want", ] +[[package]] +name = "hyper-rustls" +version = "0.23.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1788965e61b367cd03a62950836d5cd41560c3577d90e40e0819373194d1661c" +dependencies = [ + "http", + "hyper", + "rustls", + "tokio", + "tokio-rustls", +] + [[package]] name = "hyper-tls" version = "0.5.0" @@ -3126,6 +3223,16 @@ dependencies = [ "windows-sys 0.42.0", ] +[[package]] +name = "if-addrs" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cabb0019d51a643781ff15c9c8a3e5dedc365c47211270f4e8f82812fedd8f0a" +dependencies = [ + "libc", + "windows-sys 0.48.0", +] + [[package]] name = "if_chain" version = "1.0.2" @@ -3176,6 +3283,88 @@ dependencies = [ "str_stack", ] +[[package]] +name = "influxdb" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77763a6985cbf3f3251fd0725511b6eb81967bfb50763e7a88097ff8e8504fb0" +dependencies = [ + "chrono", + "futures-util", + "http", + "lazy_static", + "regex", + "reqwest", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "influxive" +version = "0.0.2-alpha.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2e33972c836e620ade20e7c0c66062c60a90b222ed46f5f872f1a4721967191" +dependencies = [ + "influxive-child-svc", + "influxive-otel", + "influxive-writer", +] + +[[package]] +name = "influxive-child-svc" +version = "0.0.2-alpha.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0923b25ac29f6e2ac600b0d3762792c4cb86438c3f2c7daa1f6e65e66f7f0d4d" +dependencies = [ + "hex-literal", + "influxive-core", + "influxive-downloader", + "influxive-writer", + "tempfile", + "tokio", + "tracing", +] + +[[package]] +name = "influxive-core" +version = "0.0.2-alpha.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5db78961ebb97b6d16ba61a65b38978a67cf7efaa91903c500b4771d1920d00" + +[[package]] +name = "influxive-downloader" +version = "0.0.2-alpha.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "264581af3b49d108e76382e301d4228f89a3995e373363b877bb42b1312ebba3" +dependencies = [ + "base64 0.21.5", + "digest 0.10.7", + "dirs", + "flate2", + "futures", + "hex", + "hex-literal", + "influxive-core", + "reqwest", + "sha2", + "tar", + "tempfile", + "tokio", + "zip", +] + +[[package]] +name = "influxive-otel" +version = "0.0.2-alpha.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "882f4ff61b099d34855841a6ea4d1890a1bd2aad2d07d8aaa63c99059d0f295c" +dependencies = [ + "influxive-core", + "opentelemetry_api", + "tokio", +] + [[package]] name = "influxive-otel-atomic-obs" version = "0.0.2-alpha.1" @@ -3185,6 +3374,27 @@ dependencies = [ "opentelemetry_api", ] +[[package]] +name = "influxive-writer" +version = "0.0.2-alpha.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89db32ac1865b814d5f4109635226c1d89189852d88f9ae704c0b51d6d2a8f25" +dependencies = [ + "influxdb", + "influxive-core", + "tokio", + "tracing", +] + +[[package]] +name = "inout" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" +dependencies = [ + "generic-array", +] + [[package]] name = "input_buffer" version = "0.4.0" @@ -3287,6 +3497,15 @@ version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" +[[package]] +name = "jobserver" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c37f63953c4c63420ed5fd3d6d398c719489b9f872b9fa683262f8edd363c7d" +dependencies = [ + "libc", +] + [[package]] name = "js-sys" version = "0.3.66" @@ -4617,12 +4836,35 @@ dependencies = [ "windows-targets 0.48.5", ] +[[package]] +name = "password-hash" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7676374caaee8a325c9e7a2ae557f216c5563a171d6997b0ef8a65af35147700" +dependencies = [ + "base64ct", + "rand_core 0.6.4", + "subtle", +] + [[package]] name = "paste" version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" +[[package]] +name = "pbkdf2" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" +dependencies = [ + "digest 0.10.7", + "hmac", + "password-hash", + "sha2", +] + [[package]] name = "pem" version = "1.1.1" @@ -4866,6 +5108,27 @@ dependencies = [ "serde", ] +[[package]] +name = "prometheus" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "449811d15fbdf5ceb5c1144416066429cf82316e2ec8ce0c1f6f8a02e7bbcf8c" +dependencies = [ + "cfg-if 1.0.0", + "fnv", + "lazy_static", + "memchr", + "parking_lot 0.12.1", + "protobuf", + "thiserror", +] + +[[package]] +name = "protobuf" +version = "2.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "106dd99e98437432fed6519dedecfade6a06a73bb7b2a1e019fdd2bee5778d94" + [[package]] name = "ptr_meta" version = "0.1.4" @@ -5395,6 +5658,7 @@ dependencies = [ "http", "http-body", "hyper", + "hyper-rustls", "hyper-tls", "ipnet", "js-sys", @@ -5404,16 +5668,22 @@ dependencies = [ "once_cell", "percent-encoding 2.3.1", "pin-project-lite", + "rustls", + "rustls-pemfile 1.0.4", "serde", "serde_json", "serde_urlencoded", "tokio", "tokio-native-tls", + "tokio-rustls", + "tokio-util", "tower-service", "url 2.5.0", "wasm-bindgen", "wasm-bindgen-futures", + "wasm-streams", "web-sys", + "webpki-roots 0.22.6", "winreg", ] @@ -6347,6 +6617,16 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "terminal_size" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21bebf2b7c9e0a515f6e0f8c51dc0f8e4696391e6f1ff30379559f8365fb0df7" +dependencies = [ + "rustix 0.38.28", + "windows-sys 0.48.0", +] + [[package]] name = "termtree" version = "0.4.1" @@ -6968,6 +7248,24 @@ dependencies = [ "zip", ] +[[package]] +name = "tx5-go-pion-turn" +version = "0.0.4-alpha" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a2ee4982985842265529632f96751020ecd109e6e249662037eef2cdf2a881" +dependencies = [ + "base64 0.13.1", + "dirs", + "dunce", + "if-addrs 0.10.2", + "once_cell", + "sha2", + "tokio", + "tracing", + "tx5-core", + "zip", +] + [[package]] name = "tx5-signal" version = "0.0.4-alpha" @@ -6997,6 +7295,27 @@ dependencies = [ "webpki-roots 0.23.1", ] +[[package]] +name = "tx5-signal-srv" +version = "0.0.4-alpha" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1041cf202eb8789aaa4fc70acdae424ea3ad361e4031aa14dc30fcf0a246f69" +dependencies = [ + "clap 4.4.11", + "dirs", + "futures", + "if-addrs 0.10.2", + "once_cell", + "prometheus", + "rand 0.8.5", + "sodoken", + "tokio", + "tracing", + "tracing-subscriber", + "tx5-core", + "warp", +] + [[package]] name = "typenum" version = "1.17.0" @@ -7361,6 +7680,19 @@ dependencies = [ "leb128", ] +[[package]] +name = "wasm-streams" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bbae3363c08332cadccd13b67db371814cd214c2524020932f0804b8cf7c078" +dependencies = [ + "futures-util", + "js-sys", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + [[package]] name = "wasmer" version = "2.3.0" @@ -8044,8 +8376,45 @@ version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "760394e246e4c28189f19d488c058bf16f564016aefac5d32bb1f3b51d5e9261" dependencies = [ + "aes", "byteorder", + "bzip2", + "constant_time_eq 0.1.5", "crc32fast", "crossbeam-utils", "flate2", + "hmac", + "pbkdf2", + "sha1", + "time", + "zstd", +] + +[[package]] +name = "zstd" +version = "0.11.2+zstd.1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4" +dependencies = [ + "zstd-safe", +] + +[[package]] +name = "zstd-safe" +version = "5.0.2+zstd.1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db" +dependencies = [ + "libc", + "zstd-sys", +] + +[[package]] +name = "zstd-sys" +version = "2.0.9+zstd.1.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e16efa8a874a0481a574084d34cc26fdb3b99627480f785888deb6386506656" +dependencies = [ + "cc", + "pkg-config", ] diff --git a/Cargo.toml b/Cargo.toml index 0020de2..fe85bbf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,6 +19,7 @@ resolver = "2" [workspace.dependencies] hdi = "=0.3.4" hdk = "=0.2.4" +holochain = "=0.2.4" serde = "=1.0.166" [workspace.dependencies.hc_zome_notifications_coordinator] @@ -29,8 +30,3 @@ path = "notifications/zomes/integrity/notifications" [workspace.dependencies.hc_zome_notifications_types] path = "notifications/crates/hc_zome_notifications_types" - -[workspace.dependencies.holochain] -default-features = false -features = ["test_utils"] -version = "0.2.2" diff --git a/package.json b/package.json index dd8a2bb..adf4d26 100644 --- a/package.json +++ b/package.json @@ -5,9 +5,9 @@ "scripts": { "start": "AGENTS=2 npm run network", "network": "hc s clean && npm run build:happ && UI_PORT=8888 concurrently -k \"npm start -w @holochain-open-dev/notifications-provider\" \"npm run launch:happ\" \"holochain-playground\"", - "test": "npm run build:happ && cargo nextest run -j 1 && npm test -w tests", + "test": "npm run build:happ && hc app pack tests/fixture/workdir --recursive && cargo nextest run -j 1", "launch:happ": "echo \"pass\" | RUST_LOG=warn hc launch --piped -n $AGENTS workdir/notifications_provider.happ --ui-port $UI_PORT network -b https://bootstrap.holo.host webrtc wss://signal.holo.host", - "build:happ": "npm run build:zomes && hc app pack fcm_push_notifications/apps/fcm_push_notifications_client/workdir --recursive && hc app pack fcm_push_notifications/apps/fcm_push_notifications_client/workdir --recursive && hc app pack tests/fixture/workdir --recursive", + "build:happ": "npm run build:zomes && hc app pack providers/fcm/apps/notifications_provider_fcm_recipient/workdir --recursive && hc app pack providers/fcm/apps/notifications_provider_fcm/workdir --recursive", "build:zomes": "CARGO_TARGET_DIR=target cargo build --workspace --release --target wasm32-unknown-unknown --exclude tests" }, "devDependencies": { diff --git a/providers/fcm/apps/notifications_provider_fcm/dnas/notifications/workdir/dna.yaml b/providers/fcm/apps/notifications_provider_fcm/dnas/notifications/workdir/dna.yaml index 0f20a2d..bdfaf52 100644 --- a/providers/fcm/apps/notifications_provider_fcm/dnas/notifications/workdir/dna.yaml +++ b/providers/fcm/apps/notifications_provider_fcm/dnas/notifications/workdir/dna.yaml @@ -8,18 +8,17 @@ integrity: zomes: - name: notifications_integrity hash: ~ - bundled: "../../../target/wasm32-unknown-unknown/release/hc_zome_notifications_integrity.wasm" + bundled: "../../../../../../../target/wasm32-unknown-unknown/release/hc_zome_notifications_integrity.wasm" dependencies: ~ coordinator: zomes: - name: notifications hash: ~ - bundled: "../../../target/wasm32-unknown-unknown/release/hc_zome_notifications_coordinator.wasm" + bundled: "../../../../../../../target/wasm32-unknown-unknown/release/hc_zome_notifications_coordinator.wasm" dependencies: - name: notifications_integrity - zomes: - name: notifications_provider_fcm_bridge hash: ~ - bundled: "../../../target/wasm32-unknown-unknown/release/hc_zome_notifications_provider_fcm_bridge.wasm" + bundled: "../../../../../../../target/wasm32-unknown-unknown/release/hc_zome_notifications_provider_fcm_bridge.wasm" dependencies: - name: notifications_integrity diff --git a/providers/fcm/apps/notifications_provider_fcm/dnas/notifications_provider_fcm/workdir/dna.yaml b/providers/fcm/apps/notifications_provider_fcm/dnas/notifications_provider_fcm/workdir/dna.yaml index 14fa4dd..a3d782c 100644 --- a/providers/fcm/apps/notifications_provider_fcm/dnas/notifications_provider_fcm/workdir/dna.yaml +++ b/providers/fcm/apps/notifications_provider_fcm/dnas/notifications_provider_fcm/workdir/dna.yaml @@ -8,14 +8,14 @@ integrity: zomes: - name: notifications_provider_fcm_integrity hash: ~ - bundled: "../../../target/wasm32-unknown-unknown/release/hc_zome_notifications_provider_fcm_integrity.wasm" + bundled: "../../../../../../../target/wasm32-unknown-unknown/release/hc_zome_notifications_provider_fcm_integrity.wasm" dependencies: ~ dylib: ~ coordinator: zomes: - name: notifications_provider_fcm hash: ~ - bundled: "../../../target/wasm32-unknown-unknown/release/hc_zome_notifications_provider_coordinator.wasm" + bundled: "../../../../../../../target/wasm32-unknown-unknown/release/hc_zome_notifications_provider_coordinator.wasm" dependencies: - name: notifications_provider_fcm_integrity dylib: ~ diff --git a/tests/Cargo.toml b/tests/Cargo.toml index 30c3dd3..47c619a 100644 --- a/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -12,5 +12,7 @@ serde = { workspace = true } fixt = "*" futures = { version = "0.3.1", default-features = false } hdk = { workspace = true, features = ["encoding", "test_utils"] } -holochain = { workspace = true } +holochain = { workspace = true, default-features = false, features = [ + "test_utils", +] } tokio = { version = "1.3", features = ["full"] } diff --git a/tests/tests/complex_flow.rs b/tests/tests/complex_flow.rs index 521d8a5..c688880 100644 --- a/tests/tests/complex_flow.rs +++ b/tests/tests/complex_flow.rs @@ -5,41 +5,81 @@ use holochain::test_utils::consistency_10s; use holochain::{conductor::config::ConductorConfig, sweettest::*}; #[tokio::test(flavor = "multi_thread")] -async fn create_and_get() { +async fn complex_flow() { // Use prebuilt DNA file - let dna_path = std::env::current_dir() + let notifications_dna = SweetDnaFile::from_bundle( + &std::env::current_dir() + .unwrap() + .join("../notifications/workdir/notifications.dna"), + ) + .await + .unwrap(); + let fixture_app = [notifications_dna]; + + let fcm_notifications_dna= SweetDnaFile::from_bundle(&std::env::current_dir() + .unwrap() + .join("../providers/fcm/apps/notifications_provider_fcm/dnas/notifications/workdir/notifications.dna")).await.unwrap(); + let fcm_provider_dna= SweetDnaFile::from_bundle(&std::env::current_dir() + .unwrap() + .join("../providers/fcm/apps/notifications_provider_fcm/dnas/notifications_provider_fcm/workdir/notifications_provider_fcm.dna")).await.unwrap(); + let fcm_provider_app = [fcm_notifications_dna, fcm_provider_dna]; + + let fcm_recipient_dna= SweetDnaFile::from_bundle(&std::env::current_dir() .unwrap() - .join("../../workdir/profiles-test.dna"); - let dna = SweetDnaFile::from_bundle(&dna_path).await.unwrap(); + .join("../providers/fcm/apps/notifications_provider_fcm_recipient/workdir/notifications_fcm_recipient.dna")).await.unwrap(); + let fcm_recipient_app = [fcm_recipient_dna]; // Set up conductors - let mut conductors = SweetConductorBatch::from_config(2, ConductorConfig::default()).await; - let apps = conductors.setup_app("profiles", &[dna]).await.unwrap(); + let mut conductors = SweetConductorBatch::from_config(3, ConductorConfig::default()).await; + + let fixture_app = conductors[0] + .setup_app("gather", &fixture_app) + .await + .unwrap(); + let provider_app = conductors[1] + .setup_app("fcm_provider", &fcm_provider_app) + .await + .unwrap(); + let recipient_app = conductors[2] + .setup_app("fcm_recipient", &fcm_recipient_app) + .await + .unwrap(); conductors.exchange_peer_info().await; - let ((alice,), (bobbo,)) = apps.into_tuples(); + let conductors = conductors.into_inner(); + + let fixture = &conductors[0]; + let provider = &conductors[1]; + let recipient = &conductors[2]; + + let fixture_alice = fixture_app.into_cells(); + let fixture_zome = fixture_alice[0].zome("notifications"); + + let provider_cells = provider_app.into_cells(); + let provider_notifications_zome = provider_cells[0].zome("notifications"); + let provider_fcm_zome = provider_cells[1].zome("notifications_provider_fcm"); - let alice_zome = alice.zome("profiles"); - let bob_zome = bobbo.zome("profiles"); + let recipient_cells = recipient_app.into_cells(); + let recipient_zome = recipient_cells[0].zome("notifications"); - let alice_pub_key = alice.agent_pubkey(); + /* Setup provider */ - // Try to get my profile before creating one. Should return None. - let record_1: Option = conductors[0] - .call(&alice_zome, "get_agent_profile", alice_pub_key) - .await; - assert_eq!(record_1, None); + // Publish Service Account Key + // Announce as provider - // Create profile for alice and try to get it via get_my_profile() as well as get_agent_profile() - let profile = Profile { - nickname: String::from("alice"), - fields: BTreeMap::new(), - }; + /* Setup recipient */ + // Register FCM token + // Shutdown recipient - let record_1: Record = conductors[0] - .call(&alice_zome, "create_profile", profile) - .await; + /* Send notification */ + // Send notification from fixture notification zome + // FCM provider zome sends signal + // Turn on recipient again - consistency_10s([&alice, &bobbo]).await; + // let record_1: Option = conductors[0] + // .call(&alice_zome, "get_agent_profile", alice_pub_key) + // .await; + // assert_eq!(record_1, None); + // consistency_10s([&alice, &bobbo]).await; }