-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
105 additions
and
4 deletions.
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
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
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
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,50 @@ | ||
use fuel_core::{ | ||
chain_config::StateConfig, | ||
service::{ | ||
Config, | ||
FuelService, | ||
}, | ||
}; | ||
use fuel_core_client::client::{ | ||
types::primitives::{ | ||
Address, | ||
AssetId, | ||
}, | ||
FuelClient, | ||
}; | ||
|
||
#[tokio::test] | ||
async fn balance_with_block_height_header() { | ||
let owner = Address::default(); | ||
let asset_id = AssetId::BASE; | ||
|
||
// setup config | ||
let state_config = StateConfig::default(); | ||
let config = Config::local_node_with_state_config(state_config); | ||
|
||
// setup server & client | ||
let srv = FuelService::new_node(config).await.unwrap(); | ||
let client = FuelClient::from(srv.bound_address); | ||
|
||
// Issue a request with wrong precondition | ||
let error = client | ||
.balance_with_required_block_header(&owner, Some(&asset_id), 100) | ||
.await | ||
.unwrap_err(); | ||
|
||
let error_str = format!("{:?}", error); | ||
assert_eq!( | ||
error_str, | ||
"Custom { kind: Other, error: ErrorResponse(412, \"\") }" | ||
); | ||
|
||
// Meet precondition on server side | ||
client.produce_blocks(100, None).await.unwrap(); | ||
|
||
// Issue request again | ||
let result = client | ||
.balance_with_required_block_header(&owner, Some(&asset_id), 100) | ||
.await; | ||
|
||
assert!(result.is_ok()); | ||
} |