Add keypair gen fn for testing
This commit is contained in:
parent
ff3795dbf0
commit
707f116344
@ -17,8 +17,10 @@ impl ValidatorRecord {
|
|||||||
withdrawal_address: Address,
|
withdrawal_address: Address,
|
||||||
randao_commitment: Sha256Digest,
|
randao_commitment: Sha256Digest,
|
||||||
balance: u64,
|
balance: u64,
|
||||||
switch_dynasty: u64) -> ValidatorRecord {
|
switch_dynasty: u64)
|
||||||
ValidatorRecord {
|
-> Self
|
||||||
|
{
|
||||||
|
Self {
|
||||||
pubkey: pubkey,
|
pubkey: pubkey,
|
||||||
withdrawal_shard: withdrawal_shard,
|
withdrawal_shard: withdrawal_shard,
|
||||||
withdrawal_address: withdrawal_address,
|
withdrawal_address: withdrawal_address,
|
||||||
@ -50,20 +52,12 @@ mod tests {
|
|||||||
extern crate rand;
|
extern crate rand;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use super::super::utils::bls::Keypair;
|
use super::super::
|
||||||
use self::rand::{ SeedableRng, XorShiftRng };
|
utils::test_helpers::get_dangerous_test_keypair;
|
||||||
|
|
||||||
fn get_keypair() -> Keypair {
|
|
||||||
let mut rng = XorShiftRng::from_seed([0xbc4f6d44,
|
|
||||||
0xd62f276c,
|
|
||||||
0xb963afd0,
|
|
||||||
0x5455863d]);
|
|
||||||
Keypair::generate(&mut rng)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_new() {
|
fn test_new() {
|
||||||
let keypair = get_keypair();;
|
let keypair = get_dangerous_test_keypair();;
|
||||||
let withdrawal_shard = 1;
|
let withdrawal_shard = 1;
|
||||||
let withdrawal_address = Address::random();
|
let withdrawal_address = Address::random();
|
||||||
let randao_commitment = Sha256Digest::random();
|
let randao_commitment = Sha256Digest::random();
|
||||||
@ -88,7 +82,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_serialization() {
|
fn test_serialization() {
|
||||||
let keypair = get_keypair();
|
let keypair = get_dangerous_test_keypair();
|
||||||
let v = ValidatorRecord {
|
let v = ValidatorRecord {
|
||||||
pubkey: keypair.public,
|
pubkey: keypair.public,
|
||||||
withdrawal_shard: 100,
|
withdrawal_shard: 100,
|
||||||
|
@ -7,3 +7,4 @@ use super::state::crystallized_state;
|
|||||||
|
|
||||||
pub mod types;
|
pub mod types;
|
||||||
pub mod bls;
|
pub mod bls;
|
||||||
|
pub mod test_helpers;
|
||||||
|
13
src/utils/test_helpers.rs
Normal file
13
src/utils/test_helpers.rs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
extern crate rand;
|
||||||
|
|
||||||
|
use super::bls::Keypair;
|
||||||
|
use self::rand::{ SeedableRng, XorShiftRng };
|
||||||
|
|
||||||
|
// Returns a keypair for use in testing purposes.
|
||||||
|
pub fn get_dangerous_test_keypair() -> Keypair {
|
||||||
|
let mut rng = XorShiftRng::from_seed([0xbc4f6d44,
|
||||||
|
0xd62f276c,
|
||||||
|
0xb963afd0,
|
||||||
|
0x5455863d]);
|
||||||
|
Keypair::generate(&mut rng)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user