read and write working

This commit is contained in:
ghe0 2024-08-22 23:29:40 +03:00
parent b3498b8e1e
commit 87c04454ad
Signed by: ghe0
GPG Key ID: 451028EE56A0FBB4

@ -84,7 +84,7 @@ struct FileManager {
impl FileManager {
async fn init(path: &str) -> std::io::Result<Self> {
let file = File::open(path).await?;
let file = File::options().read(true).append(true).open(path).await?;
Ok(Self {
file: Mutex::new(file),
})
@ -196,8 +196,14 @@ mod tests {
node.keypair.to_keypair_bytes(),
retrieved_node.keypair.to_keypair_bytes()
);
assert_eq!(node.joined_at, retrieved_node.joined_at);
assert_eq!(
node.joined_at.duration_since(UNIX_EPOCH).unwrap().as_secs(),
retrieved_node
.joined_at
.duration_since(UNIX_EPOCH)
.unwrap()
.as_secs()
);
remove_file(get_test_file_name(function_name)).await?;
Ok(())