Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test SCs using AS v25 #216

Merged
merged 9 commits into from
Feb 1, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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