From 0e436243ca7e3679b7da87bfda6e6d9824b13a72 Mon Sep 17 00:00:00 2001 From: wasm-forge <122647775+wasm-forge@users.noreply.github.com> Date: Sun, 19 May 2024 16:51:30 +0200 Subject: [PATCH] add test projects --- src/tests/demo_test/.gitignore | 25 + src/tests/demo_test/Cargo.lock | 621 ++++++++++++++++++ src/tests/demo_test/Cargo.toml | 5 + src/tests/demo_test/README.md | 61 ++ .../src/demo_test_backend/Cargo.toml | 14 + .../demo_test_backend/demo_test_backend.did | 3 + .../src/demo_test_backend/src/lib.rs | 4 + src/tests/demo_test_upgraded/.gitignore | 25 + src/tests/demo_test_upgraded/Cargo.toml | 5 + src/tests/demo_test_upgraded/README.md | 61 ++ .../src/demo_test_upgraded_backend/Cargo.toml | 14 + .../demo_test_upgraded_backend.did | 3 + .../src/demo_test_upgraded_backend/src/lib.rs | 4 + 13 files changed, 845 insertions(+) create mode 100644 src/tests/demo_test/.gitignore create mode 100644 src/tests/demo_test/Cargo.lock create mode 100644 src/tests/demo_test/Cargo.toml create mode 100644 src/tests/demo_test/README.md create mode 100644 src/tests/demo_test/src/demo_test_backend/Cargo.toml create mode 100644 src/tests/demo_test/src/demo_test_backend/demo_test_backend.did create mode 100644 src/tests/demo_test/src/demo_test_backend/src/lib.rs create mode 100644 src/tests/demo_test_upgraded/.gitignore create mode 100644 src/tests/demo_test_upgraded/Cargo.toml create mode 100644 src/tests/demo_test_upgraded/README.md create mode 100644 src/tests/demo_test_upgraded/src/demo_test_upgraded_backend/Cargo.toml create mode 100644 src/tests/demo_test_upgraded/src/demo_test_upgraded_backend/demo_test_upgraded_backend.did create mode 100644 src/tests/demo_test_upgraded/src/demo_test_upgraded_backend/src/lib.rs diff --git a/src/tests/demo_test/.gitignore b/src/tests/demo_test/.gitignore new file mode 100644 index 0000000..49c89a1 --- /dev/null +++ b/src/tests/demo_test/.gitignore @@ -0,0 +1,25 @@ +# Various IDEs and Editors +.vscode/ +.idea/ +**/*~ + +# Mac OSX temporary files +.DS_Store +**/.DS_Store + +# dfx temporary files +.dfx/ + +# generated files +**/declarations/ + +# rust +target/ + +# frontend code +node_modules/ +dist/ +.svelte-kit/ + +# environment variables +.env diff --git a/src/tests/demo_test/Cargo.lock b/src/tests/demo_test/Cargo.lock new file mode 100644 index 0000000..4cdad44 --- /dev/null +++ b/src/tests/demo_test/Cargo.lock @@ -0,0 +1,621 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "anyhow" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" + +[[package]] +name = "arrayvec" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" + +[[package]] +name = "autocfg" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" + +[[package]] +name = "binread" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16598dfc8e6578e9b597d9910ba2e73618385dc9f4b1d43dd92c349d6be6418f" +dependencies = [ + "binread_derive", + "lazy_static", + "rustversion", +] + +[[package]] +name = "binread_derive" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d9672209df1714ee804b1f4d4f68c8eb2a90b1f7a07acf472f88ce198ef1fed" +dependencies = [ + "either", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "candid" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd5902d37352dffd8bd9177a2daa6444ce3cd0279c91763fb0171c053aa04335" +dependencies = [ + "anyhow", + "binread", + "byteorder", + "candid_derive", + "hex", + "ic_principal", + "leb128", + "num-bigint", + "num-traits", + "paste", + "pretty", + "serde", + "serde_bytes", + "stacker", + "thiserror", +] + +[[package]] +name = "candid_derive" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3de398570c386726e7a59d9887b68763c481477f9a043fb998a2e09d428df1a9" +dependencies = [ + "lazy_static", + "proc-macro2", + "quote", + "syn 2.0.64", +] + +[[package]] +name = "cc" +version = "1.0.98" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41c270e7540d725e65ac7f1b212ac8ce349719624d7bcff99f8e2e488e8cf03f" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "cpufeatures" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +dependencies = [ + "libc", +] + +[[package]] +name = "crc32fast" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3855a8a784b474f333699ef2bbca9db2c4a1f6d9088a90a2d25b1eb53111eaa" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "data-encoding" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2" + +[[package]] +name = "demo_test_backend" +version = "0.1.0" +dependencies = [ + "candid", + "ic-cdk", + "ic-cdk-timers", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + +[[package]] +name = "either" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" + +[[package]] +name = "futures" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" + +[[package]] +name = "futures-executor" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" + +[[package]] +name = "futures-macro" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.64", +] + +[[package]] +name = "futures-sink" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" + +[[package]] +name = "futures-task" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" + +[[package]] +name = "futures-util" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "ic-cdk" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8859bc2b863a77750acf199e1fb7e3fc403e1b475855ba13f59cb4e4036d238" +dependencies = [ + "candid", + "ic-cdk-macros", + "ic0", + "serde", + "serde_bytes", +] + +[[package]] +name = "ic-cdk-macros" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a45800053d80a6df839a71aaea5797e723188c0b992618208ca3b941350c7355" +dependencies = [ + "candid", + "proc-macro2", + "quote", + "serde", + "serde_tokenstream", + "syn 1.0.109", +] + +[[package]] +name = "ic-cdk-timers" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "054727a3a1c486528b96349817d54290ff70df6addf417def456ea708a16f7fb" +dependencies = [ + "futures", + "ic-cdk", + "ic0", + "serde", + "serde_bytes", + "slotmap", +] + +[[package]] +name = "ic0" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a54b5297861c651551676e8c43df805dad175cc33bc97dbd992edbbb85dcbcdf" + +[[package]] +name = "ic_principal" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1762deb6f7c8d8c2bdee4b6c5a47b60195b74e9b5280faa5ba29692f8e17429c" +dependencies = [ + "crc32fast", + "data-encoding", + "serde", + "sha2", + "thiserror", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "leb128" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" + +[[package]] +name = "libc" +version = "0.2.155" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" + +[[package]] +name = "memchr" +version = "2.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" + +[[package]] +name = "num-bigint" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" +dependencies = [ + "num-integer", + "num-traits", + "serde", +] + +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "pin-project-lite" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pretty" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b55c4d17d994b637e2f4daf6e5dc5d660d209d5642377d675d7a1c3ab69fa579" +dependencies = [ + "arrayvec", + "typed-arena", + "unicode-width", +] + +[[package]] +name = "proc-macro2" +version = "1.0.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "psm" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5787f7cda34e3033a72192c018bc5883100330f362ef279a8cbccfce8bb4e874" +dependencies = [ + "cc", +] + +[[package]] +name = "quote" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rustversion" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" + +[[package]] +name = "serde" +version = "1.0.202" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "226b61a0d411b2ba5ff6d7f73a476ac4f8bb900373459cd00fab8512828ba395" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_bytes" +version = "0.11.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b8497c313fd43ab992087548117643f6fcd935cbf36f176ffda0aacf9591734" +dependencies = [ + "serde", +] + +[[package]] +name = "serde_derive" +version = "1.0.202" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6048858004bcff69094cd972ed40a32500f153bd3be9f716b2eed2e8217c4838" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.64", +] + +[[package]] +name = "serde_tokenstream" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "797ba1d80299b264f3aac68ab5d12e5825a561749db4df7cd7c8083900c5d4e9" +dependencies = [ + "proc-macro2", + "serde", + "syn 1.0.109", +] + +[[package]] +name = "sha2" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + +[[package]] +name = "slotmap" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbff4acf519f630b3a3ddcfaea6c06b42174d9a44bc70c620e9ed1649d58b82a" +dependencies = [ + "version_check", +] + +[[package]] +name = "stacker" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c886bd4480155fd3ef527d45e9ac8dd7118a898a46530b7b94c3e21866259fce" +dependencies = [ + "cc", + "cfg-if", + "libc", + "psm", + "winapi", +] + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ad3dee41f36859875573074334c200d1add8e4a87bb37113ebd31d926b7b11f" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "thiserror" +version = "1.0.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.64", +] + +[[package]] +name = "typed-arena" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6af6ae20167a9ece4bcb41af5b80f8a1f1df981f6391189ce00fd257af04126a" + +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "unicode-width" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68f5e5f3158ecfd4b8ff6fe086db7c8467a2dfdac97fe420f2b7c4aa97af66d6" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/src/tests/demo_test/Cargo.toml b/src/tests/demo_test/Cargo.toml new file mode 100644 index 0000000..767f48c --- /dev/null +++ b/src/tests/demo_test/Cargo.toml @@ -0,0 +1,5 @@ +[workspace] +members = [ + "src/demo_test_backend" +] +resolver = "2" diff --git a/src/tests/demo_test/README.md b/src/tests/demo_test/README.md new file mode 100644 index 0000000..3ebfe41 --- /dev/null +++ b/src/tests/demo_test/README.md @@ -0,0 +1,61 @@ +# demo_test + +Welcome to your new demo_test project and to the internet computer development community. By default, creating a new project adds this README and some template files to your project directory. You can edit these template files to customize your project and to include your own code to speed up the development cycle. + +To get started, you might want to explore the project directory structure and the default configuration file. Working with this project in your development environment will not affect any production deployment or identity tokens. + +To learn more before you start working with demo_test, see the following documentation available online: + +- [Quick Start](https://internetcomputer.org/docs/current/developer-docs/setup/deploy-locally) +- [SDK Developer Tools](https://internetcomputer.org/docs/current/developer-docs/setup/install) +- [Rust Canister Development Guide](https://internetcomputer.org/docs/current/developer-docs/backend/rust/) +- [ic-cdk](https://docs.rs/ic-cdk) +- [ic-cdk-macros](https://docs.rs/ic-cdk-macros) +- [Candid Introduction](https://internetcomputer.org/docs/current/developer-docs/backend/candid/) + +If you want to start working on your project right away, you might want to try the following commands: + +```bash +cd demo_test/ +dfx help +dfx canister --help +``` + +## Running the project locally + +If you want to test your project locally, you can use the following commands: + +```bash +# Starts the replica, running in the background +dfx start --background + +# Deploys your canisters to the replica and generates your candid interface +dfx deploy +``` + +Once the job completes, your application will be available at `http://localhost:4943?canisterId={asset_canister_id}`. + +If you have made changes to your backend canister, you can generate a new candid interface with + +```bash +npm run generate +``` + +at any time. This is recommended before starting the frontend development server, and will be run automatically any time you run `dfx deploy`. + +If you are making frontend changes, you can start a development server with + +```bash +npm start +``` + +Which will start a server at `http://localhost:8080`, proxying API requests to the replica at port 4943. + +### Note on frontend environment variables + +If you are hosting frontend code somewhere without using DFX, you may need to make one of the following adjustments to ensure your project does not fetch the root key in production: + +- set`DFX_NETWORK` to `ic` if you are using Webpack +- use your own preferred method to replace `process.env.DFX_NETWORK` in the autogenerated declarations + - Setting `canisters -> {asset_canister_id} -> declarations -> env_override to a string` in `dfx.json` will replace `process.env.DFX_NETWORK` with the string in the autogenerated declarations +- Write your own `createActor` constructor diff --git a/src/tests/demo_test/src/demo_test_backend/Cargo.toml b/src/tests/demo_test/src/demo_test_backend/Cargo.toml new file mode 100644 index 0000000..0761a85 --- /dev/null +++ b/src/tests/demo_test/src/demo_test_backend/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "demo_test_backend" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[lib] +crate-type = ["cdylib"] + +[dependencies] +candid = "0.10" +ic-cdk = "0.13" +ic-cdk-timers = "0.7" # Feel free to remove this dependency if you don't need timers diff --git a/src/tests/demo_test/src/demo_test_backend/demo_test_backend.did b/src/tests/demo_test/src/demo_test_backend/demo_test_backend.did new file mode 100644 index 0000000..aa419a2 --- /dev/null +++ b/src/tests/demo_test/src/demo_test_backend/demo_test_backend.did @@ -0,0 +1,3 @@ +service : { + "greet": (text) -> (text) query; +} diff --git a/src/tests/demo_test/src/demo_test_backend/src/lib.rs b/src/tests/demo_test/src/demo_test_backend/src/lib.rs new file mode 100644 index 0000000..9c04bd0 --- /dev/null +++ b/src/tests/demo_test/src/demo_test_backend/src/lib.rs @@ -0,0 +1,4 @@ +#[ic_cdk::query] +fn greet(name: String) -> String { + format!("Hello, {}!", name) +} diff --git a/src/tests/demo_test_upgraded/.gitignore b/src/tests/demo_test_upgraded/.gitignore new file mode 100644 index 0000000..49c89a1 --- /dev/null +++ b/src/tests/demo_test_upgraded/.gitignore @@ -0,0 +1,25 @@ +# Various IDEs and Editors +.vscode/ +.idea/ +**/*~ + +# Mac OSX temporary files +.DS_Store +**/.DS_Store + +# dfx temporary files +.dfx/ + +# generated files +**/declarations/ + +# rust +target/ + +# frontend code +node_modules/ +dist/ +.svelte-kit/ + +# environment variables +.env diff --git a/src/tests/demo_test_upgraded/Cargo.toml b/src/tests/demo_test_upgraded/Cargo.toml new file mode 100644 index 0000000..4778252 --- /dev/null +++ b/src/tests/demo_test_upgraded/Cargo.toml @@ -0,0 +1,5 @@ +[workspace] +members = [ + "src/demo_test_upgraded_backend" +] +resolver = "2" diff --git a/src/tests/demo_test_upgraded/README.md b/src/tests/demo_test_upgraded/README.md new file mode 100644 index 0000000..1371df9 --- /dev/null +++ b/src/tests/demo_test_upgraded/README.md @@ -0,0 +1,61 @@ +# demo_test_upgraded + +Welcome to your new demo_test_upgraded project and to the internet computer development community. By default, creating a new project adds this README and some template files to your project directory. You can edit these template files to customize your project and to include your own code to speed up the development cycle. + +To get started, you might want to explore the project directory structure and the default configuration file. Working with this project in your development environment will not affect any production deployment or identity tokens. + +To learn more before you start working with demo_test_upgraded, see the following documentation available online: + +- [Quick Start](https://internetcomputer.org/docs/current/developer-docs/setup/deploy-locally) +- [SDK Developer Tools](https://internetcomputer.org/docs/current/developer-docs/setup/install) +- [Rust Canister Development Guide](https://internetcomputer.org/docs/current/developer-docs/backend/rust/) +- [ic-cdk](https://docs.rs/ic-cdk) +- [ic-cdk-macros](https://docs.rs/ic-cdk-macros) +- [Candid Introduction](https://internetcomputer.org/docs/current/developer-docs/backend/candid/) + +If you want to start working on your project right away, you might want to try the following commands: + +```bash +cd demo_test_upgraded/ +dfx help +dfx canister --help +``` + +## Running the project locally + +If you want to test your project locally, you can use the following commands: + +```bash +# Starts the replica, running in the background +dfx start --background + +# Deploys your canisters to the replica and generates your candid interface +dfx deploy +``` + +Once the job completes, your application will be available at `http://localhost:4943?canisterId={asset_canister_id}`. + +If you have made changes to your backend canister, you can generate a new candid interface with + +```bash +npm run generate +``` + +at any time. This is recommended before starting the frontend development server, and will be run automatically any time you run `dfx deploy`. + +If you are making frontend changes, you can start a development server with + +```bash +npm start +``` + +Which will start a server at `http://localhost:8080`, proxying API requests to the replica at port 4943. + +### Note on frontend environment variables + +If you are hosting frontend code somewhere without using DFX, you may need to make one of the following adjustments to ensure your project does not fetch the root key in production: + +- set`DFX_NETWORK` to `ic` if you are using Webpack +- use your own preferred method to replace `process.env.DFX_NETWORK` in the autogenerated declarations + - Setting `canisters -> {asset_canister_id} -> declarations -> env_override to a string` in `dfx.json` will replace `process.env.DFX_NETWORK` with the string in the autogenerated declarations +- Write your own `createActor` constructor diff --git a/src/tests/demo_test_upgraded/src/demo_test_upgraded_backend/Cargo.toml b/src/tests/demo_test_upgraded/src/demo_test_upgraded_backend/Cargo.toml new file mode 100644 index 0000000..9e35a0c --- /dev/null +++ b/src/tests/demo_test_upgraded/src/demo_test_upgraded_backend/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "demo_test_upgraded_backend" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[lib] +crate-type = ["cdylib"] + +[dependencies] +candid = "0.10" +ic-cdk = "0.13" +ic-cdk-timers = "0.7" # Feel free to remove this dependency if you don't need timers diff --git a/src/tests/demo_test_upgraded/src/demo_test_upgraded_backend/demo_test_upgraded_backend.did b/src/tests/demo_test_upgraded/src/demo_test_upgraded_backend/demo_test_upgraded_backend.did new file mode 100644 index 0000000..aa419a2 --- /dev/null +++ b/src/tests/demo_test_upgraded/src/demo_test_upgraded_backend/demo_test_upgraded_backend.did @@ -0,0 +1,3 @@ +service : { + "greet": (text) -> (text) query; +} diff --git a/src/tests/demo_test_upgraded/src/demo_test_upgraded_backend/src/lib.rs b/src/tests/demo_test_upgraded/src/demo_test_upgraded_backend/src/lib.rs new file mode 100644 index 0000000..8457f5a --- /dev/null +++ b/src/tests/demo_test_upgraded/src/demo_test_upgraded_backend/src/lib.rs @@ -0,0 +1,4 @@ +#[ic_cdk::query] +fn greet(name: String) -> String { + format!("Greetings, {}!", name) +}