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

Chore: improved code coverage #44

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

gluax
Copy link
Collaborator

@gluax gluax commented Jan 8, 2025

Motivation

For the upcoming code audit.

Explanation of Changes

  • Adds more test coverage in a lot of place.
  • Uses some macros to help do.
  • Uses arbitrary and rand to help do so.
  • Makes some minor tweaks to make code regions more hittable.
  • Also comments out some code that's used by the VM in the overlay but not at all here.
  • Change cov command so it runs tests from the runtime. Before it would check for coverage in it, and then not run the tests from it which was rude.

Testing

They all pass.

Related PRs and Issues

N/A

@gluax gluax self-assigned this Jan 8, 2025
Copy link

github-actions bot commented Jan 8, 2025

Code Coverage

Package Line Rate Complexity Health
libtallyvm.src 93% 0
runtime.core.src.core_vm_imports 81% 0
runtime.sdk.src 99% 0
runtime.core.src 91% 0
runtime.sdk.src.promises 84% 0
runtime.core.src.tally_vm_imports 99% 0
Summary 90% (1233 / 1373) 0

Comment on lines +27 to 33
// Doesn't exist for Singlepass compiler
// /// The ID of the WASM file, loads from cache
// Id(String),
// Unlikely to be used for tallyvm?
// /// The path on disk of the WASM file
// Path(String),
/// The bytes of the binary
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we check with @FranklinWaller why we had this and we don't use it anymore? :)

Comment on lines +22 to +54
// not used with singlepass compiler
// pub fn wasm_cache_store<ID: ToString, T: AsRef<[u8]>>(
// sedad_home: &Path,
// store: &Store,
// id: ID,
// wasm_binary: T,
// ) -> Result<Module> {
// let wasm_cache_path = create_cache_path(sedad_home, id)?;
// let module = Module::new(&store, &wasm_binary)?;

// let mut file = File::create(wasm_cache_path)?;
// let buffer = module.serialize()?;
// file.write_all(&buffer)?;

// Ok(module)
// }

// not used with singlepass compiler
// pub fn wasm_cache_load<ID: ToString>(sedad_home: &Path, store: &Store, id: ID) -> Result<Module> {
// let wasm_cache_path = create_cache_path(sedad_home, id)?;

// unsafe {
// let ret = Module::deserialize_from_file(&store, wasm_cache_path.clone());

// if ret.is_err() {
// // If an error occurs while deserializing then we can not trust it anymore
// // so delete the cache file
// let _ = std::fs::remove_file(wasm_cache_path);
// }

// Ok(ret?)
// }
// }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After checking it, if we don't use it and we don't intent to use it in the future, we could remove it, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, they are used on the overlay side where this was taken. I didn't remove it because I wasn't sure if we'd ever swap off singlepass. But I suppose it's safe to remove since we could always copy it back from the overlay?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants