unfork dalek ed25519 (#6776)
This commit is contained in:
@ -43,6 +43,28 @@ use std::{
|
||||
|
||||
const USERDATA_CHUNK_SIZE: usize = 229; // Keep program chunks under PACKET_DATA_SIZE
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct KeypairEq(Keypair);
|
||||
|
||||
impl From<Keypair> for KeypairEq {
|
||||
fn from(keypair: Keypair) -> Self {
|
||||
Self(keypair)
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for KeypairEq {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.pubkey() == other.pubkey()
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::Deref for KeypairEq {
|
||||
type Target = Keypair;
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum CliCommand {
|
||||
@ -66,7 +88,7 @@ pub enum CliCommand {
|
||||
Deploy(String),
|
||||
// Stake Commands
|
||||
CreateStakeAccount {
|
||||
stake_account: Keypair,
|
||||
stake_account: KeypairEq,
|
||||
staker: Option<Pubkey>,
|
||||
withdrawer: Option<Pubkey>,
|
||||
lockup: Lockup,
|
||||
@ -87,7 +109,7 @@ pub enum CliCommand {
|
||||
// Storage Commands
|
||||
CreateStorageAccount {
|
||||
account_owner: Pubkey,
|
||||
storage_account: Keypair,
|
||||
storage_account: KeypairEq,
|
||||
account_type: StorageAccountType,
|
||||
},
|
||||
ClaimStorageReward {
|
||||
@ -104,7 +126,7 @@ pub enum CliCommand {
|
||||
},
|
||||
// Vote Commands
|
||||
CreateVoteAccount {
|
||||
vote_account: Keypair,
|
||||
vote_account: KeypairEq,
|
||||
node_pubkey: Pubkey,
|
||||
authorized_voter: Option<Pubkey>,
|
||||
authorized_withdrawer: Option<Pubkey>,
|
||||
@ -1796,7 +1818,7 @@ mod tests {
|
||||
let bob_pubkey = bob_keypair.pubkey();
|
||||
let node_pubkey = Pubkey::new_rand();
|
||||
config.command = CliCommand::CreateVoteAccount {
|
||||
vote_account: bob_keypair,
|
||||
vote_account: bob_keypair.into(),
|
||||
node_pubkey,
|
||||
authorized_voter: Some(bob_pubkey),
|
||||
authorized_withdrawer: Some(bob_pubkey),
|
||||
@ -1815,7 +1837,7 @@ mod tests {
|
||||
let bob_pubkey = bob_keypair.pubkey();
|
||||
let custodian = Pubkey::new_rand();
|
||||
config.command = CliCommand::CreateStakeAccount {
|
||||
stake_account: bob_keypair,
|
||||
stake_account: bob_keypair.into(),
|
||||
staker: None,
|
||||
withdrawer: None,
|
||||
lockup: Lockup { slot: 0, custodian },
|
||||
@ -1961,7 +1983,7 @@ mod tests {
|
||||
|
||||
let bob_keypair = Keypair::new();
|
||||
config.command = CliCommand::CreateVoteAccount {
|
||||
vote_account: bob_keypair,
|
||||
vote_account: bob_keypair.into(),
|
||||
node_pubkey,
|
||||
authorized_voter: Some(bob_pubkey),
|
||||
authorized_withdrawer: Some(bob_pubkey),
|
||||
|
@ -125,14 +125,17 @@ mod tests {
|
||||
let matches = app()
|
||||
.clone()
|
||||
.get_matches_from(vec!["test", "--single", &outfile]);
|
||||
assert_eq!(keypair_of(&matches, "single"), Some(keypair));
|
||||
assert_eq!(keypair_of(&matches, "multiple"), None);
|
||||
assert_eq!(
|
||||
keypair_of(&matches, "single").unwrap().pubkey(),
|
||||
keypair.pubkey()
|
||||
);
|
||||
assert!(keypair_of(&matches, "multiple").is_none());
|
||||
|
||||
let matches =
|
||||
app()
|
||||
.clone()
|
||||
.get_matches_from(vec!["test", "--single", "random_keypair_file.json"]);
|
||||
assert_eq!(keypair_of(&matches, "single"), None);
|
||||
assert!(keypair_of(&matches, "single").is_none());
|
||||
|
||||
fs::remove_file(&outfile).unwrap();
|
||||
}
|
||||
|
@ -283,7 +283,7 @@ pub fn parse_stake_create_account(matches: &ArgMatches<'_>) -> Result<CliCommand
|
||||
|
||||
Ok(CliCommandInfo {
|
||||
command: CliCommand::CreateStakeAccount {
|
||||
stake_account,
|
||||
stake_account: stake_account.into(),
|
||||
staker,
|
||||
withdrawer,
|
||||
lockup: Lockup { custodian, slot },
|
||||
@ -788,7 +788,7 @@ mod tests {
|
||||
parse_command(&test_create_stake_account).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::CreateStakeAccount {
|
||||
stake_account: stake_account_keypair,
|
||||
stake_account: stake_account_keypair.into(),
|
||||
staker: Some(authorized),
|
||||
withdrawer: Some(authorized),
|
||||
lockup: Lockup {
|
||||
@ -819,7 +819,7 @@ mod tests {
|
||||
parse_command(&test_create_stake_account2).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::CreateStakeAccount {
|
||||
stake_account: stake_account_keypair,
|
||||
stake_account: stake_account_keypair.into(),
|
||||
staker: None,
|
||||
withdrawer: None,
|
||||
lockup: Lockup {
|
||||
|
@ -107,7 +107,7 @@ pub fn parse_storage_create_archiver_account(
|
||||
Ok(CliCommandInfo {
|
||||
command: CliCommand::CreateStorageAccount {
|
||||
account_owner,
|
||||
storage_account,
|
||||
storage_account: storage_account.into(),
|
||||
account_type: StorageAccountType::Archiver,
|
||||
},
|
||||
require_keypair: true,
|
||||
@ -122,7 +122,7 @@ pub fn parse_storage_create_validator_account(
|
||||
Ok(CliCommandInfo {
|
||||
command: CliCommand::CreateStorageAccount {
|
||||
account_owner,
|
||||
storage_account,
|
||||
storage_account: storage_account.into(),
|
||||
account_type: StorageAccountType::Validator,
|
||||
},
|
||||
require_keypair: true,
|
||||
@ -257,7 +257,7 @@ mod tests {
|
||||
CliCommandInfo {
|
||||
command: CliCommand::CreateStorageAccount {
|
||||
account_owner: pubkey,
|
||||
storage_account: storage_account_keypair,
|
||||
storage_account: storage_account_keypair.into(),
|
||||
account_type: StorageAccountType::Archiver,
|
||||
},
|
||||
require_keypair: true
|
||||
@ -281,7 +281,7 @@ mod tests {
|
||||
CliCommandInfo {
|
||||
command: CliCommand::CreateStorageAccount {
|
||||
account_owner: pubkey,
|
||||
storage_account: storage_account_keypair,
|
||||
storage_account: storage_account_keypair.into(),
|
||||
account_type: StorageAccountType::Validator,
|
||||
},
|
||||
require_keypair: true
|
||||
|
@ -170,7 +170,7 @@ pub fn parse_vote_create_account(matches: &ArgMatches<'_>) -> Result<CliCommandI
|
||||
|
||||
Ok(CliCommandInfo {
|
||||
command: CliCommand::CreateVoteAccount {
|
||||
vote_account,
|
||||
vote_account: vote_account.into(),
|
||||
node_pubkey,
|
||||
authorized_voter,
|
||||
authorized_withdrawer,
|
||||
@ -479,7 +479,7 @@ mod tests {
|
||||
parse_command(&test_create_vote_account).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::CreateVoteAccount {
|
||||
vote_account: keypair,
|
||||
vote_account: keypair.into(),
|
||||
node_pubkey,
|
||||
authorized_voter: None,
|
||||
authorized_withdrawer: None,
|
||||
@ -503,7 +503,7 @@ mod tests {
|
||||
parse_command(&test_create_vote_account2).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::CreateVoteAccount {
|
||||
vote_account: keypair,
|
||||
vote_account: keypair.into(),
|
||||
node_pubkey,
|
||||
authorized_voter: None,
|
||||
authorized_withdrawer: None,
|
||||
@ -531,7 +531,7 @@ mod tests {
|
||||
parse_command(&test_create_vote_account3).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::CreateVoteAccount {
|
||||
vote_account: keypair,
|
||||
vote_account: keypair.into(),
|
||||
node_pubkey,
|
||||
authorized_voter: Some(authed),
|
||||
authorized_withdrawer: None,
|
||||
@ -557,7 +557,7 @@ mod tests {
|
||||
parse_command(&test_create_vote_account4).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::CreateVoteAccount {
|
||||
vote_account: keypair,
|
||||
vote_account: keypair.into(),
|
||||
node_pubkey,
|
||||
authorized_voter: None,
|
||||
authorized_withdrawer: Some(authed),
|
||||
|
Reference in New Issue
Block a user