1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#![deny(
missing_docs,
trivial_casts,
trivial_numeric_casts,
unsafe_code,
unused_import_braces,
unused_qualifications,
warnings
)]
mod error;
mod secure_channel;
mod secure_channel_listener;
pub use error::*;
pub use secure_channel::*;
pub use secure_channel_listener::*;
#[cfg(test)]
mod tests {
use crate::SecureChannel;
use ockam_core::Route;
use ockam_vault::SoftwareVault;
use ockam_vault_sync_core::Vault;
#[test]
fn simplest_channel() {
let (mut ctx, mut executor) = ockam_node::start_node();
executor
.execute(async move {
let vault_address = Vault::create_with_inner(&ctx, SoftwareVault::default())?;
SecureChannel::create_listener(
&ctx,
"secure_channel_listener".to_string(),
&vault_address,
)
.await?;
let initiator = SecureChannel::create(
&mut ctx,
Route::new().append("secure_channel_listener"),
&vault_address,
)
.await?;
let test_msg = "Hello, channel".to_string();
ctx.send(
Route::new().append(initiator.address()).append("app"),
test_msg.clone(),
)
.await?;
assert_eq!(ctx.receive::<String>().await?, test_msg);
ctx.stop().await
})
.unwrap();
}
}