add firefox testing. wip (#517)
* add firefox testing. wip * fix config * use crates bellman * install curl * move wasm install test install script to sh * make sh executable * remove firefox as its suppose to be there already * confirm install.. * seems like firefox isnt there after all * firefox-esr * use fixed bellman * revert backend api change, only touch env outside wasm * fix typo in cfg flag
This commit is contained in:
parent
4b409af47c
commit
86ba4b708c
10 changed files with 150 additions and 11 deletions
|
@ -58,6 +58,26 @@ jobs:
|
|||
# name: Generate code coverage report
|
||||
# command: ./scripts/cov.sh
|
||||
wasm_test:
|
||||
docker:
|
||||
- image: rustlang/rust:nightly-slim
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
name: Version information
|
||||
command: rustc --version; cargo --version; rustup --version
|
||||
- run:
|
||||
name: Calculate dependencies
|
||||
command: cargo generate-lockfile
|
||||
- restore_cache:
|
||||
keys:
|
||||
- v4-cargo-cache-{{ arch }}-{{ checksum "Cargo.lock" }}
|
||||
- run:
|
||||
name: Install wasm testing env
|
||||
command: ./scripts/install_wasm_testing.sh
|
||||
- run:
|
||||
name: Test on firefox
|
||||
command: ZOKRATES_HOME=$(pwd)/zokrates_stdlib/stdlib/ cd zokrates_core && wasm-pack test --firefox --headless -- --features wasm
|
||||
wasm_solvers_test:
|
||||
docker:
|
||||
- image: rustlang/rust:nightly-slim
|
||||
steps:
|
||||
|
@ -122,6 +142,7 @@ workflows:
|
|||
jobs:
|
||||
- build
|
||||
- test
|
||||
- wasm_solvers_test
|
||||
- wasm_test
|
||||
- integration_test
|
||||
- deploy:
|
||||
|
@ -132,6 +153,8 @@ workflows:
|
|||
requires:
|
||||
- build
|
||||
- test
|
||||
- wasm_solvers_test
|
||||
- wasm_test
|
||||
- integration_test
|
||||
|
||||
|
||||
|
|
75
Cargo.lock
generated
75
Cargo.lock
generated
|
@ -76,6 +76,23 @@ dependencies = [
|
|||
"libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bellman_ce"
|
||||
version = "0.3.1"
|
||||
source = "git+https://github.com/schaeff/bellman?branch=fix-zero-sized-chunk#53fffa998dad61f58c4f317f129614b195d28a84"
|
||||
dependencies = [
|
||||
"bit-vec 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"crossbeam 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num_cpus 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pairing_ce 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"web-sys 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bellman_ce"
|
||||
version = "0.3.1"
|
||||
|
@ -239,6 +256,15 @@ dependencies = [
|
|||
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "console_error_panic_hook"
|
||||
version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasm-bindgen 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "constant_time_eq"
|
||||
version = "0.1.4"
|
||||
|
@ -1067,6 +1093,11 @@ dependencies = [
|
|||
"tiny-keccak 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "scoped-tls"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "scopeguard"
|
||||
version = "1.0.0"
|
||||
|
@ -1398,6 +1429,17 @@ dependencies = [
|
|||
"wasm-bindgen-shared 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-futures"
|
||||
version = "0.4.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"js-sys 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasm-bindgen 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"web-sys 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro"
|
||||
version = "0.2.55"
|
||||
|
@ -1424,6 +1466,28 @@ name = "wasm-bindgen-shared"
|
|||
version = "0.2.55"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-test"
|
||||
version = "0.3.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"console_error_panic_hook 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"js-sys 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"scoped-tls 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasm-bindgen 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasm-bindgen-futures 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasm-bindgen-test-macro 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-test-macro"
|
||||
version = "0.3.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-webidl"
|
||||
version = "0.2.55"
|
||||
|
@ -1538,7 +1602,7 @@ name = "zokrates_core"
|
|||
version = "0.4.0"
|
||||
dependencies = [
|
||||
"assert_cli 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bellman_ce 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bellman_ce 0.3.1 (git+https://github.com/schaeff/bellman?branch=fix-zero-sized-chunk)",
|
||||
"bincode 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cmake 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -1560,6 +1624,7 @@ dependencies = [
|
|||
"serde_derive 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"typed-arena 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasm-bindgen-test 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasmi 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"zokrates_embed 0.1.0",
|
||||
"zokrates_field 0.3.4",
|
||||
|
@ -1578,7 +1643,7 @@ dependencies = [
|
|||
name = "zokrates_embed"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bellman_ce 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bellman_ce 0.3.1 (git+https://github.com/schaeff/bellman?branch=fix-zero-sized-chunk)",
|
||||
"sapling-crypto_ce 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
@ -1660,6 +1725,7 @@ dependencies = [
|
|||
"checksum autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2"
|
||||
"checksum backtrace 0.3.40 (registry+https://github.com/rust-lang/crates.io-index)" = "924c76597f0d9ca25d762c25a4d369d51267536465dc5064bdf0eb073ed477ea"
|
||||
"checksum backtrace-sys 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6575f128516de27e3ce99689419835fce9643a9b215a14d2b5b685be018491"
|
||||
"checksum bellman_ce 0.3.1 (git+https://github.com/schaeff/bellman?branch=fix-zero-sized-chunk)" = "<none>"
|
||||
"checksum bellman_ce 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "938ec0feff00f9dfda0e7cbfe8db8b717966a84f6a12e63ed0943c4a90d6a5de"
|
||||
"checksum bincode 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e103c8b299b28a9c6990458b7013dc4a8356a9b854c51b9883241f5866fac36e"
|
||||
"checksum bit-vec 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "02b4ff8b16e6076c3e14220b39fbc1fabb6737522281a388998046859400895f"
|
||||
|
@ -1679,6 +1745,7 @@ dependencies = [
|
|||
"checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9"
|
||||
"checksum cmake 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "81fb25b677f8bf1eb325017cb6bb8452f87969db0fedb4f757b297bee78a7c62"
|
||||
"checksum colored 1.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "433e7ac7d511768127ed85b0c4947f47a254131e37864b2dc13f52aa32cd37e5"
|
||||
"checksum console_error_panic_hook 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "b8d976903543e0c48546a91908f21588a680a8c8f984df9a5d69feccb2b2a211"
|
||||
"checksum constant_time_eq 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "995a44c877f9212528ccc74b21a232f66ad69001e40ede5bcee2ac9ef2657120"
|
||||
"checksum crossbeam 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "69323bff1fb41c635347b8ead484a5ca6c3f11914d784170b158d8449ab07f8e"
|
||||
"checksum crossbeam-channel 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "acec9a3b0b3559f15aee4f90746c4e5e293b701c0f7d3925d24e01645267b68c"
|
||||
|
@ -1780,6 +1847,7 @@ dependencies = [
|
|||
"checksum ryu 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bfa8506c1de11c9c4e4c38863ccbe02a305c8188e85a05a784c9e11e1c3910c8"
|
||||
"checksum same-file 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "585e8ddcedc187886a30fa705c47985c3fa88d06624095856b36ca0b82ff4421"
|
||||
"checksum sapling-crypto_ce 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ec318b68765114e578fe42446b6861565b302bc93089aa01669d19417a6de993"
|
||||
"checksum scoped-tls 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2"
|
||||
"checksum scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d"
|
||||
"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
|
||||
"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
|
||||
|
@ -1823,9 +1891,12 @@ dependencies = [
|
|||
"checksum wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b89c3ce4ce14bdc6fb6beaf9ec7928ca331de5df7e5ea278375642a2f478570d"
|
||||
"checksum wasm-bindgen 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)" = "29ae32af33bacd663a9a28241abecf01f2be64e6a185c6139b04f18b6385c5f2"
|
||||
"checksum wasm-bindgen-backend 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)" = "1845584bd3593442dc0de6e6d9f84454a59a057722f36f005e44665d6ab19d85"
|
||||
"checksum wasm-bindgen-futures 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "1458706aa1b8fe6898d19433c9f110d93a05d1f22ae6adf55810409a94df34b4"
|
||||
"checksum wasm-bindgen-macro 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)" = "87fcc747e6b73c93d22c947a6334644d22cfec5abd8b66238484dc2b0aeb9fe4"
|
||||
"checksum wasm-bindgen-macro-support 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)" = "3dc4b3f2c4078c8c4a5f363b92fcf62604c5913cbd16c6ff5aaf0f74ec03f570"
|
||||
"checksum wasm-bindgen-shared 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)" = "ca0b78d6d3be8589b95d1d49cdc0794728ca734adf36d7c9f07e6459508bb53d"
|
||||
"checksum wasm-bindgen-test 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ed5833682054e941db0b7e2b4877b61bbaafd680608e40d268e070d34558b305"
|
||||
"checksum wasm-bindgen-test-macro 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "9c5dcf70d21d0ff0ea5cdb97dba9a9b56ddad4a9bd10c8912eedc55618be022f"
|
||||
"checksum wasm-bindgen-webidl 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)" = "3126356474ceb717c8fb5549ae387c9fbf4872818454f4d87708bee997214bb5"
|
||||
"checksum wasmi 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "aebbaef470840d157a5c47c8c49f024da7b1b80e90ff729ca982b2b80447e78b"
|
||||
"checksum wasmi-validation 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ab380192444b3e8522ae79c0a1976e42a82920916ccdfbce3def89f456ea33f3"
|
||||
|
|
2
scripts/install_wasm_testing.sh
Executable file
2
scripts/install_wasm_testing.sh
Executable file
|
@ -0,0 +1,2 @@
|
|||
apt-get update && apt-get install curl firefox-esr -y --no-install-recommends
|
||||
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
|
|
@ -15,7 +15,7 @@ bincode = "0.8.0"
|
|||
regex = "0.2"
|
||||
zokrates_field = { version = "0.3", path = "../zokrates_field" }
|
||||
zokrates_abi = { version = "0.1", path = "../zokrates_abi" }
|
||||
zokrates_core = { version = "0.4", path = "../zokrates_core", features = ["multicore"] }
|
||||
zokrates_core = { version = "0.4", path = "../zokrates_core" }
|
||||
zokrates_fs_resolver = { version = "0.4", path = "../zokrates_fs_resolver"}
|
||||
serde_json = "1.0"
|
||||
|
||||
|
|
|
@ -36,11 +36,12 @@ wasmi = { version = "=0.4.5", optional = true }
|
|||
parity-wasm = { version = "0.35.3", optional = true }
|
||||
rustc-hex = { version = "1.0", optional = true }
|
||||
csv = "1"
|
||||
bellman_ce = { version = "0.3.1", default-features = false }
|
||||
bellman_ce = { git = "https://github.com/schaeff/bellman", branch = "fix-zero-sized-chunk", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
glob = "0.2.11"
|
||||
assert_cli = "0.5"
|
||||
wasm-bindgen-test = "0.3.0"
|
||||
|
||||
[build-dependencies]
|
||||
cc = { version = "1.0", features = ["parallel"], optional = true }
|
||||
|
|
|
@ -13,14 +13,14 @@ extern crate bincode;
|
|||
extern crate ff_ce as ff;
|
||||
extern crate lazy_static;
|
||||
extern crate pairing_ce as pairing;
|
||||
#[cfg(feature = "wasm_solver")]
|
||||
#[cfg(feature = "wasm_solvers")]
|
||||
extern crate parity_wasm;
|
||||
extern crate regex;
|
||||
#[cfg(feature = "wasm_solver")]
|
||||
#[cfg(feature = "wasm_solvers")]
|
||||
extern crate rustc_hex;
|
||||
#[cfg(feature = "wasm_solver")]
|
||||
#[cfg(feature = "wasm_solvers")]
|
||||
extern crate serde_bytes;
|
||||
#[cfg(feature = "wasm_solver")]
|
||||
#[cfg(feature = "wasm_solvers")]
|
||||
extern crate wasmi;
|
||||
extern crate zokrates_embed;
|
||||
extern crate zokrates_field;
|
||||
|
|
|
@ -22,6 +22,7 @@ impl G16 {
|
|||
|
||||
impl ProofSystem for G16 {
|
||||
fn setup(&self, program: ir::Prog<FieldPrime>) -> SetupKeypair {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
std::env::set_var("BELLMAN_VERBOSE", "0");
|
||||
println!("{}", G16_WARNING);
|
||||
|
||||
|
@ -46,6 +47,7 @@ impl ProofSystem for G16 {
|
|||
witness: ir::Witness<FieldPrime>,
|
||||
proving_key: Vec<u8>,
|
||||
) -> String {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
std::env::set_var("BELLMAN_VERBOSE", "0");
|
||||
|
||||
println!("{}", G16_WARNING);
|
||||
|
|
|
@ -11,10 +11,10 @@ pub mod types;
|
|||
mod variable;
|
||||
|
||||
pub use crate::typed_absy::parameter::Parameter;
|
||||
pub use crate::typed_absy::types::Type;
|
||||
pub use crate::typed_absy::types::{Signature, Type};
|
||||
pub use crate::typed_absy::variable::Variable;
|
||||
|
||||
use crate::typed_absy::types::{FunctionKey, MemberId, Signature};
|
||||
use crate::typed_absy::types::{FunctionKey, MemberId};
|
||||
use embed::FlatEmbed;
|
||||
use std::collections::HashMap;
|
||||
use std::convert::TryFrom;
|
||||
|
|
40
zokrates_core/tests/wasm.rs
Normal file
40
zokrates_core/tests/wasm.rs
Normal file
|
@ -0,0 +1,40 @@
|
|||
wasm_bindgen_test_configure!(run_in_browser);
|
||||
|
||||
extern crate wasm_bindgen_test;
|
||||
extern crate zokrates_core;
|
||||
extern crate zokrates_field;
|
||||
use wasm_bindgen_test::*;
|
||||
use zokrates_core::flat_absy::FlatVariable;
|
||||
use zokrates_core::ir::{Function, Prog, Statement};
|
||||
use zokrates_core::proof_system::ProofSystem;
|
||||
use zokrates_core::typed_absy::{Signature, Type};
|
||||
use zokrates_field::field::FieldPrime;
|
||||
|
||||
use zokrates_core::proof_system::G16;
|
||||
|
||||
#[wasm_bindgen_test]
|
||||
fn generate_proof() {
|
||||
let program: Prog<FieldPrime> = Prog {
|
||||
main: Function {
|
||||
id: String::from("main"),
|
||||
arguments: vec![FlatVariable::new(0)],
|
||||
returns: vec![FlatVariable::public(0)],
|
||||
statements: vec![Statement::Constraint(
|
||||
FlatVariable::new(0).into(),
|
||||
FlatVariable::public(0).into(),
|
||||
)],
|
||||
},
|
||||
private: vec![false],
|
||||
signature: Signature::new()
|
||||
.inputs(vec![Type::FieldElement])
|
||||
.outputs(vec![Type::FieldElement]),
|
||||
};
|
||||
|
||||
let witness = program
|
||||
.clone()
|
||||
.execute(&vec![FieldPrime::from(42)])
|
||||
.unwrap();
|
||||
|
||||
let keys = G16::new().setup(program.clone());
|
||||
let _proof = G16::new().generate_proof(program, witness, keys.pk);
|
||||
}
|
|
@ -10,5 +10,5 @@ wasm = ["bellman_ce/wasm", "sapling-crypto_ce/wasm"]
|
|||
multicore = ["bellman_ce/multicore", "sapling-crypto_ce/multicore"]
|
||||
|
||||
[dependencies]
|
||||
bellman_ce = { version = "0.3.1", default-features = false }
|
||||
bellman_ce = { git = "https://github.com/schaeff/bellman", branch = "fix-zero-sized-chunk", default-features = false}
|
||||
sapling-crypto_ce = { version = "0.1.1", default-features = false }
|
Loading…
Reference in a new issue