|
| 1 | +""" |
| 2 | +Tests for the op-faucet launcher. |
| 3 | +""" |
| 4 | + |
| 5 | +op_faucet_launcher = import_module("/src/faucet/op-faucet/op_faucet_launcher.star") |
| 6 | +input_parser = import_module("/src/package_io/input_parser.star") |
| 7 | +constants = import_module("/src/package_io/constants.star") |
| 8 | + |
| 9 | + |
| 10 | +def test_launch_with_defaults(plan): |
| 11 | + """Test launching the op-faucet service with default parameters.""" |
| 12 | + faucet_image = input_parser.DEFAULT_FAUCET_IMAGES["op-faucet"] |
| 13 | + service_name = "op-faucet" |
| 14 | + |
| 15 | + # Create test faucet data |
| 16 | + faucets = [ |
| 17 | + op_faucet_launcher.faucet_data( |
| 18 | + chain_id="1", |
| 19 | + el_rpc="http://l1-rpc", |
| 20 | + private_key=constants.dev_accounts[0]["private_key"], |
| 21 | + name="l1", |
| 22 | + ), |
| 23 | + op_faucet_launcher.faucet_data( |
| 24 | + chain_id="10", |
| 25 | + el_rpc="http://l2-rpc", |
| 26 | + private_key=constants.dev_accounts[1]["private_key"], |
| 27 | + name="l2", |
| 28 | + ), |
| 29 | + ] |
| 30 | + |
| 31 | + op_faucet_launcher.launch( |
| 32 | + plan=plan, |
| 33 | + service_name=service_name, |
| 34 | + image=faucet_image, |
| 35 | + faucets=faucets, |
| 36 | + ) |
| 37 | + |
| 38 | + # Verify service configuration |
| 39 | + faucet_service_config = kurtosistest.get_service_config(service_name=service_name) |
| 40 | + expect.ne(faucet_service_config, None) |
| 41 | + expect.eq(faucet_service_config.image, faucet_image) |
| 42 | + expect.eq(faucet_service_config.env_vars, {}) |
| 43 | + expect.eq(faucet_service_config.entrypoint, []) |
| 44 | + expect.eq( |
| 45 | + faucet_service_config.cmd, |
| 46 | + [ |
| 47 | + "op-faucet", |
| 48 | + "--rpc.port=9000", |
| 49 | + "--config=/config/config.yaml", |
| 50 | + ], |
| 51 | + ) |
| 52 | + expect.eq(faucet_service_config.ports["rpc"].number, 9000) |
| 53 | + expect.eq(faucet_service_config.ports["rpc"].transport_protocol, "TCP") |
| 54 | + expect.eq(faucet_service_config.ports["rpc"].application_protocol, "http") |
| 55 | + |
| 56 | + |
| 57 | +def test_launch_with_custom_image(plan): |
| 58 | + """Test launching the op-faucet service with a custom image.""" |
| 59 | + custom_image = "custom-op-faucet:latest" |
| 60 | + service_name = "op-faucet" |
| 61 | + |
| 62 | + # Create test faucet data |
| 63 | + faucets = [ |
| 64 | + op_faucet_launcher.faucet_data( |
| 65 | + chain_id="1", |
| 66 | + el_rpc="http://l1-rpc", |
| 67 | + private_key=constants.dev_accounts[0]["private_key"], |
| 68 | + ), |
| 69 | + ] |
| 70 | + |
| 71 | + op_faucet_launcher.launch( |
| 72 | + plan=plan, |
| 73 | + service_name=service_name, |
| 74 | + image=custom_image, |
| 75 | + faucets=faucets, |
| 76 | + ) |
| 77 | + |
| 78 | + # Verify service configuration |
| 79 | + faucet_service_config = kurtosistest.get_service_config(service_name=service_name) |
| 80 | + expect.eq(faucet_service_config.image, custom_image) |
0 commit comments