Skip to content

Commit

Permalink
feat(jstzd): update
Browse files Browse the repository at this point in the history
  • Loading branch information
huancheng-trili committed Sep 27, 2024
1 parent a134c27 commit 420c3c0
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion crates/jstzd/src/protocol/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ impl From<BootstrapContracts> for Value {

#[cfg(test)]
mod tests {
use super::{BootstrapAccount, BootstrapAccounts, BootstrapContract};
use super::{
BootstrapAccount, BootstrapAccounts, BootstrapContract, BootstrapContracts,
};
use serde_json::Value;

const ACCOUNT_PUBLIC_KEY: &str =
Expand Down Expand Up @@ -137,4 +139,25 @@ mod tests {
assert_eq!(contract.hash.to_string(), CONTRACT_HASH);
assert_eq!(contract.script.as_str().unwrap(), "dummy-script");
}

#[test]
fn serde_value_from_bootstrap_contracts() {
let contracts = BootstrapContracts {
contracts: vec![BootstrapContract::new(
Value::String("dummy-script".to_owned()),
1000,
CONTRACT_HASH,
)
.unwrap()],
};
let value = Value::from(contracts);
let arr = value.as_array().unwrap();
assert_eq!(arr.len(), 1);
let contract = arr.last().unwrap().as_object().unwrap();
assert_eq!(contract.get("amount").unwrap(), 1000);
assert_eq!(
contract.get("script").unwrap().as_str().unwrap(),
"dummy-script"
);
}
}

0 comments on commit 420c3c0

Please sign in to comment.