From 38c4fa6b8ec7a14e62b34acdd2061e72dc71311a Mon Sep 17 00:00:00 2001 From: Stewart Mackenzie Date: Sun, 9 Apr 2017 22:53:57 +0800 Subject: [PATCH 1/3] Problem: capnp tests don't have expected output Solution: gaslighter needs to compare the actual results from the vm with the expected results. So we provide a Test.InputOutput abstraction which includes the ExpectedOutput. --- tests/arith/basic.capnp | 57 ++++++++++++++++++++--------------------- tests/arith/mod.capnp | 1 - tests/hierarchy.capnp | 4 +-- tests/mod.capnp | 3 ++- tests/test.capnp | 14 ++++++++++ 5 files changed, 46 insertions(+), 33 deletions(-) create mode 100644 tests/test.capnp diff --git a/tests/arith/basic.capnp b/tests/arith/basic.capnp index dd6a30c5..ca52ed6c 100644 --- a/tests/arith/basic.capnp +++ b/tests/arith/basic.capnp @@ -1,48 +1,47 @@ @0xda7d72d8f4b3c0c1; -using Vm = import "../../schema/vm.capnp"; +using Test = import "../test.capnp"; using Op = import "../opcodes.capnp"; using Hierarchy = import "../hierarchy.capnp"; const all: Hierarchy.Tests = ( name = "basic", - tests = [ .stop, .add, .multiply ] + tests = [ .stop, .add ] ); -const stop: Vm.InputOutput = ( - name = "stop", - input = ( - gas = 314159, - code = [ Op.STOP, Op.STOP ], - data = [ Op.STOP, Op.STOP ] +const stop: Test.InputOutput = ( + inputOutput = ( + name = "stop", + input = ( + gas = 314159, + code = [ Op.STOP, Op.STOP ], + data = [ Op.STOP, Op.STOP ] + ), + output = ( + gas = 314159, + code = [ Op.STOP ] + ) ), - output = ( + expectedOutput = ( gas = 314159, code = [ Op.STOP ] ) ); -const add: Vm.InputOutput = ( - name = "add", - input = ( - gas = 314159, - code = [ Op.ADD, Op.ADD ], - data = [ Op.ADD, Op.ADD ] - ), - output = ( - gas = 314159, - code = [ Op.STOP ] - ) -); - -const multiply: Vm.InputOutput = ( - name = "multiply", - input = ( - gas = 314159, - code = [ Op.MUL, Op.MUL ], - data = [ Op.MUL, Op.MUL ] +const add: Test.InputOutput = ( + inputOutput = ( + name = "add", + input = ( + gas = 314159, + code = [ Op.STOP, Op.STOP ], + data = [ Op.STOP, Op.STOP ] + ), + output = ( + gas = 314159, + code = [ Op.STOP ] + ) ), - output = ( + expectedOutput = ( gas = 314159, code = [ Op.STOP ] ) diff --git a/tests/arith/mod.capnp b/tests/arith/mod.capnp index 25c65f4b..9c7d6020 100644 --- a/tests/arith/mod.capnp +++ b/tests/arith/mod.capnp @@ -1,6 +1,5 @@ @0xe165e950e83b0d24; -using Vm = import "../../schema/vm.capnp"; using Hierarchy = import "../hierarchy.capnp"; using Basic = import "basic.capnp"; diff --git a/tests/hierarchy.capnp b/tests/hierarchy.capnp index 65a5708f..ce0d2238 100644 --- a/tests/hierarchy.capnp +++ b/tests/hierarchy.capnp @@ -1,10 +1,10 @@ @0xea2c8e2dc7ce97f8; -using Vm = import "../schema/vm.capnp"; +using Test = import "test.capnp"; struct Tests { name @0 :Text; - tests @1 :List(Vm.InputOutput); + tests @1 :List(Test.InputOutput); } struct Files { diff --git a/tests/mod.capnp b/tests/mod.capnp index f42d2e24..d3f297a0 100644 --- a/tests/mod.capnp +++ b/tests/mod.capnp @@ -1,7 +1,8 @@ @0xa8dd6a728e8f8499; -using Vm = import "../schema/vm.capnp"; using Hierarchy = import "hierarchy.capnp"; + +# test modules using Arith = import "arith/mod.capnp"; const all: Hierarchy.Directories = ( diff --git a/tests/test.capnp b/tests/test.capnp new file mode 100644 index 00000000..644fc967 --- /dev/null +++ b/tests/test.capnp @@ -0,0 +1,14 @@ +@0x9b740c183df7ef25; + +using Vm = import "../schema/vm.capnp"; + +# for comparing Actual VM Output (see ../schema/vm.capnp) with Expected VM Output +struct ExpectedOutput { + gas @0 :Int32; + code @1 :List(Data); +} + +struct InputOutput { + inputOutput @0 :Vm.InputOutput; + expectedOutput @1 :ExpectedOutput; +} From 2049dfe5f4869593ecb2177cb9f38bbb519ab7cb Mon Sep 17 00:00:00 2001 From: Stewart Mackenzie Date: Mon, 10 Apr 2017 02:14:16 +0800 Subject: [PATCH 2/3] Problem: VM test which includes expected output doesn't have a name Solution: Move the name from Vm.InputOutput into Test.InputOutput and regenerate all the *_capnp.rs files. --- schema/vm.capnp | 5 +- src/bin/gaslighter/hierarchy_capnp.rs | 10 +- src/bin/gaslighter/mod.rs | 50 +++- src/bin/gaslighter/test_capnp.rs | 336 ++++++++++++++++++++++++++ src/bin/gaslighter/vm_capnp.rs | 54 ++--- tests/arith/basic.capnp | 4 +- tests/test.capnp | 5 +- 7 files changed, 413 insertions(+), 51 deletions(-) create mode 100644 src/bin/gaslighter/test_capnp.rs diff --git a/schema/vm.capnp b/schema/vm.capnp index 18ace794..652ab227 100644 --- a/schema/vm.capnp +++ b/schema/vm.capnp @@ -12,7 +12,6 @@ struct Output { } struct InputOutput { - name @0 :Text; - input @1 :Input; - output @2 :Output; + input @0 :Input; + output @1 :Output; } diff --git a/src/bin/gaslighter/hierarchy_capnp.rs b/src/bin/gaslighter/hierarchy_capnp.rs index 630550e0..10a2fb84 100644 --- a/src/bin/gaslighter/hierarchy_capnp.rs +++ b/src/bin/gaslighter/hierarchy_capnp.rs @@ -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 { @@ -57,7 +57,7 @@ pub mod tests { !self.reader.get_pointer_field(0).is_null() } #[inline] - pub fn get_tests(self) -> Result>> { + pub fn get_tests(self) -> Result>> { ::capnp::traits::FromPointerReader::get_from_pointer(&self.reader.get_pointer_field(1)) } pub fn has_tests(&self) -> bool { @@ -129,15 +129,15 @@ pub mod tests { !self.builder.get_pointer_field(0).is_null() } #[inline] - pub fn get_tests(self) -> Result>> { + pub fn get_tests(self) -> Result>> { ::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 { diff --git a/src/bin/gaslighter/mod.rs b/src/bin/gaslighter/mod.rs index 6a693ba9..a5e17f79 100644 --- a/src/bin/gaslighter/mod.rs +++ b/src/bin/gaslighter/mod.rs @@ -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, + data: Vec, +} + +impl Input { + pub fn new(gas: usize, code: Vec, data: Vec) -> Self { + Self { + gas: gas, + code: code, + data: data, + } + } +} + +struct Output { + gas: usize, + code: Vec, +} + +impl Output { + pub fn new(gas: usize, code: Vec) -> 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 => diff --git a/src/bin/gaslighter/test_capnp.rs b/src/bin/gaslighter/test_capnp.rs new file mode 100644 index 00000000..4c70255f --- /dev/null +++ b/src/bin/gaslighter/test_capnp.rs @@ -0,0 +1,336 @@ +// Generated by the capnpc-rust plugin to the Cap'n Proto schema compiler. +// DO NOT EDIT. +// source: tests/test.capnp + + +pub mod expected_output { + #![allow(unused_imports)] + use capnp::capability::{FromClientHook, FromTypelessPipeline}; + use capnp::{text, data, Result}; + use capnp::private::layout; + use capnp::traits::{FromStructBuilder, FromStructReader}; + use capnp::{primitive_list, enum_list, struct_list, text_list, data_list, list_list}; + + pub struct Owned; + impl <'a> ::capnp::traits::Owned<'a> for Owned { type Reader = Reader<'a>; type Builder = Builder<'a>; } + impl <'a> ::capnp::traits::OwnedStruct<'a> for Owned { type Reader = Reader<'a>; type Builder = Builder<'a>; } + impl ::capnp::traits::Pipelined for Owned { type Pipeline = Pipeline; } + + #[derive(Clone, Copy)] + pub struct Reader<'a> { reader: layout::StructReader<'a> } + + impl <'a,> ::capnp::traits::HasTypeId for Reader<'a,> { + #[inline] + fn type_id() -> u64 { _private::TYPE_ID } + } + impl <'a,> ::capnp::traits::FromStructReader<'a> for Reader<'a,> { + fn new(reader: ::capnp::private::layout::StructReader<'a>) -> Reader<'a,> { + Reader { reader: reader, } + } + } + + impl <'a,> ::capnp::traits::FromPointerReader<'a> for Reader<'a,> { + fn get_from_pointer(reader: &::capnp::private::layout::PointerReader<'a>) -> Result> { + ::std::result::Result::Ok(::capnp::traits::FromStructReader::new(try!(reader.get_struct(::std::ptr::null())))) + } + } + + impl <'a,> ::capnp::traits::Imbue<'a> for Reader<'a,> { + fn imbue(&mut self, cap_table: &'a ::capnp::private::layout::CapTable) { + self.reader.imbue(::capnp::private::layout::CapTableReader::Plain(cap_table)) + } + } + + impl <'a,> Reader<'a,> { + pub fn borrow<'b>(&'b self) -> Reader<'b,> { + Reader { .. *self } + } + + pub fn total_size(&self) -> Result<::capnp::MessageSize> { + self.reader.total_size() + } + #[inline] + pub fn get_gas(self) -> i32 { + self.reader.get_data_field::(0) + } + #[inline] + pub fn get_code(self) -> Result> { + ::capnp::traits::FromPointerReader::get_from_pointer(&self.reader.get_pointer_field(0)) + } + pub fn has_code(&self) -> bool { + !self.reader.get_pointer_field(0).is_null() + } + } + + pub struct Builder<'a> { builder: ::capnp::private::layout::StructBuilder<'a> } + impl <'a,> ::capnp::traits::HasStructSize for Builder<'a,> { + #[inline] + fn struct_size() -> layout::StructSize { _private::STRUCT_SIZE } + } + impl <'a,> ::capnp::traits::HasTypeId for Builder<'a,> { + #[inline] + fn type_id() -> u64 { _private::TYPE_ID } + } + impl <'a,> ::capnp::traits::FromStructBuilder<'a> for Builder<'a,> { + fn new(builder: ::capnp::private::layout::StructBuilder<'a>) -> Builder<'a, > { + Builder { builder: builder, } + } + } + + impl <'a,> ::capnp::traits::ImbueMut<'a> for Builder<'a,> { + fn imbue_mut(&mut self, cap_table: &'a mut ::capnp::private::layout::CapTable) { + self.builder.imbue(::capnp::private::layout::CapTableBuilder::Plain(cap_table)) + } + } + + impl <'a,> ::capnp::traits::FromPointerBuilder<'a> for Builder<'a,> { + fn init_pointer(builder: ::capnp::private::layout::PointerBuilder<'a>, _size: u32) -> Builder<'a,> { + ::capnp::traits::FromStructBuilder::new(builder.init_struct(_private::STRUCT_SIZE)) + } + fn get_from_pointer(builder: ::capnp::private::layout::PointerBuilder<'a>) -> Result> { + ::std::result::Result::Ok(::capnp::traits::FromStructBuilder::new(try!(builder.get_struct(_private::STRUCT_SIZE, ::std::ptr::null())))) + } + } + + impl <'a,> ::capnp::traits::SetPointerBuilder> for Reader<'a,> { + fn set_pointer_builder<'b>(pointer: ::capnp::private::layout::PointerBuilder<'b>, value: Reader<'a,>) -> Result<()> { pointer.set_struct(&value.reader) } + } + + impl <'a,> Builder<'a,> { + pub fn as_reader(self) -> Reader<'a,> { + ::capnp::traits::FromStructReader::new(self.builder.as_reader()) + } + pub fn borrow<'b>(&'b mut self) -> Builder<'b,> { + Builder { .. *self } + } + pub fn borrow_as_reader<'b>(&'b self) -> Reader<'b,> { + ::capnp::traits::FromStructReader::new(self.builder.as_reader()) + } + + pub fn total_size(&self) -> Result<::capnp::MessageSize> { + self.builder.as_reader().total_size() + } + #[inline] + pub fn get_gas(self) -> i32 { + self.builder.get_data_field::(0) + } + #[inline] + pub fn set_gas(&mut self, value: i32) { + self.builder.set_data_field::(0, value); + } + #[inline] + pub fn get_code(self) -> Result> { + ::capnp::traits::FromPointerBuilder::get_from_pointer(self.builder.get_pointer_field(0)) + } + #[inline] + pub fn set_code(&mut self, value: data_list::Reader<'a>) -> Result<()> { + ::capnp::traits::SetPointerBuilder::set_pointer_builder(self.builder.get_pointer_field(0), value) + } + #[inline] + pub fn init_code(self, size: u32) -> data_list::Builder<'a> { + ::capnp::traits::FromPointerBuilder::init_pointer(self.builder.get_pointer_field(0), size) + } + pub fn has_code(&self) -> bool { + !self.builder.get_pointer_field(0).is_null() + } + } + + pub struct Pipeline { _typeless: ::capnp::any_pointer::Pipeline } + impl FromTypelessPipeline for Pipeline { + fn new(typeless: ::capnp::any_pointer::Pipeline) -> Pipeline { + Pipeline { _typeless: typeless, } + } + } + impl Pipeline { + } + mod _private { + use capnp::private::layout; + pub const STRUCT_SIZE: layout::StructSize = layout::StructSize { data: 1, pointers: 1 }; + pub const TYPE_ID: u64 = 0xd65b07c6483b20a5; + } +} + +pub mod input_output { + #![allow(unused_imports)] + use capnp::capability::{FromClientHook, FromTypelessPipeline}; + use capnp::{text, data, Result}; + use capnp::private::layout; + use capnp::traits::{FromStructBuilder, FromStructReader}; + use capnp::{primitive_list, enum_list, struct_list, text_list, data_list, list_list}; + + pub struct Owned; + impl <'a> ::capnp::traits::Owned<'a> for Owned { type Reader = Reader<'a>; type Builder = Builder<'a>; } + impl <'a> ::capnp::traits::OwnedStruct<'a> for Owned { type Reader = Reader<'a>; type Builder = Builder<'a>; } + impl ::capnp::traits::Pipelined for Owned { type Pipeline = Pipeline; } + + #[derive(Clone, Copy)] + pub struct Reader<'a> { reader: layout::StructReader<'a> } + + impl <'a,> ::capnp::traits::HasTypeId for Reader<'a,> { + #[inline] + fn type_id() -> u64 { _private::TYPE_ID } + } + impl <'a,> ::capnp::traits::FromStructReader<'a> for Reader<'a,> { + fn new(reader: ::capnp::private::layout::StructReader<'a>) -> Reader<'a,> { + Reader { reader: reader, } + } + } + + impl <'a,> ::capnp::traits::FromPointerReader<'a> for Reader<'a,> { + fn get_from_pointer(reader: &::capnp::private::layout::PointerReader<'a>) -> Result> { + ::std::result::Result::Ok(::capnp::traits::FromStructReader::new(try!(reader.get_struct(::std::ptr::null())))) + } + } + + impl <'a,> ::capnp::traits::Imbue<'a> for Reader<'a,> { + fn imbue(&mut self, cap_table: &'a ::capnp::private::layout::CapTable) { + self.reader.imbue(::capnp::private::layout::CapTableReader::Plain(cap_table)) + } + } + + impl <'a,> Reader<'a,> { + pub fn borrow<'b>(&'b self) -> Reader<'b,> { + Reader { .. *self } + } + + pub fn total_size(&self) -> Result<::capnp::MessageSize> { + self.reader.total_size() + } + #[inline] + pub fn get_name(self) -> Result> { + self.reader.get_pointer_field(0).get_text(::std::ptr::null(), 0) + } + pub fn has_name(&self) -> bool { + !self.reader.get_pointer_field(0).is_null() + } + #[inline] + pub fn get_input_output(self) -> Result<::vm_capnp::input_output::Reader<'a>> { + ::capnp::traits::FromPointerReader::get_from_pointer(&self.reader.get_pointer_field(1)) + } + pub fn has_input_output(&self) -> bool { + !self.reader.get_pointer_field(1).is_null() + } + #[inline] + pub fn get_expected_output(self) -> Result<::test_capnp::expected_output::Reader<'a>> { + ::capnp::traits::FromPointerReader::get_from_pointer(&self.reader.get_pointer_field(2)) + } + pub fn has_expected_output(&self) -> bool { + !self.reader.get_pointer_field(2).is_null() + } + } + + pub struct Builder<'a> { builder: ::capnp::private::layout::StructBuilder<'a> } + impl <'a,> ::capnp::traits::HasStructSize for Builder<'a,> { + #[inline] + fn struct_size() -> layout::StructSize { _private::STRUCT_SIZE } + } + impl <'a,> ::capnp::traits::HasTypeId for Builder<'a,> { + #[inline] + fn type_id() -> u64 { _private::TYPE_ID } + } + impl <'a,> ::capnp::traits::FromStructBuilder<'a> for Builder<'a,> { + fn new(builder: ::capnp::private::layout::StructBuilder<'a>) -> Builder<'a, > { + Builder { builder: builder, } + } + } + + impl <'a,> ::capnp::traits::ImbueMut<'a> for Builder<'a,> { + fn imbue_mut(&mut self, cap_table: &'a mut ::capnp::private::layout::CapTable) { + self.builder.imbue(::capnp::private::layout::CapTableBuilder::Plain(cap_table)) + } + } + + impl <'a,> ::capnp::traits::FromPointerBuilder<'a> for Builder<'a,> { + fn init_pointer(builder: ::capnp::private::layout::PointerBuilder<'a>, _size: u32) -> Builder<'a,> { + ::capnp::traits::FromStructBuilder::new(builder.init_struct(_private::STRUCT_SIZE)) + } + fn get_from_pointer(builder: ::capnp::private::layout::PointerBuilder<'a>) -> Result> { + ::std::result::Result::Ok(::capnp::traits::FromStructBuilder::new(try!(builder.get_struct(_private::STRUCT_SIZE, ::std::ptr::null())))) + } + } + + impl <'a,> ::capnp::traits::SetPointerBuilder> for Reader<'a,> { + fn set_pointer_builder<'b>(pointer: ::capnp::private::layout::PointerBuilder<'b>, value: Reader<'a,>) -> Result<()> { pointer.set_struct(&value.reader) } + } + + impl <'a,> Builder<'a,> { + pub fn as_reader(self) -> Reader<'a,> { + ::capnp::traits::FromStructReader::new(self.builder.as_reader()) + } + pub fn borrow<'b>(&'b mut self) -> Builder<'b,> { + Builder { .. *self } + } + pub fn borrow_as_reader<'b>(&'b self) -> Reader<'b,> { + ::capnp::traits::FromStructReader::new(self.builder.as_reader()) + } + + pub fn total_size(&self) -> Result<::capnp::MessageSize> { + self.builder.as_reader().total_size() + } + #[inline] + pub fn get_name(self) -> Result> { + self.builder.get_pointer_field(0).get_text(::std::ptr::null(), 0) + } + #[inline] + pub fn set_name(&mut self, value: text::Reader) { + self.builder.get_pointer_field(0).set_text(value); + } + #[inline] + pub fn init_name(self, size: u32) -> text::Builder<'a> { + self.builder.get_pointer_field(0).init_text(size) + } + pub fn has_name(&self) -> bool { + !self.builder.get_pointer_field(0).is_null() + } + #[inline] + pub fn get_input_output(self) -> Result<::vm_capnp::input_output::Builder<'a>> { + ::capnp::traits::FromPointerBuilder::get_from_pointer(self.builder.get_pointer_field(1)) + } + #[inline] + pub fn set_input_output<'b>(&mut self, value: ::vm_capnp::input_output::Reader<'b>) -> Result<()> { + ::capnp::traits::SetPointerBuilder::set_pointer_builder(self.builder.get_pointer_field(1), value) + } + #[inline] + pub fn init_input_output(self, ) -> ::vm_capnp::input_output::Builder<'a> { + ::capnp::traits::FromPointerBuilder::init_pointer(self.builder.get_pointer_field(1), 0) + } + pub fn has_input_output(&self) -> bool { + !self.builder.get_pointer_field(1).is_null() + } + #[inline] + pub fn get_expected_output(self) -> Result<::test_capnp::expected_output::Builder<'a>> { + ::capnp::traits::FromPointerBuilder::get_from_pointer(self.builder.get_pointer_field(2)) + } + #[inline] + pub fn set_expected_output<'b>(&mut self, value: ::test_capnp::expected_output::Reader<'b>) -> Result<()> { + ::capnp::traits::SetPointerBuilder::set_pointer_builder(self.builder.get_pointer_field(2), value) + } + #[inline] + pub fn init_expected_output(self, ) -> ::test_capnp::expected_output::Builder<'a> { + ::capnp::traits::FromPointerBuilder::init_pointer(self.builder.get_pointer_field(2), 0) + } + pub fn has_expected_output(&self) -> bool { + !self.builder.get_pointer_field(2).is_null() + } + } + + pub struct Pipeline { _typeless: ::capnp::any_pointer::Pipeline } + impl FromTypelessPipeline for Pipeline { + fn new(typeless: ::capnp::any_pointer::Pipeline) -> Pipeline { + Pipeline { _typeless: typeless, } + } + } + impl Pipeline { + pub fn get_input_output(&self) -> ::vm_capnp::input_output::Pipeline<> { + FromTypelessPipeline::new(self._typeless.get_pointer_field(1)) + } + pub fn get_expected_output(&self) -> ::test_capnp::expected_output::Pipeline<> { + FromTypelessPipeline::new(self._typeless.get_pointer_field(2)) + } + } + mod _private { + use capnp::private::layout; + pub const STRUCT_SIZE: layout::StructSize = layout::StructSize { data: 0, pointers: 3 }; + pub const TYPE_ID: u64 = 0xbe7e49b634a7736b; + } +} diff --git a/src/bin/gaslighter/vm_capnp.rs b/src/bin/gaslighter/vm_capnp.rs index 78350459..1a302b49 100644 --- a/src/bin/gaslighter/vm_capnp.rs +++ b/src/bin/gaslighter/vm_capnp.rs @@ -1,6 +1,6 @@ // Generated by the capnpc-rust plugin to the Cap'n Proto schema compiler. // DO NOT EDIT. -// source: ../../../schema/vm.capnp +// source: schema/vm.capnp pub mod input { @@ -366,25 +366,18 @@ pub mod input_output { self.reader.total_size() } #[inline] - pub fn get_name(self) -> Result> { - self.reader.get_pointer_field(0).get_text(::std::ptr::null(), 0) - } - pub fn has_name(&self) -> bool { - !self.reader.get_pointer_field(0).is_null() - } - #[inline] pub fn get_input(self) -> Result<::vm_capnp::input::Reader<'a>> { - ::capnp::traits::FromPointerReader::get_from_pointer(&self.reader.get_pointer_field(1)) + ::capnp::traits::FromPointerReader::get_from_pointer(&self.reader.get_pointer_field(0)) } pub fn has_input(&self) -> bool { - !self.reader.get_pointer_field(1).is_null() + !self.reader.get_pointer_field(0).is_null() } #[inline] pub fn get_output(self) -> Result<::vm_capnp::output::Reader<'a>> { - ::capnp::traits::FromPointerReader::get_from_pointer(&self.reader.get_pointer_field(2)) + ::capnp::traits::FromPointerReader::get_from_pointer(&self.reader.get_pointer_field(1)) } pub fn has_output(&self) -> bool { - !self.reader.get_pointer_field(2).is_null() + !self.reader.get_pointer_field(1).is_null() } } @@ -437,49 +430,34 @@ pub mod input_output { self.builder.as_reader().total_size() } #[inline] - pub fn get_name(self) -> Result> { - self.builder.get_pointer_field(0).get_text(::std::ptr::null(), 0) - } - #[inline] - pub fn set_name(&mut self, value: text::Reader) { - self.builder.get_pointer_field(0).set_text(value); - } - #[inline] - pub fn init_name(self, size: u32) -> text::Builder<'a> { - self.builder.get_pointer_field(0).init_text(size) - } - pub fn has_name(&self) -> bool { - !self.builder.get_pointer_field(0).is_null() - } - #[inline] pub fn get_input(self) -> Result<::vm_capnp::input::Builder<'a>> { - ::capnp::traits::FromPointerBuilder::get_from_pointer(self.builder.get_pointer_field(1)) + ::capnp::traits::FromPointerBuilder::get_from_pointer(self.builder.get_pointer_field(0)) } #[inline] pub fn set_input<'b>(&mut self, value: ::vm_capnp::input::Reader<'b>) -> Result<()> { - ::capnp::traits::SetPointerBuilder::set_pointer_builder(self.builder.get_pointer_field(1), value) + ::capnp::traits::SetPointerBuilder::set_pointer_builder(self.builder.get_pointer_field(0), value) } #[inline] pub fn init_input(self, ) -> ::vm_capnp::input::Builder<'a> { - ::capnp::traits::FromPointerBuilder::init_pointer(self.builder.get_pointer_field(1), 0) + ::capnp::traits::FromPointerBuilder::init_pointer(self.builder.get_pointer_field(0), 0) } pub fn has_input(&self) -> bool { - !self.builder.get_pointer_field(1).is_null() + !self.builder.get_pointer_field(0).is_null() } #[inline] pub fn get_output(self) -> Result<::vm_capnp::output::Builder<'a>> { - ::capnp::traits::FromPointerBuilder::get_from_pointer(self.builder.get_pointer_field(2)) + ::capnp::traits::FromPointerBuilder::get_from_pointer(self.builder.get_pointer_field(1)) } #[inline] pub fn set_output<'b>(&mut self, value: ::vm_capnp::output::Reader<'b>) -> Result<()> { - ::capnp::traits::SetPointerBuilder::set_pointer_builder(self.builder.get_pointer_field(2), value) + ::capnp::traits::SetPointerBuilder::set_pointer_builder(self.builder.get_pointer_field(1), value) } #[inline] pub fn init_output(self, ) -> ::vm_capnp::output::Builder<'a> { - ::capnp::traits::FromPointerBuilder::init_pointer(self.builder.get_pointer_field(2), 0) + ::capnp::traits::FromPointerBuilder::init_pointer(self.builder.get_pointer_field(1), 0) } pub fn has_output(&self) -> bool { - !self.builder.get_pointer_field(2).is_null() + !self.builder.get_pointer_field(1).is_null() } } @@ -491,15 +469,15 @@ pub mod input_output { } impl Pipeline { pub fn get_input(&self) -> ::vm_capnp::input::Pipeline<> { - FromTypelessPipeline::new(self._typeless.get_pointer_field(1)) + FromTypelessPipeline::new(self._typeless.get_pointer_field(0)) } pub fn get_output(&self) -> ::vm_capnp::output::Pipeline<> { - FromTypelessPipeline::new(self._typeless.get_pointer_field(2)) + FromTypelessPipeline::new(self._typeless.get_pointer_field(1)) } } mod _private { use capnp::private::layout; - pub const STRUCT_SIZE: layout::StructSize = layout::StructSize { data: 0, pointers: 3 }; + pub const STRUCT_SIZE: layout::StructSize = layout::StructSize { data: 0, pointers: 2 }; pub const TYPE_ID: u64 = 0x80ac473e311425e1; } } diff --git a/tests/arith/basic.capnp b/tests/arith/basic.capnp index ca52ed6c..935e033e 100644 --- a/tests/arith/basic.capnp +++ b/tests/arith/basic.capnp @@ -10,8 +10,8 @@ const all: Hierarchy.Tests = ( ); const stop: Test.InputOutput = ( + name = "stop", inputOutput = ( - name = "stop", input = ( gas = 314159, code = [ Op.STOP, Op.STOP ], @@ -29,8 +29,8 @@ const stop: Test.InputOutput = ( ); const add: Test.InputOutput = ( + name = "add", inputOutput = ( - name = "add", input = ( gas = 314159, code = [ Op.STOP, Op.STOP ], diff --git a/tests/test.capnp b/tests/test.capnp index 644fc967..dcfb37b0 100644 --- a/tests/test.capnp +++ b/tests/test.capnp @@ -9,6 +9,7 @@ struct ExpectedOutput { } struct InputOutput { - inputOutput @0 :Vm.InputOutput; - expectedOutput @1 :ExpectedOutput; + name @0 :Text; + inputOutput @1 :Vm.InputOutput; + expectedOutput @2 :ExpectedOutput; } From 56e747f83a33fdf52f6aa88f8d9ef097821fe09b Mon Sep 17 00:00:00 2001 From: Stewart Mackenzie Date: Mon, 10 Apr 2017 14:01:08 +0800 Subject: [PATCH 3/3] Problem: CI fails due to incorrect SHA256 dependency hash Solution: insert the correct hash, but also include other modifications such as splitting out cli into its own dir. --- Cargo.toml | 4 ++-- default.nix | 6 +++--- src/bin/{cli.rs => cli/mod.rs} | 0 src/bin/gaslighter/mod.rs | 3 +-- 4 files changed, 6 insertions(+), 7 deletions(-) rename src/bin/{cli.rs => cli/mod.rs} (100%) diff --git a/Cargo.toml b/Cargo.toml index 46ad43e7..a8e02b79 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" @@ -23,4 +23,4 @@ clap = "2.22" log = "0.3" capnp = "0.8" ring = "^0.6.0" -merkle = "1.1.0" \ No newline at end of file +merkle = "1.1.0" diff --git a/default.nix b/default.nix index 326bc568..c2016eab 100644 --- a/default.nix +++ b/default.nix @@ -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 { diff --git a/src/bin/cli.rs b/src/bin/cli/mod.rs similarity index 100% rename from src/bin/cli.rs rename to src/bin/cli/mod.rs diff --git a/src/bin/gaslighter/mod.rs b/src/bin/gaslighter/mod.rs index a5e17f79..4819d5af 100644 --- a/src/bin/gaslighter/mod.rs +++ b/src/bin/gaslighter/mod.rs @@ -78,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, };