Skip to content

Commit

Permalink
Merge pull request #216 from massalabs/test-sc-using-as-25
Browse files Browse the repository at this point in the history
Test SCs using AS v25
  • Loading branch information
Eitu33 authored Feb 1, 2023
2 parents 6602be5 + 35f8ca1 commit 6d39a65
Show file tree
Hide file tree
Showing 19 changed files with 329 additions and 20 deletions.
180 changes: 179 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ parking_lot = "0.12"
rand = "0.8"
displaydoc = "0.2"
thiserror = "1.0"
chrono = "0.4"
# for gas_calibration middleware
regex = "1"
more-asserts = "0.3"
Expand Down
8 changes: 7 additions & 1 deletion src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,13 @@ impl Interface for TestInterface {
}

fn get_time(&self) -> Result<u64> {
Ok(0)
// Using chrono as a test dummy implementation to make sure the ABI is called correctly
// Note that Massa node implementation uses the time of the context slot
// in order to ensure determinism, not the UTC time
Ok(chrono::offset::Utc::now()
.timestamp_millis()
.try_into()
.unwrap())
}
}

Expand Down
11 changes: 1 addition & 10 deletions src/tests/tests_gas_calibration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,7 @@ fn test_basic_abi_call_loop() -> Result<()> {
#[serial]
fn test_basic_op() -> Result<()> {
let interface: TestInterface = TestInterface(Arc::new(Mutex::new(Ledger::new())));
let bytecode = include_bytes!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/wasm/gc_op_basic.wasm"
));
let bytecode = include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/wasm/gc_basic_op.wat"));

let gas_costs = GasCosts::default();
let runtime_module = RuntimeModule::new(bytecode, 100_000, gas_costs.clone())?;
Expand All @@ -134,19 +131,13 @@ fn test_basic_op() -> Result<()> {
// Use wat file to view op (https://webassembly.github.io/wabt/demo/wasm2wat/)
let op_executed = HashSet::from([
"Wasm:I32Add",
"Wasm:I32And",
"Wasm:I32GtU",
"Wasm:End",
"Wasm:I32Sub",
"Wasm:I32Shl",
"Wasm:I32Store",
"Wasm:GlobalSet",
"Wasm:LocalTee",
"Wasm:LocalGet",
"Wasm:GlobalGet",
"Wasm:I32Const",
// "Wasm:If",
"Wasm:MemorySize",
]);

for op_exec in &op_executed {
Expand Down
Loading

0 comments on commit 6d39a65

Please sign in to comment.