-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
114 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
use crate::common::{data, startup::{db::DbBuilder, quick_start, server::ServerBootstrapper}}; | ||
use assert_fs::TempDir; | ||
use reqwest::StatusCode; | ||
|
||
#[test] | ||
pub fn get_funds_list_is_not_empty() { | ||
let temp_dir = TempDir::new().unwrap(); | ||
let (server, hash) = quick_start(&temp_dir); | ||
let funds = server | ||
.rest_client_with_token(hash) | ||
.funds() | ||
.expect("cannot get funds"); | ||
assert!(funds.len() > 0); | ||
} | ||
|
||
|
||
#[test] | ||
pub fn get_funds_by_id() -> Result<(), Box<dyn std::error::Error>>{ | ||
let temp_dir = TempDir::new().unwrap().into_persistent(); | ||
let expected_fund = data::funds().first().unwrap().clone(); | ||
let (token, hash) = data::token(); | ||
|
||
let db_path = DbBuilder::new() | ||
.with_token(token) | ||
.with_funds(vec![expected_fund.clone()]) | ||
.build(&temp_dir)?; | ||
|
||
let server = ServerBootstrapper::new() | ||
.with_db_path(db_path.to_str().unwrap()) | ||
.start()?; | ||
|
||
let rest_client = server.rest_client_with_token(hash); | ||
|
||
let actual_fund = rest_client.fund(&expected_fund.id.to_string())?; | ||
assert_eq!(actual_fund,expected_fund); | ||
|
||
// non existing | ||
assert_eq!(rest_client.fund_raw("2")?.status(), StatusCode::NOT_FOUND); | ||
// malformed index | ||
assert_eq!(rest_client.fund_raw("a")?.status(), StatusCode::NOT_FOUND); | ||
// overflow index | ||
assert_eq!(rest_client.fund_raw("3147483647")?.status(), StatusCode::NOT_FOUND); | ||
|
||
Ok(()) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
|
||
use crate::common::{data, startup::{db::DbBuilder, server::ServerBootstrapper}}; | ||
use assert_fs::TempDir; | ||
|
||
use crate::common::paths::BLOCK0_BIN; | ||
|
||
#[test] | ||
pub fn genesis_deserialize_bijection() { | ||
let temp_dir = TempDir::new().unwrap(); | ||
let (token, hash) = data::token(); | ||
|
||
let db_path = DbBuilder::new() | ||
.with_token(token) | ||
.build(&temp_dir) | ||
.unwrap(); | ||
|
||
let server = ServerBootstrapper::new() | ||
.with_db_path(db_path.to_str().unwrap()) | ||
.with_block0_path(BLOCK0_BIN) | ||
.start() | ||
.unwrap(); | ||
|
||
let expected = std::fs::read(BLOCK0_BIN).unwrap(); | ||
|
||
|
||
let genesis_as_bytes = server | ||
.rest_client_with_token(hash) | ||
.genesis() | ||
.expect("cannot get genesis block bytes"); | ||
|
||
assert_eq!(expected,genesis_as_bytes); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
pub mod proposals; | ||
pub mod genesis; | ||
pub mod funds; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters