use super::*;
#[cfg(feature = "encryption")]
pub async fn server_with_label_with_encryption_client_with_label_with_encryption<S, R>(
s: S::Options,
kind: AddressKind,
) -> Result<(), AnyError>
where
S: StreamLayer<Runtime = R>,
R: Runtime,
{
let name = format!("{kind}_server_with_label_with_encryption_client_with_label_with_encryption");
let label = Label::try_from(&name)?;
let pk = SecretKey::from([1; 32]);
let client = NetTransportTestClient::<R>::new(kind.next(0))
.await?
.with_receive_encrypted(Some(pk))
.with_label(label.cheap_clone())
.with_send_label(true)
.with_receive_verify_label(true);
let mut opts = NetTransportOptions::<_, _, S>::with_stream_layer_options(name.into(), s)
.with_primary_key(Some(pk))
.with_encryption_algo(EncryptionAlgo::PKCS7)
.with_gossip_verify_outgoing(true)
.with_label(label)
.with_offload_size(10);
opts.add_bind_address(kind.next(0));
let trans = NetTransport::<_, SocketAddrResolver<R>, _, _>::new(opts)
.await
.unwrap();
handle_ping(trans, client).await?;
Ok(())
}
#[cfg(feature = "encryption")]
pub async fn server_with_label_with_encryption_client_with_label_no_encryption<S, R>(
s: S::Options,
kind: AddressKind,
) -> Result<(), AnyError>
where
S: StreamLayer<Runtime = R>,
R: Runtime,
{
let name = format!("{kind}_server_with_label_with_encryption_client_with_label_no_encryption");
let label = Label::try_from(&name)?;
let pk = SecretKey::from([1; 32]);
let client = NetTransportTestClient::<R>::new(kind.next(0))
.await?
.with_send_label(true)
.with_label(label.cheap_clone())
.with_receive_verify_label(true)
.with_receive_encrypted(Some(pk));
let mut opts = NetTransportOptions::<_, _, S>::with_stream_layer_options(name.into(), s)
.with_primary_key(Some(pk))
.with_encryption_algo(EncryptionAlgo::PKCS7)
.with_gossip_verify_outgoing(true)
.with_label(label);
opts.add_bind_address(kind.next(0));
let trans = NetTransport::<_, SocketAddrResolver<R>, _, _>::new(opts)
.await
.unwrap();
handle_ping(trans, client).await?;
Ok(())
}
pub async fn server_with_label_no_encryption_client_with_label_with_encryption<S, R>(
s: S::Options,
kind: AddressKind,
) -> Result<(), AnyError>
where
S: StreamLayer<Runtime = R>,
R: Runtime,
{
let name = format!("{kind}_server_with_label_no_encryption_client_with_label_with_encryption");
let label = Label::try_from(&name)?;
let pk = SecretKey::from([1; 32]);
let client = NetTransportTestClient::<R>::new(kind.next(0))
.await?
.with_send_encrypted(Some((EncryptionAlgo::PKCS7, pk)))
.with_receive_verify_label(true)
.with_label(label.cheap_clone())
.with_send_label(true);
let mut opts = NetTransportOptions::<_, _, S>::with_stream_layer_options(name.into(), s)
.with_label(label)
.with_primary_key(Some(pk))
.with_encryption_algo(EncryptionAlgo::PKCS7)
.with_gossip_verify_outgoing(false);
opts.add_bind_address(kind.next(0));
let trans = NetTransport::<_, SocketAddrResolver<R>, _, _>::new(opts)
.await
.unwrap();
handle_ping(trans, client).await?;
Ok(())
}