async def _main( logger: logging.Logger, config: Config, arguments: argparse.Namespace ) -> None: key_store = KeyStore.from_config(config) clock = Clock.from_config(config) beacon_node = BeaconNode.from_config(config) # with key_store.persistence(): async with beacon_node: client = Client(key_store, clock, beacon_node) async with background_trio_service(client): await _wait_for_interrupts() logger.info("received interrupt; shutting down...")
def test_key_store_can_persist_key_files(tmp_path, sample_bls_key_pair): config = Config( key_store_constructor=lambda config: KeyStore.from_config(config), root_data_dir=tmp_path, ) some_password = b"password" public_key, private_key = sample_bls_key_pair private_key_bytes = private_key.to_bytes(length=32, byteorder="big") encoded_private_key = private_key_bytes.hex() with config.key_store as key_store: assert not tuple(key_store._location.iterdir()) key_store.import_private_key(encoded_private_key, some_password) key_files = tuple(key_store._location.iterdir()) assert len(key_files) == 1 key_file = key_files[0] with open(key_file) as key_file_handle: key_file_json = json.load(key_file_handle) assert decode_hex(key_file_json["public_key"]) == public_key assert private_key_bytes == eth_keyfile.decode_keyfile_json( key_file_json, some_password)