Skip to content

Commit

Permalink
add matrix room test
Browse files Browse the repository at this point in the history
  • Loading branch information
paulormart committed Oct 30, 2024
1 parent effa45b commit e682717
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ fn default_matrix_network_report_epoch_rate() -> u32 {
6
}

/// provides default value for matrix_bot_user if ONET_MATRIX_BOT_USER env var is not set
fn default_matrix_bot_user() -> String {
"@some-bot-handle:matrix.org".to_string()
}

/// provides default value for callout_epoch_rate if ONET_EPOCH_RATE_THRESHOLD env var is not set
fn default_epoch_rate_threshold() -> u32 {
0
Expand Down Expand Up @@ -292,7 +297,7 @@ pub struct Config {
pub matrix_callout_epoch_rate: u32,
#[serde(default = "default_matrix_network_report_epoch_rate")]
pub matrix_network_report_epoch_rate: u32,
#[serde(default)]
#[serde(default = "default_matrix_bot_user")]
pub matrix_bot_user: String,
#[serde(default)]
pub matrix_bot_password: String,
Expand Down
16 changes: 16 additions & 0 deletions src/matrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1599,3 +1599,19 @@ impl Matrix {
// }
// }
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn it_defines_a_matrix_room() {
let config = &CONFIG;
assert_eq!(config.matrix_bot_user, "@some-bot-handle:matrix.org".to_string());
let user_id = "@ematest:matrix.org";
let chain = SupportedRuntime::Polkadot;
let room: Room = Room::new_private(chain, user_id);
assert_eq!(room.room_alias, "#b25ldC9Qb2xrYWRvdC9AZW1hdGVzdDptYXRyaXgub3JnL0Bzb21lLWJvdC1oYW5kbGU6bWF0cml4Lm9yZw==:matrix.org".to_string());
}

}

0 comments on commit e682717

Please sign in to comment.