burrow/tun/tests/configure.rs
JettChenT beae8c0f79 Add Read and Write for Async TunInterface
Those features are implemented using AsyncFD. While write doesn't
require a mutable reference to self, read does.

Make Async Tun a feature

remove async tun from workspace

rename write/read to send/recv
2023-07-03 09:30:52 -04:00

35 lines
644 B
Rust

use fehler::throws;
use std::io::Error;
use std::net::{Ipv4Addr};
use tun::TunInterface;
#[test]
#[throws]
fn test_create() {
TunInterface::new()?;
}
#[test]
#[throws]
fn test_set_get_ipv4() {
let tun = TunInterface::new()?;
let addr = Ipv4Addr::new(10, 0, 0, 1);
tun.set_ipv4_addr(addr)?;
let result = tun.ipv4_addr()?;
assert_eq!(addr, result);
}
#[test]
#[throws]
#[cfg(target_os = "linux")]
fn test_set_get_ipv6() {
let tun = TunInterface::new()?;
let addr = Ipv6Addr::new(1, 1, 1, 1, 1, 1, 1, 1);
tun.set_ipv6_addr(addr)?;
// let result = tun.ipv6_addr()?;
// assert_eq!(addr, result);
}