Unit test for what's done of the open invite protocol so far
This commit is contained in:
parent
e9267f5b37
commit
75630d3ad0
|
@ -236,3 +236,44 @@ impl BridgeAuth {
|
||||||
|
|
||||||
// The protocol modules
|
// The protocol modules
|
||||||
pub mod open_invite;
|
pub mod open_invite;
|
||||||
|
|
||||||
|
// Unit tests that require access to the testing-only function
|
||||||
|
// BridgeLine::random()
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::bridge_table::BridgeLine;
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_open_invite() {
|
||||||
|
// Create a BridegDb
|
||||||
|
let bdb = BridgeDb::new(20);
|
||||||
|
// Create a BridgeAuth
|
||||||
|
let mut ba = BridgeAuth::new(bdb.pubkey);
|
||||||
|
|
||||||
|
// Make 20 buckets with one random bridge each
|
||||||
|
for _ in 0..20 {
|
||||||
|
let bucket: [BridgeLine; 3] =
|
||||||
|
[BridgeLine::random(), Default::default(), Default::default()];
|
||||||
|
ba.bridge_table.new_bucket(bucket);
|
||||||
|
}
|
||||||
|
// And 20 more with three random bridges each
|
||||||
|
for _ in 0..20 {
|
||||||
|
let bucket: [BridgeLine; 3] = [
|
||||||
|
BridgeLine::random(),
|
||||||
|
BridgeLine::random(),
|
||||||
|
BridgeLine::random(),
|
||||||
|
];
|
||||||
|
ba.bridge_table.new_bucket(bucket);
|
||||||
|
}
|
||||||
|
// Create the encrypted bridge table
|
||||||
|
ba.bridge_table.encrypt_table();
|
||||||
|
|
||||||
|
// Issue an open invitation
|
||||||
|
let inv = bdb.invite();
|
||||||
|
|
||||||
|
// Use it to get a Lox credential
|
||||||
|
let (req, state) = open_invite::request(&inv);
|
||||||
|
let resp = ba.handle_open_invite(req);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue