Skip to content

Commit

Permalink
Merge pull request zcash-hackworks#15 from sjmackenzie/dev
Browse files Browse the repository at this point in the history
Problems: tests need expected output schema and CI fails due to incorrect SHA256
  • Loading branch information
sorpaas authored Apr 10, 2017
2 parents b75c773 + 56e747f commit 1ab0769
Show file tree
Hide file tree
Showing 13 changed files with 459 additions and 85 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ crate-type = ["rlib", "dylib"]

[[bin]]
name = "svm"
path = "./src/bin/cli.rs"
path = "./src/bin/cli/mod.rs"

[[bin]]
name = "gaslighter"
Expand All @@ -23,4 +23,4 @@ clap = "2.22"
log = "0.3"
capnp = "0.8"
ring = "^0.6.0"
merkle = "1.1.0"
merkle = "1.1.0"
6 changes: 3 additions & 3 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ sputnikvm = rustPlatform.buildRustPackage (rec {
name = "sputnikvm-${version}";
version = "0.1.0";
src = ./.;
depsSha256 = "14i5gh4fvg4fpnirwrzmgycxqm118p1p5c1mnf386223vdg2qisp";
buildInputs = [ capnproto ];
depsSha256 = "040h1s26n5nf8d2sw13lnvd93l5imyg2l6lvmam57ghgvl0rrjc3";
buildInputs = [ capnproto perl ];
doCheck = true;
checkPhase = ''
${capnproto}/bin/capnp eval -b tests/mod.capnp all >> tests.bin
cargo test
target/release/gaslighter --capnp_test_bin tests.bin --artefact_dir target/release/
target/release/gaslighter --capnp_test_bin tests.bin --run_test ///
'';
});
in {
Expand Down
5 changes: 2 additions & 3 deletions schema/vm.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ struct Output {
}

struct InputOutput {
name @0 :Text;
input @1 :Input;
output @2 :Output;
input @0 :Input;
output @1 :Output;
}
File renamed without changes.
10 changes: 5 additions & 5 deletions src/bin/gaslighter/hierarchy_capnp.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Generated by the capnpc-rust plugin to the Cap'n Proto schema compiler.
// DO NOT EDIT.
// source: ../../../tests/hierarchy.capnp
// source: tests/hierarchy.capnp


pub mod tests {
Expand Down Expand Up @@ -57,7 +57,7 @@ pub mod tests {
!self.reader.get_pointer_field(0).is_null()
}
#[inline]
pub fn get_tests(self) -> Result<struct_list::Reader<'a,::vm_capnp::input_output::Owned<>>> {
pub fn get_tests(self) -> Result<struct_list::Reader<'a,::test_capnp::input_output::Owned<>>> {
::capnp::traits::FromPointerReader::get_from_pointer(&self.reader.get_pointer_field(1))
}
pub fn has_tests(&self) -> bool {
Expand Down Expand Up @@ -129,15 +129,15 @@ pub mod tests {
!self.builder.get_pointer_field(0).is_null()
}
#[inline]
pub fn get_tests(self) -> Result<struct_list::Builder<'a,::vm_capnp::input_output::Owned<>>> {
pub fn get_tests(self) -> Result<struct_list::Builder<'a,::test_capnp::input_output::Owned<>>> {
::capnp::traits::FromPointerBuilder::get_from_pointer(self.builder.get_pointer_field(1))
}
#[inline]
pub fn set_tests(&mut self, value: struct_list::Reader<'a,::vm_capnp::input_output::Owned<>>) -> Result<()> {
pub fn set_tests(&mut self, value: struct_list::Reader<'a,::test_capnp::input_output::Owned<>>) -> Result<()> {
::capnp::traits::SetPointerBuilder::set_pointer_builder(self.builder.get_pointer_field(1), value)
}
#[inline]
pub fn init_tests(self, size: u32) -> struct_list::Builder<'a,::vm_capnp::input_output::Owned<>> {
pub fn init_tests(self, size: u32) -> struct_list::Builder<'a,::test_capnp::input_output::Owned<>> {
::capnp::traits::FromPointerBuilder::init_pointer(self.builder.get_pointer_field(1), size)
}
pub fn has_tests(&self) -> bool {
Expand Down
53 changes: 50 additions & 3 deletions src/bin/gaslighter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,63 @@ extern crate capnp;

mod hierarchy_capnp;
mod vm_capnp;
mod test_capnp;

use std::error::Error;
use std::fs::File;
use std::path::Path;
use std::io::BufReader;

use hierarchy_capnp::{directories, files};
use hierarchy_capnp::{directories};
use vm_capnp::{input_output, input, output};
use test_capnp::*;
use capnp::{serialize, message};

struct Input {
gas: usize,
code: Vec<u8>,
data: Vec<u8>,
}

impl Input {
pub fn new(gas: usize, code: Vec<u8>, data: Vec<u8>) -> Self {
Self {
gas: gas,
code: code,
data: data,
}
}
}

struct Output {
gas: usize,
code: Vec<u8>,
}

impl Output {
pub fn new(gas: usize, code: Vec<u8>) -> Self {
Self {
gas: gas,
code: code,
}
}
}

struct InputOutput {
name: String,
input: Input,
output: Output,
}

impl InputOutput {
pub fn new(name: String, input: Input, output: Output) -> Self{
Self {
name: name,
input: input,
output: output,
}
}
}

fn main() {
let matches = clap_app!(gaslighter =>
Expand All @@ -30,10 +78,9 @@ fn main() {
Some(c) => c,
None => "",
};
println!("capnp_test_bin: {:?}", capnp_test_bin);
let path = Path::new(capnp_test_bin);
let display = path.display();
let mut file = match File::open(&path) {
let file = match File::open(&path) {
Err(_) => panic!("couldn't open {}", display),
Ok(file) => file,
};
Expand Down
Loading

0 comments on commit 1ab0769

Please sign in to comment.