Skip to content

Commit

Permalink
sui-graphql-client: fix coin stream test (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan-mysten authored Oct 23, 2024
1 parent 86ad4b2 commit dd03025
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 2 additions & 0 deletions crates/sui-graphql-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ tracing = "0.1.40"
tokio = "1.40.0"

[dev-dependencies]
sui-types = { package = "sui-sdk-types", path = "../sui-sdk-types", features = ["serde", "rand", "hash"] }
rand = "0.8.5"
tokio = { version = "1.40.0", features = ["full"] }

[build-dependencies]
Expand Down
15 changes: 13 additions & 2 deletions crates/sui-graphql-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,9 @@ impl Client {
#[cfg(test)]
mod tests {
use futures::StreamExt;
use sui_types::types::Ed25519PublicKey;

use crate::faucet::FaucetClient;
use crate::Client;
use crate::PaginationFilter;
use crate::DEVNET_HOST;
Expand Down Expand Up @@ -1202,8 +1204,17 @@ mod tests {

#[tokio::test]
async fn test_coins_stream() {
let client = Client::new_testnet();
let mut stream = client.coins_stream("0x1".parse().unwrap(), None);
let client = test_client();
let faucet = match client.rpc_server() {
LOCAL_HOST => FaucetClient::local(),
TESTNET_HOST => FaucetClient::testnet(),
DEVNET_HOST => FaucetClient::devnet(),
_ => return,
};
let key = Ed25519PublicKey::generate(rand::thread_rng());
let address = key.to_address();
faucet.request_and_wait(address).await.unwrap();
let mut stream = client.coins_stream(address, None);
let mut num_coins = 0;
while let Some(result) = stream.next().await {
assert!(result.is_ok());
Expand Down

0 comments on commit dd03025

Please sign in to comment.