Compare commits
No commits in common. "262a52a8e97ea36c4b51abaa668206b56f56ee85" and "3ffb124cd4a04c40c2fcb0bc08f6e05360dd0a2c" have entirely different histories.
262a52a8e9
...
3ffb124cd4
|
@ -47,7 +47,6 @@ pub struct VoiceState {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Updateable for VoiceState {
|
impl Updateable for VoiceState {
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
fn id(&self) -> Snowflake {
|
fn id(&self) -> Snowflake {
|
||||||
if let Some(id) = self.id {
|
if let Some(id) = self.id {
|
||||||
id // ID exists: Only the case for Spacebar Server impls
|
id // ID exists: Only the case for Spacebar Server impls
|
||||||
|
|
|
@ -31,9 +31,7 @@ pub struct AutoModerationRuleUpdate {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "client")]
|
#[cfg(feature = "client")]
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
impl UpdateMessage<AutoModerationRule> for AutoModerationRuleUpdate {
|
impl UpdateMessage<AutoModerationRule> for AutoModerationRuleUpdate {
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
fn id(&self) -> Option<Snowflake> {
|
fn id(&self) -> Option<Snowflake> {
|
||||||
Some(self.rule.id)
|
Some(self.rule.id)
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,6 @@ impl WebSocketEvent for ChannelCreate {}
|
||||||
|
|
||||||
#[cfg(feature = "client")]
|
#[cfg(feature = "client")]
|
||||||
impl UpdateMessage<Guild> for ChannelCreate {
|
impl UpdateMessage<Guild> for ChannelCreate {
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
fn id(&self) -> Option<Snowflake> {
|
fn id(&self) -> Option<Snowflake> {
|
||||||
self.channel.guild_id
|
self.channel.guild_id
|
||||||
}
|
}
|
||||||
|
@ -74,8 +73,6 @@ impl UpdateMessage<Channel> for ChannelUpdate {
|
||||||
let mut write = object_to_update.write().unwrap();
|
let mut write = object_to_update.write().unwrap();
|
||||||
*write = self.channel.clone();
|
*write = self.channel.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
fn id(&self) -> Option<Snowflake> {
|
fn id(&self) -> Option<Snowflake> {
|
||||||
Some(self.channel.id)
|
Some(self.channel.id)
|
||||||
}
|
}
|
||||||
|
@ -114,7 +111,6 @@ pub struct ChannelDelete {
|
||||||
|
|
||||||
#[cfg(feature = "client")]
|
#[cfg(feature = "client")]
|
||||||
impl UpdateMessage<Guild> for ChannelDelete {
|
impl UpdateMessage<Guild> for ChannelDelete {
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
fn id(&self) -> Option<Snowflake> {
|
fn id(&self) -> Option<Snowflake> {
|
||||||
self.channel.guild_id
|
self.channel.guild_id
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,9 +30,7 @@ pub struct GuildCreate {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "client")]
|
#[cfg(feature = "client")]
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
impl UpdateMessage<Guild> for GuildCreate {
|
impl UpdateMessage<Guild> for GuildCreate {
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
fn id(&self) -> Option<Snowflake> {
|
fn id(&self) -> Option<Snowflake> {
|
||||||
match &self.d {
|
match &self.d {
|
||||||
GuildCreateDataOption::UnavailableGuild(unavailable) => Some(unavailable.id),
|
GuildCreateDataOption::UnavailableGuild(unavailable) => Some(unavailable.id),
|
||||||
|
@ -94,7 +92,6 @@ impl WebSocketEvent for GuildUpdate {}
|
||||||
|
|
||||||
#[cfg(feature = "client")]
|
#[cfg(feature = "client")]
|
||||||
impl UpdateMessage<Guild> for GuildUpdate {
|
impl UpdateMessage<Guild> for GuildUpdate {
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
fn id(&self) -> Option<Snowflake> {
|
fn id(&self) -> Option<Snowflake> {
|
||||||
Some(self.guild.id)
|
Some(self.guild.id)
|
||||||
}
|
}
|
||||||
|
@ -114,7 +111,6 @@ pub struct GuildDelete {
|
||||||
|
|
||||||
#[cfg(feature = "client")]
|
#[cfg(feature = "client")]
|
||||||
impl UpdateMessage<Guild> for GuildDelete {
|
impl UpdateMessage<Guild> for GuildDelete {
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
fn id(&self) -> Option<Snowflake> {
|
fn id(&self) -> Option<Snowflake> {
|
||||||
Some(self.guild.id)
|
Some(self.guild.id)
|
||||||
}
|
}
|
||||||
|
@ -229,7 +225,6 @@ impl WebSocketEvent for GuildRoleCreate {}
|
||||||
|
|
||||||
#[cfg(feature = "client")]
|
#[cfg(feature = "client")]
|
||||||
impl UpdateMessage<Guild> for GuildRoleCreate {
|
impl UpdateMessage<Guild> for GuildRoleCreate {
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
fn id(&self) -> Option<Snowflake> {
|
fn id(&self) -> Option<Snowflake> {
|
||||||
Some(self.guild_id)
|
Some(self.guild_id)
|
||||||
}
|
}
|
||||||
|
@ -263,7 +258,6 @@ impl WebSocketEvent for GuildRoleUpdate {}
|
||||||
|
|
||||||
#[cfg(feature = "client")]
|
#[cfg(feature = "client")]
|
||||||
impl UpdateMessage<RoleObject> for GuildRoleUpdate {
|
impl UpdateMessage<RoleObject> for GuildRoleUpdate {
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
fn id(&self) -> Option<Snowflake> {
|
fn id(&self) -> Option<Snowflake> {
|
||||||
Some(self.role.id)
|
Some(self.role.id)
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,7 +135,6 @@ where
|
||||||
fn update(&mut self, object_to_update: Shared<T>) {
|
fn update(&mut self, object_to_update: Shared<T>) {
|
||||||
update_object(self.get_json(), object_to_update)
|
update_object(self.get_json(), object_to_update)
|
||||||
}
|
}
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
fn id(&self) -> Option<Snowflake>;
|
fn id(&self) -> Option<Snowflake>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,6 @@ impl WebSocketEvent for ThreadUpdate {}
|
||||||
|
|
||||||
#[cfg(feature = "client")]
|
#[cfg(feature = "client")]
|
||||||
impl UpdateMessage<Channel> for ThreadUpdate {
|
impl UpdateMessage<Channel> for ThreadUpdate {
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
fn id(&self) -> Option<Snowflake> {
|
fn id(&self) -> Option<Snowflake> {
|
||||||
Some(self.thread.id)
|
Some(self.thread.id)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,7 @@ mod common;
|
||||||
|
|
||||||
use chorus::errors::GatewayError;
|
use chorus::errors::GatewayError;
|
||||||
use chorus::gateway::*;
|
use chorus::gateway::*;
|
||||||
use chorus::types::{
|
use chorus::types::{self, ChannelModifySchema, IntoShared, RoleCreateModifySchema, RoleObject};
|
||||||
self, Channel, ChannelCreateSchema, ChannelModifySchema, IntoShared, RoleCreateModifySchema,
|
|
||||||
RoleObject,
|
|
||||||
};
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
use wasm_bindgen_test::*;
|
use wasm_bindgen_test::*;
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
|
@ -39,10 +36,7 @@ async fn test_gateway_authenticate() {
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
||||||
#[cfg_attr(not(target_arch = "wasm32"), tokio::test)]
|
#[cfg_attr(not(target_arch = "wasm32"), tokio::test)]
|
||||||
async fn test_self_updating_structs() {
|
async fn test_self_updating_structs() {
|
||||||
// PRETTYFYME: This test is a bit of a mess, but it works. Ideally, each self-updating struct
|
|
||||||
// would have its own test.
|
|
||||||
let mut bundle = common::setup().await;
|
let mut bundle = common::setup().await;
|
||||||
|
|
||||||
let received_channel = bundle
|
let received_channel = bundle
|
||||||
.user
|
.user
|
||||||
.gateway
|
.gateway
|
||||||
|
@ -70,34 +64,6 @@ async fn test_self_updating_structs() {
|
||||||
"selfupdating".to_string()
|
"selfupdating".to_string()
|
||||||
);
|
);
|
||||||
|
|
||||||
let guild = bundle
|
|
||||||
.user
|
|
||||||
.gateway
|
|
||||||
.observe_and_into_inner(bundle.guild.clone())
|
|
||||||
.await;
|
|
||||||
assert!(guild.channels.is_none());
|
|
||||||
|
|
||||||
Channel::create(
|
|
||||||
&mut bundle.user,
|
|
||||||
guild.id,
|
|
||||||
None,
|
|
||||||
ChannelCreateSchema {
|
|
||||||
name: "selfupdating2".to_string(),
|
|
||||||
channel_type: Some(types::ChannelType::GuildText),
|
|
||||||
..Default::default()
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let guild = bundle
|
|
||||||
.user
|
|
||||||
.gateway
|
|
||||||
.observe_and_into_inner(guild.into_shared())
|
|
||||||
.await;
|
|
||||||
assert!(guild.channels.is_some());
|
|
||||||
assert!(guild.channels.as_ref().unwrap().len() == 1);
|
|
||||||
|
|
||||||
common::teardown(bundle).await
|
common::teardown(bundle).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,28 @@
|
||||||
|
use chorus::errors::ChorusError;
|
||||||
use chorus::ratelimiter::ChorusRequest;
|
use chorus::ratelimiter::ChorusRequest;
|
||||||
|
|
||||||
mod common;
|
mod common;
|
||||||
|
|
||||||
|
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
||||||
|
#[cfg_attr(not(target_arch = "wasm32"), tokio::test)]
|
||||||
|
async fn hit_ratelimit() {
|
||||||
|
let mut bundle = common::setup().await;
|
||||||
|
let mut _count = 0;
|
||||||
|
let guild = bundle.guild.read().unwrap().clone();
|
||||||
|
while _count < 1000 {
|
||||||
|
_count += 1;
|
||||||
|
match guild.channels(&mut bundle.user).await {
|
||||||
|
Err(ChorusError::RateLimited { bucket: _ }) => {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Err(_) => panic!("Hit different rate limit"),
|
||||||
|
_ => continue,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
common::teardown(bundle).await;
|
||||||
|
panic!("Ratelimit never triggered");
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
||||||
#[cfg_attr(not(target_arch = "wasm32"), tokio::test)]
|
#[cfg_attr(not(target_arch = "wasm32"), tokio::test)]
|
||||||
async fn get_limit_config() {
|
async fn get_limit_config() {
|
||||||
|
|
Loading…
Reference in New Issue