mirror of
https://github.com/FuelLabs/sway.git
synced 2025-08-09 13:18:44 +00:00

Some checks failed
Codspeed Benchmarks / benchmarks (push) Has been cancelled
CI / check-dependency-version-formats (push) Has been cancelled
CI / check-forc-manifest-version (push) Has been cancelled
CI / get-fuel-core-version (push) Has been cancelled
CI / build-sway-lib-std (push) Has been cancelled
CI / build-sway-examples (push) Has been cancelled
CI / build-reference-examples (push) Has been cancelled
CI / forc-fmt-check-sway-lib-std (push) Has been cancelled
CI / forc-fmt-check-sway-examples (push) Has been cancelled
CI / forc-fmt-check-panic (push) Has been cancelled
CI / check-sdk-harness-test-suite-compatibility (push) Has been cancelled
CI / build-mdbook (push) Has been cancelled
CI / build-forc-doc-sway-lib-std (push) Has been cancelled
CI / cargo-clippy (push) Has been cancelled
CI / build-forc-test-project (push) Has been cancelled
CI / cargo-build-workspace (push) Has been cancelled
CI / cargo-toml-fmt-check (push) Has been cancelled
CI / cargo-fmt-check (push) Has been cancelled
CI / forc-run-benchmarks (push) Has been cancelled
CI / forc-unit-tests (push) Has been cancelled
CI / forc-pkg-fuels-deps-check (push) Has been cancelled
CI / cargo-test-sway-lsp (push) Has been cancelled
CI / cargo-run-e2e-test-evm (push) Has been cancelled
CI / cargo-test-lib-std (push) Has been cancelled
CI / cargo-test-forc (push) Has been cancelled
CI / cargo-test-workspace (push) Has been cancelled
CI / cargo-unused-deps-check (push) Has been cancelled
CI / pre-publish-check (push) Has been cancelled
github pages / deploy (push) Has been cancelled
CI / verifications-complete (push) Has been cancelled
CI / cargo-run-e2e-test (push) Has been cancelled
CI / cargo-run-e2e-test-release (push) Has been cancelled
CI / cargo-test-forc-debug (push) Has been cancelled
CI / cargo-test-forc-client (push) Has been cancelled
CI / cargo-test-forc-mcp (push) Has been cancelled
CI / cargo-test-forc-node (push) Has been cancelled
CI / notify-slack-on-failure (push) Has been cancelled
CI / publish (push) Has been cancelled
CI / publish-sway-lib-std (push) Has been cancelled
CI / Build and upload forc binaries to release (push) Has been cancelled
This is in preparation for the argument mutability analysis. This PR also has some skeleton code for this analysis, but the actual analysis is still a `todo!()`. The analysis will also have better precision if we use fewer asm blocks, but I'll get to that after working on the analysis itself.
88 lines
3.7 KiB
Rust
88 lines
3.7 KiB
Rust
use std::path::PathBuf;
|
|
|
|
use rexpect::spawn;
|
|
|
|
const TIMEOUT_MS: u64 = 300000;
|
|
|
|
fn test_fixtures_path() -> PathBuf {
|
|
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
|
.join("tests")
|
|
.join("fixtures")
|
|
.canonicalize()
|
|
.unwrap()
|
|
}
|
|
|
|
#[test]
|
|
fn test_forc_test_decoded_logs() -> Result<(), rexpect::error::Error> {
|
|
// Spawn the forc binary using cargo run
|
|
let project_dir = test_fixtures_path().join("test_contract");
|
|
let mut process = spawn(
|
|
&format!(
|
|
"cargo run --bin forc -- test --logs --path {}",
|
|
project_dir.to_string_lossy()
|
|
),
|
|
Some(TIMEOUT_MS),
|
|
)?;
|
|
|
|
// Assert that the output is correct
|
|
process.exp_string(" test test_log_4")?;
|
|
process.exp_string("decoded log values:")?;
|
|
process.exp_string("4, log rb: 1515152261580153489")?;
|
|
process.exp_string(" test test_log_2")?;
|
|
process.exp_string("decoded log values:")?;
|
|
process.exp_string("2, log rb: 1515152261580153489")?;
|
|
|
|
process.process.exit()?;
|
|
Ok(())
|
|
}
|
|
|
|
#[test]
|
|
fn test_forc_test_raw_logs() -> Result<(), rexpect::error::Error> {
|
|
// Spawn the forc binary using cargo run
|
|
let project_dir = test_fixtures_path().join("test_contract");
|
|
let mut process = spawn(
|
|
&format!(
|
|
"cargo run --bin forc -- test --raw-logs --path {}",
|
|
project_dir.to_string_lossy()
|
|
),
|
|
Some(TIMEOUT_MS),
|
|
)?;
|
|
|
|
// Assert that the output is correct
|
|
process.exp_string(" test test_log_4")?;
|
|
process.exp_string("raw logs:")?;
|
|
process.exp_string(r#"[{"LogData":{"data":"0000000000000004","digest":"8005f02d43fa06e7d0585fb64c961d57e318b27a145c857bcd3a6bdb413ff7fc","id":"0000000000000000000000000000000000000000000000000000000000000000","is":10368,"len":8,"pc":12456,"ptr":67107840,"ra":0,"rb":1515152261580153489}}]"#)?;
|
|
process.exp_string(" test test_log_2")?;
|
|
process.exp_string("raw logs:")?;
|
|
process.exp_string(r#"[{"LogData":{"data":"0000000000000002","digest":"cd04a4754498e06db5a13c5f371f1f04ff6d2470f24aa9bd886540e5dce77f70","id":"0000000000000000000000000000000000000000000000000000000000000000","is":10368,"len":8,"pc":12456,"ptr":67107840,"ra":0,"rb":1515152261580153489}}]"#)?;
|
|
|
|
process.process.exit()?;
|
|
Ok(())
|
|
}
|
|
|
|
#[test]
|
|
fn test_forc_test_both_logs() -> Result<(), rexpect::error::Error> {
|
|
// Spawn the forc binary using cargo run
|
|
let project_dir = test_fixtures_path().join("test_contract");
|
|
let mut process = spawn(
|
|
&format!(
|
|
"cargo run --bin forc -- test --logs --raw-logs --path {}",
|
|
project_dir.to_string_lossy()
|
|
),
|
|
Some(TIMEOUT_MS),
|
|
)?;
|
|
|
|
// Assert that the output is correct
|
|
process.exp_string(" test test_log_4")?;
|
|
process.exp_string("decoded log values:")?;
|
|
process.exp_string("4, log rb: 1515152261580153489")?;
|
|
process.exp_string("raw logs:")?;
|
|
process.exp_string(r#"[{"LogData":{"data":"0000000000000004","digest":"8005f02d43fa06e7d0585fb64c961d57e318b27a145c857bcd3a6bdb413ff7fc","id":"0000000000000000000000000000000000000000000000000000000000000000","is":10368,"len":8,"pc":12456,"ptr":67107840,"ra":0,"rb":1515152261580153489}}]"#)?;
|
|
process.exp_string(" test test_log_2")?;
|
|
process.exp_string("decoded log values:")?;
|
|
process.exp_string("2, log rb: 1515152261580153489")?;
|
|
process.exp_string("raw logs:")?;
|
|
process.exp_string(r#"[{"LogData":{"data":"0000000000000002","digest":"cd04a4754498e06db5a13c5f371f1f04ff6d2470f24aa9bd886540e5dce77f70","id":"0000000000000000000000000000000000000000000000000000000000000000","is":10368,"len":8,"pc":12456,"ptr":67107840,"ra":0,"rb":1515152261580153489}}]"#)?;
|
|
process.process.exit()?;
|
|
Ok(())
|
|
}
|