Replace transaction traits with structs
Also: * SystemTransaction::new -> new_account * SystemTransaction::new_create -> new_program_account
This commit is contained in:
@ -313,7 +313,7 @@ mod test {
|
||||
let contract = Keypair::new().pubkey();
|
||||
let to = Keypair::new().pubkey();
|
||||
let witness = Keypair::new().pubkey();
|
||||
let tx = Transaction::budget_new_when_signed(
|
||||
let tx = BudgetTransaction::new_when_signed(
|
||||
&from,
|
||||
to,
|
||||
contract,
|
||||
@ -326,7 +326,7 @@ mod test {
|
||||
|
||||
// Attack! Part 1: Sign a witness transaction with a random key.
|
||||
let rando = Keypair::new();
|
||||
let mut tx = Transaction::budget_new_signature(&rando, contract, to, Hash::default());
|
||||
let mut tx = BudgetTransaction::new_signature(&rando, contract, to, Hash::default());
|
||||
|
||||
// Attack! Part 2: Point the instruction to the expected, but unsigned, key.
|
||||
tx.account_keys.push(from.pubkey());
|
||||
@ -352,7 +352,7 @@ mod test {
|
||||
let contract = Keypair::new().pubkey();
|
||||
let to = Keypair::new().pubkey();
|
||||
let dt = Utc::now();
|
||||
let tx = Transaction::budget_new_on_date(
|
||||
let tx = BudgetTransaction::new_on_date(
|
||||
&from,
|
||||
to,
|
||||
contract,
|
||||
@ -366,7 +366,7 @@ mod test {
|
||||
|
||||
// Attack! Part 1: Sign a timestamp transaction with a random key.
|
||||
let rando = Keypair::new();
|
||||
let mut tx = Transaction::budget_new_timestamp(&rando, contract, to, dt, Hash::default());
|
||||
let mut tx = BudgetTransaction::new_timestamp(&rando, contract, to, dt, Hash::default());
|
||||
|
||||
// Attack! Part 2: Point the instruction to the expected, but unsigned, key.
|
||||
tx.account_keys.push(from.pubkey());
|
||||
@ -394,7 +394,7 @@ mod test {
|
||||
let to = Keypair::new();
|
||||
let rando = Keypair::new();
|
||||
let dt = Utc::now();
|
||||
let tx = Transaction::budget_new_on_date(
|
||||
let tx = BudgetTransaction::new_on_date(
|
||||
&from,
|
||||
to.pubkey(),
|
||||
contract.pubkey(),
|
||||
@ -411,7 +411,7 @@ mod test {
|
||||
assert!(program.is_pending());
|
||||
|
||||
// Attack! Try to payout to a rando key
|
||||
let tx = Transaction::budget_new_timestamp(
|
||||
let tx = BudgetTransaction::new_timestamp(
|
||||
&from,
|
||||
contract.pubkey(),
|
||||
rando.pubkey(),
|
||||
@ -431,7 +431,7 @@ mod test {
|
||||
|
||||
// Now, acknowledge the time in the condition occurred and
|
||||
// that pubkey's funds are now available.
|
||||
let tx = Transaction::budget_new_timestamp(
|
||||
let tx = BudgetTransaction::new_timestamp(
|
||||
&from,
|
||||
contract.pubkey(),
|
||||
to.pubkey(),
|
||||
@ -469,7 +469,7 @@ mod test {
|
||||
let contract = Keypair::new();
|
||||
let to = Keypair::new();
|
||||
let dt = Utc::now();
|
||||
let tx = Transaction::budget_new_on_date(
|
||||
let tx = BudgetTransaction::new_on_date(
|
||||
&from,
|
||||
to.pubkey(),
|
||||
contract.pubkey(),
|
||||
@ -487,7 +487,7 @@ mod test {
|
||||
|
||||
// Attack! try to put the tokens into the wrong account with cancel
|
||||
let tx =
|
||||
Transaction::budget_new_signature(&to, contract.pubkey(), to.pubkey(), Hash::default());
|
||||
BudgetTransaction::new_signature(&to, contract.pubkey(), to.pubkey(), Hash::default());
|
||||
// unit test hack, the `from account` is passed instead of the `to` account to avoid
|
||||
// creating more account vectors
|
||||
process_transaction(&tx, &mut accounts).unwrap();
|
||||
@ -498,7 +498,7 @@ mod test {
|
||||
assert_eq!(accounts[pay_account].tokens, 0);
|
||||
|
||||
// Now, cancel the transaction. from gets her funds back
|
||||
let tx = Transaction::budget_new_signature(
|
||||
let tx = BudgetTransaction::new_signature(
|
||||
&from,
|
||||
contract.pubkey(),
|
||||
from.pubkey(),
|
||||
@ -510,7 +510,7 @@ mod test {
|
||||
assert_eq!(accounts[pay_account].tokens, 1);
|
||||
|
||||
// try to replay the signature contract
|
||||
let tx = Transaction::budget_new_signature(
|
||||
let tx = BudgetTransaction::new_signature(
|
||||
&from,
|
||||
contract.pubkey(),
|
||||
from.pubkey(),
|
||||
@ -535,7 +535,7 @@ mod test {
|
||||
let from = Keypair::new();
|
||||
let contract = Keypair::new();
|
||||
let to = Keypair::new();
|
||||
let tx = Transaction::budget_new_on_date(
|
||||
let tx = BudgetTransaction::new_on_date(
|
||||
&from,
|
||||
to.pubkey(),
|
||||
contract.pubkey(),
|
||||
@ -549,7 +549,7 @@ mod test {
|
||||
assert!(process_transaction(&tx, &mut accounts).is_err());
|
||||
assert!(BudgetProgram::deserialize(&accounts[1].userdata).is_err());
|
||||
|
||||
let tx = Transaction::budget_new_timestamp(
|
||||
let tx = BudgetTransaction::new_timestamp(
|
||||
&from,
|
||||
contract.pubkey(),
|
||||
to.pubkey(),
|
||||
|
@ -242,7 +242,7 @@ mod test {
|
||||
keyed_accounts.push(KeyedAccount::new(&pubkey, true, &mut user_account));
|
||||
keyed_accounts.push(KeyedAccount::new(&system_key, false, &mut system_account));
|
||||
|
||||
let tx = Transaction::storage_new_advertise_last_id(
|
||||
let tx = StorageTransaction::new_advertise_last_id(
|
||||
&keypair,
|
||||
Hash::default(),
|
||||
Hash::default(),
|
||||
@ -260,7 +260,7 @@ mod test {
|
||||
let keypair = Keypair::new();
|
||||
let mut accounts = [Default::default()];
|
||||
|
||||
let tx = Transaction::storage_new_mining_proof(
|
||||
let tx = StorageTransaction::new_mining_proof(
|
||||
&keypair,
|
||||
Hash::default(),
|
||||
Hash::default(),
|
||||
@ -281,7 +281,7 @@ mod test {
|
||||
let mut accounts = [Account::default(), Account::default()];
|
||||
accounts[1].userdata.resize(16 * 1024, 0);
|
||||
|
||||
let tx = Transaction::storage_new_mining_proof(
|
||||
let tx = StorageTransaction::new_mining_proof(
|
||||
&keypair,
|
||||
Hash::default(),
|
||||
Hash::default(),
|
||||
@ -300,7 +300,7 @@ mod test {
|
||||
let mut accounts = [Account::default(), Account::default()];
|
||||
accounts[1].userdata.resize(16 * 1024, 0);
|
||||
|
||||
let tx = Transaction::storage_new_advertise_last_id(
|
||||
let tx = StorageTransaction::new_advertise_last_id(
|
||||
&keypair,
|
||||
Hash::default(),
|
||||
Hash::default(),
|
||||
@ -309,7 +309,7 @@ mod test {
|
||||
|
||||
test_transaction(&tx, &mut accounts).unwrap();
|
||||
|
||||
let tx = Transaction::storage_new_mining_proof(
|
||||
let tx = StorageTransaction::new_mining_proof(
|
||||
&keypair,
|
||||
Hash::default(),
|
||||
Hash::default(),
|
||||
@ -329,7 +329,7 @@ mod test {
|
||||
|
||||
let entry_height = 0;
|
||||
|
||||
let tx = Transaction::storage_new_advertise_last_id(
|
||||
let tx = StorageTransaction::new_advertise_last_id(
|
||||
&keypair,
|
||||
Hash::default(),
|
||||
Hash::default(),
|
||||
@ -338,7 +338,7 @@ mod test {
|
||||
|
||||
test_transaction(&tx, &mut accounts).unwrap();
|
||||
|
||||
let tx = Transaction::storage_new_mining_proof(
|
||||
let tx = StorageTransaction::new_mining_proof(
|
||||
&keypair,
|
||||
Hash::default(),
|
||||
Hash::default(),
|
||||
@ -347,7 +347,7 @@ mod test {
|
||||
);
|
||||
test_transaction(&tx, &mut accounts).unwrap();
|
||||
|
||||
let tx = Transaction::storage_new_advertise_last_id(
|
||||
let tx = StorageTransaction::new_advertise_last_id(
|
||||
&keypair,
|
||||
Hash::default(),
|
||||
Hash::default(),
|
||||
@ -355,7 +355,7 @@ mod test {
|
||||
);
|
||||
test_transaction(&tx, &mut accounts).unwrap();
|
||||
|
||||
let tx = Transaction::storage_new_proof_validation(
|
||||
let tx = StorageTransaction::new_proof_validation(
|
||||
&keypair,
|
||||
Hash::default(),
|
||||
entry_height,
|
||||
@ -363,7 +363,7 @@ mod test {
|
||||
);
|
||||
test_transaction(&tx, &mut accounts).unwrap();
|
||||
|
||||
let tx = Transaction::storage_new_advertise_last_id(
|
||||
let tx = StorageTransaction::new_advertise_last_id(
|
||||
&keypair,
|
||||
Hash::default(),
|
||||
Hash::default(),
|
||||
@ -371,7 +371,7 @@ mod test {
|
||||
);
|
||||
test_transaction(&tx, &mut accounts).unwrap();
|
||||
|
||||
let tx = Transaction::storage_new_reward_claim(&keypair, Hash::default(), entry_height);
|
||||
let tx = StorageTransaction::new_reward_claim(&keypair, Hash::default(), entry_height);
|
||||
test_transaction(&tx, &mut accounts).unwrap();
|
||||
|
||||
assert!(accounts[0].tokens == TOTAL_VALIDATOR_REWARDS);
|
||||
|
Reference in New Issue
Block a user