CLI: Expose Durable Nonce Authorize instruction (#7541)

* CLI: Expose Durable Nonce `Authorize` instruction

* fmt
This commit is contained in:
Trent Nelson
2019-12-19 19:13:01 -05:00
committed by GitHub
parent 0ae7e86fcb
commit 37eaa6e4f9
3 changed files with 171 additions and 4 deletions

View File

@ -174,4 +174,47 @@ fn full_battery_tests(
use_lamports_unit: true,
};
process_command(&config_payer).unwrap();
// Set new authority
let new_authority = Keypair::new();
let (new_authority_keypair_file, mut tmp_file) = make_tmp_file();
write_keypair(&new_authority, tmp_file.as_file_mut()).unwrap();
config_payer.command = CliCommand::AuthorizeNonceAccount {
nonce_account: read_keypair_file(&nonce_keypair_file).unwrap().pubkey(),
nonce_authority: read_keypair_file(&authority_keypair_file).unwrap().into(),
new_authority: read_keypair_file(&new_authority_keypair_file)
.unwrap()
.pubkey(),
};
process_command(&config_payer).unwrap();
// Old authority fails now
config_payer.command = CliCommand::NewNonce {
nonce_account: read_keypair_file(&nonce_keypair_file).unwrap().pubkey(),
nonce_authority: read_keypair_file(&authority_keypair_file).unwrap().into(),
};
process_command(&config_payer).unwrap_err();
// New authority can advance nonce
config_payer.command = CliCommand::NewNonce {
nonce_account: read_keypair_file(&nonce_keypair_file).unwrap().pubkey(),
nonce_authority: read_keypair_file(&new_authority_keypair_file)
.unwrap()
.into(),
};
process_command(&config_payer).unwrap();
// New authority can withdraw from nonce account
config_payer.command = CliCommand::WithdrawFromNonceAccount {
nonce_account: read_keypair_file(&nonce_keypair_file).unwrap().pubkey(),
nonce_authority: read_keypair_file(&new_authority_keypair_file)
.unwrap()
.into(),
destination_account_pubkey: payee_pubkey,
lamports: 100,
};
process_command(&config_payer).unwrap();
check_balance(1000, &rpc_client, &config_payer.keypair.pubkey());
check_balance(800, &rpc_client, &config_nonce.keypair.pubkey());
check_balance(200, &rpc_client, &payee_pubkey);
}