Skip to content

Commit

Permalink
fmt code
Browse files Browse the repository at this point in the history
  • Loading branch information
He1pa committed Feb 5, 2024
1 parent b26c7a4 commit 4d04f30
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 40 deletions.
4 changes: 1 addition & 3 deletions ir_cli/src/abi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,9 +458,7 @@ fn input_type_to_abi_param(input_type_name: &str, param_str: &str) -> Result<ABI
return Ok(ABIParam::StrU128Map(values));
}
_ => {
return Err(format!(
"not supported input param type {inner_type_name}"
));
return Err(format!("not supported input param type {inner_type_name}"));
}
}
} else {
Expand Down
7 changes: 4 additions & 3 deletions ir_cli/src/tests/e2e/continue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ use smart_ir::encoding::datastream::ParamType;

#[test]
fn test_simple_contract_with_continue() {
let mut runtime_and_abi = build_mock_runtime(
r#"module_name = "continueTest"
let mut runtime_and_abi =
build_mock_runtime(
r#"module_name = "continueTest"
contract continueTest {
state {
}
Expand Down Expand Up @@ -48,7 +49,7 @@ fn test_simple_contract_with_continue() {
meta !6 = !{11: u32, 11: u32, "test.sonar": str, }
meta !7 = !{14: u32, 14: u32, "test.sonar": str, }
"#,
);
);
let mut runtime = runtime_and_abi.0;
let abi = runtime_and_abi.1;
// ABI
Expand Down
2 changes: 1 addition & 1 deletion ir_cli/src/tests/e2e/match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ fn test_match() {

let mut bytes = vec![0_u8];
bytes.append(&mut ABIParam::I32(3).as_bytes());
assert_eq!(runtime.call("match", &bytes), [0,3]);
assert_eq!(runtime.call("match", &bytes), [0, 3]);
}
2 changes: 1 addition & 1 deletion ir_cli/src/tests/e2e/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ mod r#for;
mod func;
mod r#if;
mod map;
mod r#match;
mod math;
mod parampack;
mod select;
mod r#match;
65 changes: 33 additions & 32 deletions ir_cli/src/vm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ use smart_ir::ir_codegen::common::global::set_extend_context;
use smart_ir::ir_config::IROptions;
use smart_ir::runtime::vm::*;

pub static WASM_IR: [&[u8]; 1] = [include_bytes!(
"../../../smart_ir/src/runtime/stdlib/wasm/storage_t.bc"
)];
pub static WASM_IR: [&[u8]; 1] =
[include_bytes!("../../../smart_ir/src/runtime/stdlib/wasm/storage_t.bc")];

pub static INIT_EXTEND_CONTEXT_ONCE: Once = Once::new();

Expand Down Expand Up @@ -150,10 +149,11 @@ impl Externals for MockRuntime {
let value_ptr: u32 = args.nth_checked(5)?;

println!("GET SHARED STORAGE KEYS: {keys:?}");
let value = match self.store.get(&keys) {
Some(v) => v.clone(),
None => vec![0],
};
let value =
match self.store.get(&keys) {
Some(v) => v.clone(),
None => vec![0],
};
println!("GET SHARED STORAGE VALUE {value:?}");
self.codec.push(value.clone());
self.vm
Expand All @@ -172,10 +172,11 @@ impl Externals for MockRuntime {
Some(HostAPI::ReadObjectLength) => {
let keys = self.build_keys(&args, "GET STORAGE LENGTH".to_string())?;
println!("GET SHARED STORAGE KEYS: {keys:?}");
let length = match self.store.get(&keys) {
Some(v) => v.len() as i32,
None => -1,
};
let length =
match self.store.get(&keys) {
Some(v) => v.len() as i32,
None => -1,
};
println!("GET PRIVATE STORAGE LENGTH: {length:?}");
Ok(Some(RuntimeValue::I32(length)))
}
Expand All @@ -194,12 +195,12 @@ impl Externals for MockRuntime {

Ok(None)
}
Some(HostAPI::GetCallGasLeft) => Ok(Some(RuntimeValue::I64(
self.vm.context.call_gas_left as i64,
))),
Some(HostAPI::GetCallGasLimit) => Ok(Some(RuntimeValue::I64(
self.vm.context.call_gas_limit as i64,
))),
Some(HostAPI::GetCallGasLeft) => {
Ok(Some(RuntimeValue::I64(self.vm.context.call_gas_left as i64)))
}
Some(HostAPI::GetCallGasLimit) => {
Ok(Some(RuntimeValue::I64(self.vm.context.call_gas_limit as i64)))
}
Some(HostAPI::GetOpContractLength) => {
Ok(Some(RuntimeValue::I32(self.vm.op_addr.len() as i32)))
}
Expand Down Expand Up @@ -245,12 +246,12 @@ impl Externals for MockRuntime {

Ok(None)
}
Some(HostAPI::GetBlockNumber) => Ok(Some(RuntimeValue::I64(
self.vm.context.block_number.try_into().unwrap(),
))),
Some(HostAPI::GetBlockTimestamp) => Ok(Some(RuntimeValue::I64(
self.vm.context.block_timestamp.try_into().unwrap(),
))),
Some(HostAPI::GetBlockNumber) => {
Ok(Some(RuntimeValue::I64(self.vm.context.block_number.try_into().unwrap())))
}
Some(HostAPI::GetBlockTimestamp) => {
Ok(Some(RuntimeValue::I64(self.vm.context.block_timestamp.try_into().unwrap())))
}
Some(HostAPI::GetBlockRandomSeed) => {
let data: u32 = args.nth_checked(0)?;

Expand All @@ -261,15 +262,15 @@ impl Externals for MockRuntime {

Ok(None)
}
Some(HostAPI::GetTxTimestamp) => Ok(Some(RuntimeValue::I64(
self.vm.context.timestamp.try_into().unwrap(),
))),
Some(HostAPI::GetTxNonce) => Ok(Some(RuntimeValue::I64(
self.vm.context.nonce.try_into().unwrap(),
))),
Some(HostAPI::GetTxIndex) => Ok(Some(RuntimeValue::I32(
self.vm.context.index.try_into().unwrap(),
))),
Some(HostAPI::GetTxTimestamp) => {
Ok(Some(RuntimeValue::I64(self.vm.context.timestamp.try_into().unwrap())))
}
Some(HostAPI::GetTxNonce) => {
Ok(Some(RuntimeValue::I64(self.vm.context.nonce.try_into().unwrap())))
}
Some(HostAPI::GetTxIndex) => {
Ok(Some(RuntimeValue::I32(self.vm.context.index.try_into().unwrap())))
}
Some(HostAPI::GetTxHash) => {
let dest = args.nth_checked::<u32>(0)?;
self.vm
Expand Down

0 comments on commit 4d04f30

Please sign in to comment.