Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
jakelang committed May 24, 2019
1 parent e36d7f7 commit d078d6c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
6 changes: 2 additions & 4 deletions bindings/rust/evmc-declare-tests/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use evmc_vm::EvmcVm;
use evmc_vm::ExecutionResult;
use evmc_vm::ExecutionContext;
use evmc_vm::ExecutionResult;
#[macro_use]
use evmc_declare::evmc_declare_vm;

Expand All @@ -11,9 +11,7 @@ pub struct FooVM {

impl EvmcVm for FooVM {
fn init() -> Self {
FooVM {
a: 105023,
}
FooVM { a: 105023 }
}

fn execute(&self, code: &[u8], context: &ExecutionContext) -> ExecutionResult {
Expand Down
17 changes: 13 additions & 4 deletions bindings/rust/evmc-vm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
*/

pub extern crate evmc_sys;
pub mod types;
mod container;
pub mod types;

pub use container::EvmcContainer;
pub use evmc_declare::evmc_declare_vm;
Expand Down Expand Up @@ -63,7 +63,10 @@ impl ExecutionResult {
}

impl<'a> ExecutionContext<'a> {
pub fn new(_message: &'a evmc_sys::evmc_message, _context: &'a mut evmc_sys::evmc_context) -> Self {
pub fn new(
_message: &'a evmc_sys::evmc_message,
_context: &'a mut evmc_sys::evmc_context,
) -> Self {
let _tx_context = unsafe {
assert!((*(_context.host)).get_tx_context.is_some());
(*(_context.host)).get_tx_context.unwrap()(_context as *mut evmc_sys::evmc_context)
Expand Down Expand Up @@ -175,7 +178,11 @@ impl<'a> ExecutionContext<'a> {
}
}

pub fn selfdestruct(&mut self, address: &evmc_sys::evmc_address, beneficiary: &evmc_sys::evmc_address) {
pub fn selfdestruct(
&mut self,
address: &evmc_sys::evmc_address,
beneficiary: &evmc_sys::evmc_address,
) {
unsafe {
assert!((*self.context.host).selfdestruct.is_some());
(*self.context.host).selfdestruct.unwrap()(
Expand Down Expand Up @@ -517,7 +524,9 @@ mod tests {
let mut exe_context = ExecutionContext::new(&msg, &mut context_raw);

let a = exe_context.get_tx_context();
let b = unsafe { get_dummy_tx_context(&mut get_dummy_context() as *mut evmc_sys::evmc_context) };
let b = unsafe {
get_dummy_tx_context(&mut get_dummy_context() as *mut evmc_sys::evmc_context)
};

assert_eq!(a.block_gas_limit, b.block_gas_limit);
assert_eq!(a.block_timestamp, b.block_timestamp);
Expand Down

0 comments on commit d078d6c

Please sign in to comment.