Skip to content

Commit

Permalink
add deserialize test
Browse files Browse the repository at this point in the history
  • Loading branch information
kayagokalp committed Jun 5, 2024
1 parent 8e2e09f commit 01ade05
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
23 changes: 23 additions & 0 deletions forc-pkg/src/manifest/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1025,8 +1025,31 @@ pub fn find_dir_within(dir: &Path, pkg_name: &str) -> Option<PathBuf> {

#[cfg(test)]
mod tests {
use std::str::FromStr;

use super::*;

#[test]
fn deserialize_contract_dependency() {
let contract_dep_str = r#"{"path": "../", "salt": "1111111111111111111111111111111111111111111111111111111111111111" }"#;

let contract_dep_expected: ContractDependency =
serde_json::from_str(&contract_dep_str).unwrap();

let dependency_det = DependencyDetails {
path: Some("../".to_owned()),
..Default::default()
};
let dependency = Dependency::Detailed(dependency_det);
let contract_dep = ContractDependency {
dependency,
salt: fuel_tx::Salt::from_str(
"1111111111111111111111111111111111111111111111111111111111111111",
)
.unwrap(),
};
assert_eq!(contract_dep, contract_dep_expected)
}
#[test]
fn test_invalid_dependency_details_mixed_together() {
let dependency_details_path_branch = DependencyDetails {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ implicit-std = false
core = { path = "../../../../../../../sway-lib-core" }

[contract-dependencies]
contract_c = { path = "../contract_c", salt = "111111111111111111111111111111111111111111111111111111111111111" }
contract_c = { path = "../contract_c", salt = "1111111111111111111111111111111111111111111111111111111111111111" }

0 comments on commit 01ade05

Please sign in to comment.