diff --git a/Cargo.lock b/Cargo.lock index f80df157..2f3fd71b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,5 +1,7 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "addr2line" version = "0.14.1" @@ -495,7 +497,7 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" dependencies = [ - "generic-array 0.12.3", + "generic-array 0.12.4", ] [[package]] @@ -680,11 +682,11 @@ dependencies = [ [[package]] name = "fce-sqlite-connector" -version = "0.1.3" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8165090ee52453a5c14bd42212bfc6516860c4aaa2315fd568c0198b46b52901" +checksum = "c02ba19dff7f195418416b249423384761a964447dc40e7427f448687ac60b56" dependencies = [ - "fluence 0.2.18", + "fluence 0.4.2", ] [[package]] @@ -977,7 +979,7 @@ checksum = "1812c7ab8aedf8d6f2701a43e1243acdbcc2b36ab26e2ad421eb99ac963d96d1" dependencies = [ "futures-core", "futures-task", - "pin-project-lite 0.2.4", + "pin-project-lite 0.2.5", "pin-utils", ] @@ -1008,9 +1010,9 @@ dependencies = [ [[package]] name = "generic-array" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" +checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" dependencies = [ "typenum", ] @@ -1120,9 +1122,9 @@ dependencies = [ [[package]] name = "hex" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "644f9158b2f133fd50f5fb3242878846d9eb792e445c893805ff0e3824006e35" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "http" @@ -1374,9 +1376,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.86" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7282d924be3275cec7f6756ff4121987bc6481325397dde6ba3e7802b1a8b1c" +checksum = "265d751d31d6780a3f956bb5b8022feba2d94eeee5a84ba64f4212eedca42213" [[package]] name = "local_storage" @@ -1637,9 +1639,9 @@ checksum = "a9a7ab5d64814df0fe4a4b5ead45ed6c5f181ee3ff04ba344313a6c80446c5d4" [[package]] name = "once_cell" -version = "1.7.0" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10acf907b94fc1b1a152d08ef97e7759650268cf986bf127f387e602b02c7e5a" +checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3" [[package]] name = "openssl" @@ -1776,15 +1778,15 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.1.11" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c917123afa01924fc84bb20c4c03f004d9c38e5127e3c039bbf7f4b9c76a2f6b" +checksum = "257b64915a082f7811703966789728173279bdebb956b143dbcd23f6f970a777" [[package]] name = "pin-project-lite" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "439697af366c49a6d0a010c56a0d97685bc140ce0d377b13a2ea2aa42d64a827" +checksum = "0cf491442e4b033ed1c722cb9f0df5fcfcf4de682466c46469c36bc47dc5548a" [[package]] name = "pin-utils" @@ -2029,7 +2031,7 @@ dependencies = [ "mime_guess", "native-tls", "percent-encoding", - "pin-project-lite 0.2.4", + "pin-project-lite 0.2.5", "serde", "serde_urlencoded", "tokio", @@ -2465,7 +2467,7 @@ dependencies = [ "lazy_static", "memchr", "mio", - "pin-project-lite 0.1.11", + "pin-project-lite 0.1.12", "slab", "tokio-macros", ] @@ -2501,7 +2503,7 @@ dependencies = [ "futures-core", "futures-sink", "log", - "pin-project-lite 0.1.11", + "pin-project-lite 0.1.12", "tokio", ] @@ -2528,7 +2530,7 @@ checksum = "01ebdc2bb4498ab1ab5f5b73c5803825e60199229ccba0698170e3be0e7f959f" dependencies = [ "cfg-if 1.0.0", "log", - "pin-project-lite 0.2.4", + "pin-project-lite 0.2.5", "tracing-core", ] diff --git a/examples/sqlite/Cargo.toml b/examples/sqlite/Cargo.toml index 6515fa44..99ff645b 100644 --- a/examples/sqlite/Cargo.toml +++ b/examples/sqlite/Cargo.toml @@ -10,5 +10,5 @@ name = "sqlite_test" path = "src/main.rs" [dependencies] -fluence = "=0.4.2" -fce-sqlite-connector = "=0.1.3" +fluence = "0.4.2" +fce-sqlite-connector = "0.2.0" diff --git a/examples/sqlite/Config.toml b/examples/sqlite/Config.toml index 325d6296..1232832f 100644 --- a/examples/sqlite/Config.toml +++ b/examples/sqlite/Config.toml @@ -5,9 +5,15 @@ modules_dir = "artifacts/" mem_pages_count = 100 logger_enabled = false + [module.wasi] + preopened_files = ["/Users/mike/dev/work/fluence/wasm/fce/examples/sqlite"] + mapped_dirs = { "var" = "/Users/mike/dev/work/fluence/wasm/fce/examples/sqlite" } + [[module]] -name = "sqlite_test" + name = "sqlite_test" mem_pages_count = 1 logger_enabled = false - preopened_files = ["/var"] - mapped_dirs = { "var" = "./var" } + + [module.wasi] + preopened_files = ["/Users/mike/dev/work/fluence/wasm/fce/examples/sqlite"] + mapped_dirs = { "var" = "/Users/mike/dev/work/fluence/wasm/fce/examples/sqlite" } diff --git a/examples/sqlite/artifacts/sqlite_test.wasm b/examples/sqlite/artifacts/sqlite_test.wasm index a7982f0e..cc9e0351 100755 Binary files a/examples/sqlite/artifacts/sqlite_test.wasm and b/examples/sqlite/artifacts/sqlite_test.wasm differ diff --git a/examples/sqlite/build.sh b/examples/sqlite/build.sh index 6fb82fd6..fc969d13 100755 --- a/examples/sqlite/build.sh +++ b/examples/sqlite/build.sh @@ -6,5 +6,5 @@ fce build --release rm artifacts/* cp ../../target/wasm32-wasi/release/sqlite_test.wasm artifacts/ -wget https://github.com/fluencelabs/sqlite/releases/download/v0.9.0_w/sqlite3.wasm +wget https://github.com/fluencelabs/sqlite/releases/download/v0.10.0_w/sqlite3.wasm mv sqlite3.wasm artifacts/ diff --git a/examples/sqlite/src/main.rs b/examples/sqlite/src/main.rs index 9e5ed566..eae11e65 100644 --- a/examples/sqlite/src/main.rs +++ b/examples/sqlite/src/main.rs @@ -83,20 +83,21 @@ pub fn test2(age: i64) { #[fce] pub fn test3() { - let db_path = "/var/users.sqlite"; - let connection = fce_sqlite_connector::open(db_path).expect("error on connection establishing"); + let db_path = "/tmp/users.sqlite"; + let connection = fce_sqlite_connector::open(db_path).expect("db should be opened"); - let execute_result = connection.execute( - " - CREATE TABLE users (name TEXT, age INTEGER); + connection + .execute( + " + CREATE TABLE IF NOT EXISTS users (name TEXT, age INTEGER); INSERT INTO users VALUES ('Alice', 42); INSERT INTO users VALUES ('Bob', 69); ", - ); + ) + .expect("table should be created successfully"); - println!("execute result: {:?}", execute_result); + let connection = fce_sqlite_connector::open(db_path).expect("db should be opened"); + let cursor = connection.prepare("SELECT * FROM users").unwrap().cursor(); - //TODO fix it - // let file_size = std::fs::metadata(db_path).expect("error on file_size check").len(); - // println!("{} file size is {}", db_path, file_size); + println!("table size is: {:?}", cursor.count()); }