diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2021-11-28 10:42:33 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2021-11-28 10:46:45 +0100 |
commit | ef32ca89e69098512ba2cf2356377f258ed440ec (patch) | |
tree | 893f7867315cb250c47bf9f474fcdd845051a8b0 /src | |
parent | bfb222f401ad39f1a49281ac1c2a4420326ae12e (diff) |
Add test which posts a chain of messages
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'src')
-rw-r--r-- | src/client.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/client.rs b/src/client.rs index 1872d8a..358a587 100644 --- a/src/client.rs +++ b/src/client.rs @@ -197,4 +197,33 @@ mod tests { assert_eq!(content, text); } + #[tokio::test] + async fn test_post_text_chain() { + let _ = env_logger::try_init(); + let ipfs = IpfsClient::from_str("http://localhost:5001").unwrap(); + let config = Config::default(); + let client = Client::new(ipfs, config); + + let chain_elements = vec![ + (mkdate(2021, 11, 27, 12, 30, 0), "text1", "bafyreiddewrcj6nwfzouxhycypbuqwohb6oev62vjqdko5w7obl5qrwhwm"), + (mkdate(2021, 11, 27, 12, 31, 0), "text2", "bafyreibcu6wgvh62w4gwpnnbhzoafeog4il4wzqg2zo42ogjqrlnr44pgm"), + (mkdate(2021, 11, 27, 12, 32, 0), "text3", "bafyreica4fz6spaiuk3nd6ybfquj3ysn6nlxuoxcd54xblibpirisjlhkm"), + ]; + + let mut prev: Option<crate::cid::Cid> = None; + for (datetime, text, expected_cid) in chain_elements { + let parents = if let Some(previous) = prev.as_ref() { + vec![previous.clone()] + } else { + Vec::new() + }; + + let cid = client.post_text_node_with_datetime(parents, String::from(text), datetime.clone()).await; + assert!(cid.is_ok()); + let cid = cid.unwrap(); + assert_eq!(cid.as_ref(), expected_cid); + prev = Some(cid); + } + } + } |