Skip to content

Commit fd4d814

Browse files
committed
test
1 parent a2112fb commit fd4d814

File tree

5 files changed

+34
-27
lines changed

5 files changed

+34
-27
lines changed

.github/workflows/rust.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ jobs:
127127
run: |
128128
mkdir /tmp/local-linera-net
129129
FAUCET_PORT=$(echo "$LINERA_FAUCET_URL" | cut -d: -f3)
130-
cargo run --bin linera --features kubernetes -- net up --kubernetes --policy-config testnet --path /tmp/local-linera-net --validators 2 --shards 2 --with-faucet --faucet-port $FAUCET_PORT --faucet-amount 1000 &
130+
cargo run --bin linera --features kubernetes -- net up --kubernetes --policy-config testnet --path /tmp/local-linera-net --validators 1 --shards 2 --with-faucet --faucet-port $FAUCET_PORT --faucet-amount 100 &
131131
- name: Wait for faucet to be ready
132132
run: |
133133
until curl -s $LINERA_FAUCET_URL >/dev/null; do sleep 1; done

linera-service/src/cli/net_up_utils.rs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -317,18 +317,23 @@ async fn print_messages_and_create_faucet(
317317

318318
// Run the faucet,
319319
let faucet_service = if with_faucet {
320-
let faucet_chain_idx = faucet_chain.unwrap_or(0);
321-
assert!(
322-
num_other_initial_chains > faucet_chain_idx,
323-
"num_other_initial_chains must be strictly greater than the faucet chain index if \
320+
let faucet_chain = if let Some(faucet_chain_idx) = faucet_chain {
321+
assert!(
322+
num_other_initial_chains > faucet_chain_idx,
323+
"num_other_initial_chains must be strictly greater than the faucet chain index if \
324324
with_faucet is true"
325-
);
326-
// This picks a lexicographically faucet_chain_idx-th non-admin chain.
327-
let faucet_chain = chains
328-
.into_iter()
329-
.filter(|chain_id| *chain_id != wallet.genesis_admin_chain())
330-
.nth(faucet_chain_idx as usize)
331-
.unwrap(); // we checked that there are enough chains above, so this should be safe
325+
);
326+
// This picks a lexicographically faucet_chain_idx-th non-admin chain.
327+
Some(
328+
chains
329+
.into_iter()
330+
.filter(|chain_id| *chain_id != wallet.genesis_admin_chain())
331+
.nth(faucet_chain_idx as usize)
332+
.unwrap(),
333+
) // we checked that there are enough chains above, so this should be safe
334+
} else {
335+
None
336+
};
332337
let service = client
333338
.run_faucet(Some(faucet_port.into()), faucet_chain, faucet_amount)
334339
.await?;

linera-service/src/cli_wrappers/wallet.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -540,17 +540,19 @@ impl ClientWrapper {
540540
pub async fn run_faucet(
541541
&self,
542542
port: impl Into<Option<u16>>,
543-
chain_id: ChainId,
543+
chain_id: Option<ChainId>,
544544
amount: Amount,
545545
) -> Result<FaucetService> {
546546
let port = port.into().unwrap_or(8080);
547547
let mut command = self.command().await?;
548-
let child = command
548+
let command = command
549549
.arg("faucet")
550-
.arg(chain_id.to_string())
551550
.args(["--port".to_string(), port.to_string()])
552-
.args(["--amount".to_string(), amount.to_string()])
553-
.spawn_into()?;
551+
.args(["--amount".to_string(), amount.to_string()]);
552+
if let Some(chain_id) = chain_id {
553+
command.arg(chain_id.to_string());
554+
}
555+
let child = command.spawn_into()?;
554556
let client = reqwest_client();
555557
for i in 0..10 {
556558
linera_base::time::timer::sleep(Duration::from_secs(i)).await;

linera-service/tests/linera_net_tests.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4271,7 +4271,7 @@ async fn test_end_to_end_faucet(config: impl LineraNetConfig) -> Result<()> {
42714271
let owner2 = client2.keygen().await?;
42724272

42734273
let mut faucet_service = client1
4274-
.run_faucet(None, chain1, Amount::from_tokens(2))
4274+
.run_faucet(None, Some(chain1), Amount::from_tokens(2))
42754275
.await?;
42764276
let faucet = faucet_service.instance();
42774277
let chain2 = faucet.claim(&owner2).await?.id();
@@ -4356,7 +4356,7 @@ async fn test_end_to_end_faucet_with_long_chains(config: impl LineraNetConfig) -
43564356

43574357
let new_chain_init_balance = Amount::ONE;
43584358
let mut faucet_service = faucet_client
4359-
.run_faucet(None, faucet_chain, new_chain_init_balance)
4359+
.run_faucet(None, Some(faucet_chain), new_chain_init_balance)
43604360
.await?;
43614361
let faucet = faucet_service.instance();
43624362

@@ -4427,7 +4427,7 @@ async fn test_end_to_end_faucet_batch_processing(config: impl LineraNetConfig) -
44274427

44284428
// Start faucet with small batch size for testing
44294429
let mut faucet_service = client1
4430-
.run_faucet(None, chain1, Amount::from_tokens(2))
4430+
.run_faucet(None, Some(chain1), Amount::from_tokens(2))
44314431
.await?;
44324432
let faucet = faucet_service.instance();
44334433

@@ -4516,7 +4516,7 @@ async fn test_end_to_end_fungible_client_benchmark(config: impl LineraNetConfig)
45164516

45174517
let chain1 = client1.load_wallet()?.default_chain().unwrap();
45184518

4519-
let mut faucet_service = client1.run_faucet(None, chain1, Amount::ONE).await?;
4519+
let mut faucet_service = client1.run_faucet(None, Some(chain1), Amount::ONE).await?;
45204520
let faucet = faucet_service.instance();
45214521

45224522
let path =

linera-service/tests/local_net_tests.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ async fn test_end_to_end_reconfiguration(config: LocalNetConfig) -> Result<()> {
6767
.await?;
6868

6969
let mut faucet_service = faucet_client
70-
.run_faucet(None, faucet_chain, Amount::from_tokens(2))
70+
.run_faucet(None, Some(faucet_chain), Amount::from_tokens(2))
7171
.await?;
7272

7373
faucet_service.ensure_is_running()?;
@@ -284,7 +284,7 @@ async fn test_end_to_end_receipt_of_old_create_committee_messages(
284284

285285
if matches!(network, Network::Grpc) {
286286
let mut faucet_service = faucet_client
287-
.run_faucet(None, faucet_chain, Amount::from_tokens(2))
287+
.run_faucet(None, Some(faucet_chain), Amount::from_tokens(2))
288288
.await?;
289289

290290
faucet_service.ensure_is_running()?;
@@ -327,7 +327,7 @@ async fn test_end_to_end_receipt_of_old_create_committee_messages(
327327
faucet_client.process_inbox(faucet_chain).await?;
328328

329329
let mut faucet_service = faucet_client
330-
.run_faucet(None, faucet_chain, Amount::from_tokens(2))
330+
.run_faucet(None, Some(faucet_chain), Amount::from_tokens(2))
331331
.await?;
332332

333333
faucet_service.ensure_is_running()?;
@@ -381,7 +381,7 @@ async fn test_end_to_end_receipt_of_old_remove_committee_messages(
381381

382382
if matches!(network, Network::Grpc) {
383383
let mut faucet_service = faucet_client
384-
.run_faucet(None, faucet_chain, Amount::from_tokens(2))
384+
.run_faucet(None, Some(faucet_chain), Amount::from_tokens(2))
385385
.await?;
386386

387387
faucet_service.ensure_is_running()?;
@@ -427,7 +427,7 @@ async fn test_end_to_end_receipt_of_old_remove_committee_messages(
427427

428428
if matches!(network, Network::Grpc) {
429429
let mut faucet_service = faucet_client
430-
.run_faucet(None, faucet_chain, Amount::from_tokens(2))
430+
.run_faucet(None, Some(faucet_chain), Amount::from_tokens(2))
431431
.await?;
432432

433433
faucet_service.ensure_is_running()?;
@@ -472,7 +472,7 @@ async fn test_end_to_end_receipt_of_old_remove_committee_messages(
472472
faucet_client.process_inbox(faucet_chain).await?;
473473

474474
let mut faucet_service = faucet_client
475-
.run_faucet(None, faucet_chain, Amount::from_tokens(2))
475+
.run_faucet(None, Some(faucet_chain), Amount::from_tokens(2))
476476
.await?;
477477

478478
faucet_service.ensure_is_running()?;

0 commit comments

Comments
 (0)