diff --git a/crates/jstzd/src/protocol/bootstrap.rs b/crates/jstzd/src/protocol/bootstrap.rs index 0ebb4ce9..8ac432bd 100644 --- a/crates/jstzd/src/protocol/bootstrap.rs +++ b/crates/jstzd/src/protocol/bootstrap.rs @@ -95,7 +95,9 @@ impl From 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 = @@ -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" + ); + } }