def generate_validators(powers):
    """Generates an arbitrary number of validators with random public keys.

       The object under the `storage` key is in the format expected by DB.

       The object under the `eleciton` key is in the format expected by
       the upsert validator election.

       `public_key`, `private_key` are in the format used for signing transactions.

       Args:
           powers: A list of intergers representing the voting power to
                   assign to the corresponding validators.
    """
    validators = []
    for power in powers:
        kp = crypto.generate_key_pair()
        validators.append({
            'storage': {
                'public_key': {
                    'value': key_to_base64(base58.b58decode(kp.public_key).hex()),
                    'type': 'ed25519-base64',
                },
                'voting_power': power,
            },
            'election': {
                'node_id': f'node-{random.choice(range(100))}',
                'power': power,
                'public_key': {
                    'value': base64.b16encode(base58.b58decode(kp.public_key)).decode('utf-8'),
                    'type': 'ed25519-base16',
                },
            },
            'public_key': kp.public_key,
            'private_key': kp.private_key,
        })
    return validators
Generates an arbitrary number of validators with random public keys.

The object under the `storage` key is in the format expected by DB.

The object under the `eleciton` key is in the format expected by
the upsert validator election.

`public_key`, `private_key` are in the format used for signing transactions.

Args:
powers: A list of intergers representing the voting power to
assign to the corresponding validators.
tests/utils.py