Skip to content

Commit

Permalink
[faucet] enhance faucet's concurrent processing ability (MystenLabs#3700
Browse files Browse the repository at this point in the history
)

* concurrency

* fix typo

* get rid of split coin

* metrics

* wrap up
  • Loading branch information
longbowlu authored Aug 5, 2022
1 parent 8ed049e commit 5087a5d
Show file tree
Hide file tree
Showing 8 changed files with 341 additions and 133 deletions.
4 changes: 4 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion crates/sui-faucet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@ serde = { version = "1.0.141", features = ["derive"] }
tower = { version = "0.4.12", features = ["util", "timeout", "load-shed", "limit"] }
tower-http = { version = "0.3.4", features = ["cors"] }
http = { version = "0.2.8" }

futures = "0.3.21"
uuid = {version = "1.1.2", features = [ "v4", "fast-rng"]}
prometheus = "0.13.1"
scopeguard = "1.1"

sui = { path = "../sui" }
sui-node = { path = "../sui-node" }
sui-json-rpc-types= { path = "../sui-json-rpc-types" }
sui-types = { path = "../sui-types" }
sui-config = { path = "../sui-config" }
Expand Down
27 changes: 0 additions & 27 deletions crates/sui-faucet/src/faucet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,30 +52,3 @@ impl From<&SuiParsedObject> for CoinInfo {
}
}
}

#[cfg(test)]
mod tests {
use test_utils::network::setup_network_and_wallet;

use super::*;

#[tokio::test]
async fn simple_faucet_basic_interface_should_work() {
let (_network, context, _address) = setup_network_and_wallet().await.unwrap();
let faucet = SimpleFaucet::new(context).await.unwrap();
test_basic_interface(faucet).await;
}

async fn test_basic_interface(faucet: impl Faucet) {
let recipient = SuiAddress::random_for_testing_only();
let amounts = vec![1, 2, 3];

let FaucetReceipt { sent } = faucet
.send(Uuid::new_v4(), recipient, &amounts)
.await
.unwrap();
let mut actual_amounts: Vec<u64> = sent.iter().map(|c| c.amount).collect();
actual_amounts.sort_unstable();
assert_eq!(actual_amounts, amounts);
}
}
Loading

0 comments on commit 5087a5d

Please sign in to comment.