fn create_operator_with_file_writer(file_writer: fn(&Ed25519PublicKey, PathBuf)) {
    let (env, op_tool, _, _) = launch_swarm_with_op_tool_and_backend(1, 0);

    // Create a new operator key and account
    let (operator_key, operator_account) = create_new_test_account();

    // Verify the corresponding account doesn't exist on-chain
    let libra_json_rpc = get_json_rpc_libra_interface(&env.validator_swarm, 0);
    libra_json_rpc
        .retrieve_account_state(operator_account)
        .unwrap_err();

    // Write the key to a file using the provided file writer
    let key_file_path = write_key_to_file(&operator_key.public_key(), &env, file_writer);

    // Create the operator account
    let backend = load_libra_root_storage(&env.validator_swarm, 0);
    let op_human_name = "new_operator";
    let (txn_ctx, account_address) = op_tool
        .create_validator_operator(op_human_name, key_file_path.to_str().unwrap(), &backend)
        .unwrap();
    assert_eq!(operator_account, account_address);

    // Wait for the create operator transaction to be executed
    let mut client = env.get_validator_client(0, None);
    client
        .wait_for_transaction(txn_ctx.address, txn_ctx.sequence_number + 1)
        .unwrap();

    // Verify the operator account now exists on-chain
    let account_state = libra_json_rpc
        .retrieve_account_state(operator_account)
        .unwrap();
    let op_config_resource = account_state
        .get_validator_operator_config_resource()
        .unwrap()
        .unwrap();
    assert_eq!(op_human_name.as_bytes(), op_config_resource.human_name);
}
/// Creates a new validator operator using the given file writer and verifies
/// the operator account is correctly initialized on-chain.
Creates a new validator operator using the given file writer and verifies
the operator account is correctly initialized on-chain.
Creates a new validator operator using the given file writer and verifies the operator account is correctly initialized on - chain .
fn create_operator_with_file_writer(file_writer: fn(&Ed25519PublicKey, PathBuf)) {
    let (env, op_tool, _, _) = launch_swarm_with_op_tool_and_backend(1, 0);
    // Create a new operator key and account
    let (operator_key, operator_account) = create_new_test_account();
    // Verify the corresponding account doesn't exist on-chain
    let libra_json_rpc = get_json_rpc_libra_interface(&env.validator_swarm, 0);
    libra_json_rpc
        .retrieve_account_state(operator_account)
        .unwrap_err();
    // Write the key to a file using the provided file writer
    let key_file_path = write_key_to_file(&operator_key.public_key(), &env, file_writer);
    // Create the operator account
    let backend = load_libra_root_storage(&env.validator_swarm, 0);
    let op_human_name = "new_operator";
    let (txn_ctx, account_address) = op_tool
        .create_validator_operator(op_human_name, key_file_path.to_str().unwrap(), &backend)
        .unwrap();
    assert_eq!(operator_account, account_address);
    // Wait for the create operator transaction to be executed
    let mut client = env.get_validator_client(0, None);
    client
        .wait_for_transaction(txn_ctx.address, txn_ctx.sequence_number + 1)
        .unwrap();
    // Verify the operator account now exists on-chain
    let account_state = libra_json_rpc
        .retrieve_account_state(operator_account)
        .unwrap();
    let op_config_resource = account_state
        .get_validator_operator_config_resource()
        .unwrap()
        .unwrap();
    assert_eq!(op_human_name.as_bytes(), op_config_resource.human_name);
}
fn create_operator_with_file_writer ( file_writer : fn ( & Ed25519PublicKey , PathBuf ) ) { let ( env , op_tool , _ , _ ) = launch_swarm_with_op_tool_and_backend ( 1 , 0 ) ; // Create a new operator key and account let ( operator_key , operator_account ) = create_new_test_account ( ) ; // Verify the corresponding account doesn't exist on-chain let libra_json_rpc = get_json_rpc_libra_interface ( & env . validator_swarm , 0 ) ; libra_json_rpc . retrieve_account_state ( operator_account ) . unwrap_err ( ) ; // Write the key to a file using the provided file writer let key_file_path = write_key_to_file ( & operator_key . public_key ( ) , & env , file_writer ) ; // Create the operator account let backend = load_libra_root_storage ( & env . validator_swarm , 0 ) ; let op_human_name = " " ; let ( txn_ctx , account_address ) = op_tool . create_validator_operator ( op_human_name , key_file_path . to_str ( ) . unwrap ( ) , & backend ) . unwrap ( ) ; assert_eq ! ( operator_account account_address ) ; // Wait for the create operator transaction to be executed let mut client = env . get_validator_client ( 0 , None ) ; client . wait_for_transaction ( txn_ctx . address , txn_ctx . sequence_number + 1 ) . unwrap ( ) ; // Verify the operator account now exists on-chain let account_state = libra_json_rpc . retrieve_account_state ( operator_account ) . unwrap ( ) ; let op_config_resource = account_state . get_validator_operator_config_resource ( ) . unwrap ( ) . unwrap ( ) ; assert_eq ! ( op_human_name as_bytes ( ) op_config_resource human_name ) ; }
Creates a new validator operator using the given file writer and verifies
the operator account is correctly initialized on-chain.
Creates a new validator operator using the given file writer and verifies the operator account is correctly initialized on - chain .
file_writer
fn(&Ed25519PublicKey, PathBuf)
file_writer
fn(&Ed25519PublicKey, PathBuf)