actix upgrade and adapt actix breaking changes

This commit is contained in:
Aravinth Manivannan 2021-03-24 14:14:31 +05:30
parent 2c13985405
commit d30c97e57a
Signed by: realaravinth
GPG Key ID: AD9F0F08E855ED88
5 changed files with 72 additions and 665 deletions

707
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
[package]
name = "m_captcha"
version = "0.1.1"
version = "0.1.2"
authors = ["realaravinth <realaravinth@batsense.net>"]
description = "Convenient abstractions for all things credentials"
keywords = ["credentials", "password"]
@ -11,7 +11,7 @@ edition = "2018"
readme = "README.md"
[dependencies]
actix = "0.10"
actix = "0.11"
serde = "1.0.114"
serde_json = "1"
@ -23,4 +23,4 @@ rand = "0.8"
pow_sha256 = { version = "0.2", git = "https://github.com/mcaptcha/pow_sha256" }
[dev-dependencies]
actix-rt = "1"
actix-rt = "2"

View File

@ -60,7 +60,7 @@ impl Actor for HashCache {
impl Handler<Cache> for HashCache {
type Result = MessageResult<Cache>;
fn handle(&mut self, msg: Cache, ctx: &mut Self::Context) -> Self::Result {
use actix::clock::delay_for;
use actix::clock::sleep;
use std::time::Duration;
let addr = ctx.address();
@ -68,7 +68,7 @@ impl Handler<Cache> for HashCache {
let duration: Duration = Duration::new(msg.duration.clone(), 0);
let wait_for = async move {
delay_for(duration).await;
sleep(duration).await;
addr.send(del_msg).await.unwrap().unwrap();
}
.into_actor(self);
@ -102,11 +102,11 @@ mod tests {
use crate::pow::PoWConfig;
async fn sleep(time: u64) {
use actix::clock::delay_for;
use actix::clock::sleep;
use std::time::Duration;
let duration: Duration = Duration::new(time, 0);
delay_for(duration).await;
sleep(duration).await;
}
#[actix_rt::test]

View File

@ -19,7 +19,7 @@
use std::collections::BTreeMap;
use std::time::Duration;
use actix::clock::delay_for;
use actix::clock::sleep;
use actix::dev::*;
use derive_builder::Builder;
@ -124,7 +124,7 @@ impl Handler<CleanUp> for Master {
}
let duration = Duration::new(gc, 0);
delay_for(duration).await;
sleep(duration).await;
master.send(CleanUp).await.unwrap();
}
.into_actor(self);
@ -187,8 +187,8 @@ mod tests {
assert!(addr_doesnt_exist.is_none());
let timer_expire = Duration::new(DURATION, 0);
delay_for(timer_expire).await;
delay_for(timer_expire).await;
sleep(timer_expire).await;
sleep(timer_expire).await;
let mcaptcha_addr = addr.send(GetSite(id.into())).await.unwrap();
assert_eq!(mcaptcha_addr, None);

View File

@ -74,7 +74,7 @@
use std::time::Duration;
use actix::clock::delay_for;
use actix::clock::sleep;
use actix::dev::*;
use serde::{Deserialize, Serialize};
@ -218,7 +218,7 @@ impl Handler<AddVisitor> for MCaptcha {
let duration: Duration = Duration::new(self.duration.clone(), 0);
let wait_for = async move {
delay_for(duration).await;
sleep(duration).await;
addr.send(DeleteVisitor).await.unwrap();
}
.into_actor(self);
@ -320,7 +320,7 @@ pub mod tests {
#[actix_rt::test]
async fn counter_defense_loosenup_works() {
use actix::clock::delay_for;
use actix::clock::sleep;
let addr: MyActor = get_counter().start();
race(addr.clone(), LEVEL_2).await;
@ -329,7 +329,7 @@ pub mod tests {
assert_eq!(mcaptcha.difficulty_factor, LEVEL_2.1);
let duration = Duration::new(DURATION, 0);
delay_for(duration).await;
sleep(duration).await;
mcaptcha = addr.send(AddVisitor).await.unwrap();
assert_eq!(mcaptcha.difficulty_factor, LEVEL_1.1);