Skip to content

Commit

Permalink
rust: add type aliases for enums
Browse files Browse the repository at this point in the history
  • Loading branch information
axic committed Jul 4, 2019
1 parent 2f7a083 commit e84bca3
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
2 changes: 2 additions & 0 deletions bindings/rust/evmc-vm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
//! Have a look at evmc-declare to declare an EVMC compatible VM.
//! This crate documents how to use certain data types.

#![feature(type_alias_enum_variants)]

mod container;
mod types;

Expand Down
46 changes: 46 additions & 0 deletions bindings/rust/evmc-vm/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,21 @@ pub type Bytes32 = ffi::evmc_bytes32;
/// EVMC big-endian 256-bit integer
pub type Uint256 = ffi::evmc_uint256be;

/// EVMC message (call) kind.
pub type MessageKind = ffi::evmc_call_kind;

/// EVMC message (call) flags.
pub type MessageFlags = ffi::evmc_flags;

/// EVMC status code.
pub type StatusCode = ffi::evmc_status_code;

/// EVMC storage status.
pub type StorageStatus = ffi::evmc_storage_status;

/// EVMC VM revision.
pub type Revision = ffi::evmc_revision;

#[cfg(test)]
mod tests {
use super::*;
Expand All @@ -34,4 +49,35 @@ mod tests {
let b = Uint256::default();
assert_eq!(a.clone(), b.clone());
}

#[test]
fn message_kind() {
assert_eq!(MessageKind::EVMC_CALL, ffi::evmc_call_kind::EVMC_CALL);
assert_eq!(
MessageKind::EVMC_CALLCODE,
ffi::evmc_call_kind::EVMC_CALLCODE
);
assert_eq!(
MessageKind::EVMC_DELEGATECALL,
ffi::evmc_call_kind::EVMC_DELEGATECALL
);
assert_eq!(MessageKind::EVMC_CREATE, ffi::evmc_call_kind::EVMC_CREATE);
}

#[test]
fn message_flags() {
assert_eq!(MessageFlags::EVMC_STATIC, ffi::evmc_flags::EVMC_STATIC);
}

#[test]
fn status_code() {}

#[test]
fn storage_status() {}

#[test]
fn revision() {
assert_eq!(Revision::EVMC_FRONTIER, ffi::evmc_revision::EVMC_FRONTIER);
assert_eq!(Revision::EVMC_ISTANBUL, ffi::evmc_revision::EVMC_ISTANBUL);
}
}

0 comments on commit e84bca3

Please sign in to comment.