actix upgrade and adapt actix breaking changes
This commit is contained in:
parent
2c13985405
commit
d30c97e57a
5 changed files with 72 additions and 665 deletions
707
Cargo.lock
generated
707
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "m_captcha"
|
name = "m_captcha"
|
||||||
version = "0.1.1"
|
version = "0.1.2"
|
||||||
authors = ["realaravinth <realaravinth@batsense.net>"]
|
authors = ["realaravinth <realaravinth@batsense.net>"]
|
||||||
description = "Convenient abstractions for all things credentials"
|
description = "Convenient abstractions for all things credentials"
|
||||||
keywords = ["credentials", "password"]
|
keywords = ["credentials", "password"]
|
||||||
|
@ -11,7 +11,7 @@ edition = "2018"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix = "0.10"
|
actix = "0.11"
|
||||||
|
|
||||||
serde = "1.0.114"
|
serde = "1.0.114"
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
|
@ -23,4 +23,4 @@ rand = "0.8"
|
||||||
pow_sha256 = { version = "0.2", git = "https://github.com/mcaptcha/pow_sha256" }
|
pow_sha256 = { version = "0.2", git = "https://github.com/mcaptcha/pow_sha256" }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
actix-rt = "1"
|
actix-rt = "2"
|
||||||
|
|
8
src/cache/hashcache.rs
vendored
8
src/cache/hashcache.rs
vendored
|
@ -60,7 +60,7 @@ impl Actor for HashCache {
|
||||||
impl Handler<Cache> for HashCache {
|
impl Handler<Cache> for HashCache {
|
||||||
type Result = MessageResult<Cache>;
|
type Result = MessageResult<Cache>;
|
||||||
fn handle(&mut self, msg: Cache, ctx: &mut Self::Context) -> Self::Result {
|
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;
|
use std::time::Duration;
|
||||||
|
|
||||||
let addr = ctx.address();
|
let addr = ctx.address();
|
||||||
|
@ -68,7 +68,7 @@ impl Handler<Cache> for HashCache {
|
||||||
|
|
||||||
let duration: Duration = Duration::new(msg.duration.clone(), 0);
|
let duration: Duration = Duration::new(msg.duration.clone(), 0);
|
||||||
let wait_for = async move {
|
let wait_for = async move {
|
||||||
delay_for(duration).await;
|
sleep(duration).await;
|
||||||
addr.send(del_msg).await.unwrap().unwrap();
|
addr.send(del_msg).await.unwrap().unwrap();
|
||||||
}
|
}
|
||||||
.into_actor(self);
|
.into_actor(self);
|
||||||
|
@ -102,11 +102,11 @@ mod tests {
|
||||||
use crate::pow::PoWConfig;
|
use crate::pow::PoWConfig;
|
||||||
|
|
||||||
async fn sleep(time: u64) {
|
async fn sleep(time: u64) {
|
||||||
use actix::clock::delay_for;
|
use actix::clock::sleep;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
let duration: Duration = Duration::new(time, 0);
|
let duration: Duration = Duration::new(time, 0);
|
||||||
delay_for(duration).await;
|
sleep(duration).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use actix::clock::delay_for;
|
use actix::clock::sleep;
|
||||||
use actix::dev::*;
|
use actix::dev::*;
|
||||||
use derive_builder::Builder;
|
use derive_builder::Builder;
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ impl Handler<CleanUp> for Master {
|
||||||
}
|
}
|
||||||
|
|
||||||
let duration = Duration::new(gc, 0);
|
let duration = Duration::new(gc, 0);
|
||||||
delay_for(duration).await;
|
sleep(duration).await;
|
||||||
master.send(CleanUp).await.unwrap();
|
master.send(CleanUp).await.unwrap();
|
||||||
}
|
}
|
||||||
.into_actor(self);
|
.into_actor(self);
|
||||||
|
@ -187,8 +187,8 @@ mod tests {
|
||||||
assert!(addr_doesnt_exist.is_none());
|
assert!(addr_doesnt_exist.is_none());
|
||||||
|
|
||||||
let timer_expire = Duration::new(DURATION, 0);
|
let timer_expire = Duration::new(DURATION, 0);
|
||||||
delay_for(timer_expire).await;
|
sleep(timer_expire).await;
|
||||||
delay_for(timer_expire).await;
|
sleep(timer_expire).await;
|
||||||
|
|
||||||
let mcaptcha_addr = addr.send(GetSite(id.into())).await.unwrap();
|
let mcaptcha_addr = addr.send(GetSite(id.into())).await.unwrap();
|
||||||
assert_eq!(mcaptcha_addr, None);
|
assert_eq!(mcaptcha_addr, None);
|
||||||
|
|
|
@ -74,7 +74,7 @@
|
||||||
|
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use actix::clock::delay_for;
|
use actix::clock::sleep;
|
||||||
use actix::dev::*;
|
use actix::dev::*;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
@ -218,7 +218,7 @@ impl Handler<AddVisitor> for MCaptcha {
|
||||||
|
|
||||||
let duration: Duration = Duration::new(self.duration.clone(), 0);
|
let duration: Duration = Duration::new(self.duration.clone(), 0);
|
||||||
let wait_for = async move {
|
let wait_for = async move {
|
||||||
delay_for(duration).await;
|
sleep(duration).await;
|
||||||
addr.send(DeleteVisitor).await.unwrap();
|
addr.send(DeleteVisitor).await.unwrap();
|
||||||
}
|
}
|
||||||
.into_actor(self);
|
.into_actor(self);
|
||||||
|
@ -320,7 +320,7 @@ pub mod tests {
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn counter_defense_loosenup_works() {
|
async fn counter_defense_loosenup_works() {
|
||||||
use actix::clock::delay_for;
|
use actix::clock::sleep;
|
||||||
let addr: MyActor = get_counter().start();
|
let addr: MyActor = get_counter().start();
|
||||||
|
|
||||||
race(addr.clone(), LEVEL_2).await;
|
race(addr.clone(), LEVEL_2).await;
|
||||||
|
@ -329,7 +329,7 @@ pub mod tests {
|
||||||
assert_eq!(mcaptcha.difficulty_factor, LEVEL_2.1);
|
assert_eq!(mcaptcha.difficulty_factor, LEVEL_2.1);
|
||||||
|
|
||||||
let duration = Duration::new(DURATION, 0);
|
let duration = Duration::new(DURATION, 0);
|
||||||
delay_for(duration).await;
|
sleep(duration).await;
|
||||||
|
|
||||||
mcaptcha = addr.send(AddVisitor).await.unwrap();
|
mcaptcha = addr.send(AddVisitor).await.unwrap();
|
||||||
assert_eq!(mcaptcha.difficulty_factor, LEVEL_1.1);
|
assert_eq!(mcaptcha.difficulty_factor, LEVEL_1.1);
|
||||||
|
|
Loading…
Reference in a new issue