diff --git a/.changes/clone-stronghold.md b/.changes/clone-stronghold.md new file mode 100644 index 000000000..a15c7a2c7 --- /dev/null +++ b/.changes/clone-stronghold.md @@ -0,0 +1,5 @@ +--- +"iota-stronghold": minor +--- + +- make stronghold interface clonable \ No newline at end of file diff --git a/client/src/interface.rs b/client/src/interface.rs index c4b62bb12..4446f9b21 100644 --- a/client/src/interface.rs +++ b/client/src/interface.rs @@ -41,6 +41,7 @@ use p2p::{ Multiaddr, PeerId, }; +#[derive(Clone)] /// The main type for the Stronghold System. Used as the entry point for the actor model. Contains various pieces of /// metadata to interpret the data in the vault and store. pub struct Stronghold { diff --git a/client/src/tests/interface_tests.rs b/client/src/tests/interface_tests.rs index 8ec6edf91..d6276a67d 100644 --- a/client/src/tests/interface_tests.rs +++ b/client/src/tests/interface_tests.rs @@ -30,8 +30,11 @@ async fn test_stronghold() { .await .unwrap(); + // clone it, and check for consistency + let stronghold2 = stronghold.clone(); + // Write at the first record of the vault using Some(0). Also creates the new vault. - assert!(stronghold + assert!(stronghold2 .write_to_vault( loc0.clone(), b"test".to_vec(), @@ -42,6 +45,11 @@ async fn test_stronghold() { .is_ok()); // read head. + let (p, _) = stronghold2.read_secret(client_path.clone(), loc0.clone()).await; + + assert_eq!(std::str::from_utf8(&p.unwrap()), Ok("test")); + + // read head from first reference let (p, _) = stronghold.read_secret(client_path.clone(), loc0.clone()).await; assert_eq!(std::str::from_utf8(&p.unwrap()), Ok("test"));