Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test-case invalid_undelegate_transaction_with_invalid_delegator2 #545

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 35 additions & 3 deletions core/src/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2277,10 +2277,42 @@ mod test {
#[ignore]
#[test]
// Test the case where the `Undelegate` extra-agenda transaction is invalid because the delegator has not delegated.
/// This test case is ignored because the extra-agenda transaction is not implemented yet.
/// TODO: enable this test case when the extra-agenda transaction is implemented.
fn invalid_undelegate_transaction_with_invalid_delegator2() {
todo!("Implement this test")
let (validator_keypair, reserved_state, mut csv) = setup_test(4);
// Apply agenda commit
let agenda_transactions_hash = calculate_agenda_transactions_hash(csv.phase.clone());
let agenda: Agenda = Agenda {
author: reserved_state.query_name(&validator_keypair[0].0).unwrap(),
timestamp: 1,
transactions_hash: agenda_transactions_hash,
height: csv.header.height + 1,
previous_block_hash: csv.header.to_hash256(),
};
csv.apply_commit(&generate_agenda_commit(&agenda)).unwrap();
// Apply agenda-proof commit
csv.apply_commit(&generate_agenda_proof_commit(
&validator_keypair,
&agenda,
agenda.to_hash256(),
))
.unwrap();
// Apply 'Undelegate' extra-agenda transaction commit with the delegator has not delegated.
let delegator = reserved_state.members[1].clone();
let delegator_private_key = validator_keypair[1].1.clone();
let undelegation_transaction_data: UndelegationTransactionData =
UndelegationTransactionData {
delegator: delegator.name,
block_height: csv.header.height + 1,
timestamp: 2,
chain_name: reserved_state.genesis_info.chain_name,
};
let proof: TypedSignature<UndelegationTransactionData> =
TypedSignature::sign(&undelegation_transaction_data, &delegator_private_key).unwrap();
csv.apply_commit(&generate_undelegation_transaction_commit(
&undelegation_transaction_data,
proof,
))
.unwrap_err();
}

#[ignore]
Expand Down
Loading