mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-29 14:57:56 +00:00
Add field names to pallet Event variants (#9993)
* convert pallet-assets events to struct types * updated events of a couple pallets * updated pallet event field names * update pallet event field names * updated events in test files * cargo fmt * minorfixes * fix assertion error * minor fix * formatting fix * fmt
This commit is contained in:
@@ -216,11 +216,32 @@ fn close_works() {
|
||||
assert_eq!(
|
||||
System::events(),
|
||||
vec![
|
||||
record(Event::Collective(CollectiveEvent::Proposed(1, 0, hash, 3))),
|
||||
record(Event::Collective(CollectiveEvent::Voted(1, hash, true, 1, 0))),
|
||||
record(Event::Collective(CollectiveEvent::Voted(2, hash, true, 2, 0))),
|
||||
record(Event::Collective(CollectiveEvent::Closed(hash, 2, 1))),
|
||||
record(Event::Collective(CollectiveEvent::Disapproved(hash)))
|
||||
record(Event::Collective(CollectiveEvent::Proposed {
|
||||
account: 1,
|
||||
proposal_index: 0,
|
||||
proposal_hash: hash,
|
||||
threshold: 3
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Voted {
|
||||
account: 1,
|
||||
proposal_hash: hash,
|
||||
voted: true,
|
||||
yes: 1,
|
||||
no: 0
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Voted {
|
||||
account: 2,
|
||||
proposal_hash: hash,
|
||||
voted: true,
|
||||
yes: 2,
|
||||
no: 0
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Closed {
|
||||
proposal_hash: hash,
|
||||
yes: 2,
|
||||
no: 1
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Disapproved { proposal_hash: hash }))
|
||||
]
|
||||
);
|
||||
});
|
||||
@@ -315,11 +336,32 @@ fn close_with_prime_works() {
|
||||
assert_eq!(
|
||||
System::events(),
|
||||
vec![
|
||||
record(Event::Collective(CollectiveEvent::Proposed(1, 0, hash, 3))),
|
||||
record(Event::Collective(CollectiveEvent::Voted(1, hash, true, 1, 0))),
|
||||
record(Event::Collective(CollectiveEvent::Voted(2, hash, true, 2, 0))),
|
||||
record(Event::Collective(CollectiveEvent::Closed(hash, 2, 1))),
|
||||
record(Event::Collective(CollectiveEvent::Disapproved(hash)))
|
||||
record(Event::Collective(CollectiveEvent::Proposed {
|
||||
account: 1,
|
||||
proposal_index: 0,
|
||||
proposal_hash: hash,
|
||||
threshold: 3
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Voted {
|
||||
account: 1,
|
||||
proposal_hash: hash,
|
||||
voted: true,
|
||||
yes: 1,
|
||||
no: 0
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Voted {
|
||||
account: 2,
|
||||
proposal_hash: hash,
|
||||
voted: true,
|
||||
yes: 2,
|
||||
no: 0
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Closed {
|
||||
proposal_hash: hash,
|
||||
yes: 2,
|
||||
no: 1
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Disapproved { proposal_hash: hash }))
|
||||
]
|
||||
);
|
||||
});
|
||||
@@ -354,15 +396,36 @@ fn close_with_voting_prime_works() {
|
||||
assert_eq!(
|
||||
System::events(),
|
||||
vec![
|
||||
record(Event::Collective(CollectiveEvent::Proposed(1, 0, hash, 3))),
|
||||
record(Event::Collective(CollectiveEvent::Voted(1, hash, true, 1, 0))),
|
||||
record(Event::Collective(CollectiveEvent::Voted(2, hash, true, 2, 0))),
|
||||
record(Event::Collective(CollectiveEvent::Closed(hash, 3, 0))),
|
||||
record(Event::Collective(CollectiveEvent::Approved(hash))),
|
||||
record(Event::Collective(CollectiveEvent::Executed(
|
||||
hash,
|
||||
Err(DispatchError::BadOrigin)
|
||||
)))
|
||||
record(Event::Collective(CollectiveEvent::Proposed {
|
||||
account: 1,
|
||||
proposal_index: 0,
|
||||
proposal_hash: hash,
|
||||
threshold: 3
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Voted {
|
||||
account: 1,
|
||||
proposal_hash: hash,
|
||||
voted: true,
|
||||
yes: 1,
|
||||
no: 0
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Voted {
|
||||
account: 2,
|
||||
proposal_hash: hash,
|
||||
voted: true,
|
||||
yes: 2,
|
||||
no: 0
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Closed {
|
||||
proposal_hash: hash,
|
||||
yes: 3,
|
||||
no: 0
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Approved { proposal_hash: hash })),
|
||||
record(Event::Collective(CollectiveEvent::Executed {
|
||||
proposal_hash: hash,
|
||||
result: Err(DispatchError::BadOrigin)
|
||||
}))
|
||||
]
|
||||
);
|
||||
});
|
||||
@@ -404,16 +467,45 @@ fn close_with_no_prime_but_majority_works() {
|
||||
assert_eq!(
|
||||
System::events(),
|
||||
vec![
|
||||
record(Event::CollectiveMajority(CollectiveEvent::Proposed(1, 0, hash, 5))),
|
||||
record(Event::CollectiveMajority(CollectiveEvent::Voted(1, hash, true, 1, 0))),
|
||||
record(Event::CollectiveMajority(CollectiveEvent::Voted(2, hash, true, 2, 0))),
|
||||
record(Event::CollectiveMajority(CollectiveEvent::Voted(3, hash, true, 3, 0))),
|
||||
record(Event::CollectiveMajority(CollectiveEvent::Closed(hash, 5, 0))),
|
||||
record(Event::CollectiveMajority(CollectiveEvent::Approved(hash))),
|
||||
record(Event::CollectiveMajority(CollectiveEvent::Executed(
|
||||
hash,
|
||||
Err(DispatchError::BadOrigin)
|
||||
)))
|
||||
record(Event::CollectiveMajority(CollectiveEvent::Proposed {
|
||||
account: 1,
|
||||
proposal_index: 0,
|
||||
proposal_hash: hash,
|
||||
threshold: 5
|
||||
})),
|
||||
record(Event::CollectiveMajority(CollectiveEvent::Voted {
|
||||
account: 1,
|
||||
proposal_hash: hash,
|
||||
voted: true,
|
||||
yes: 1,
|
||||
no: 0
|
||||
})),
|
||||
record(Event::CollectiveMajority(CollectiveEvent::Voted {
|
||||
account: 2,
|
||||
proposal_hash: hash,
|
||||
voted: true,
|
||||
yes: 2,
|
||||
no: 0
|
||||
})),
|
||||
record(Event::CollectiveMajority(CollectiveEvent::Voted {
|
||||
account: 3,
|
||||
proposal_hash: hash,
|
||||
voted: true,
|
||||
yes: 3,
|
||||
no: 0
|
||||
})),
|
||||
record(Event::CollectiveMajority(CollectiveEvent::Closed {
|
||||
proposal_hash: hash,
|
||||
yes: 5,
|
||||
no: 0
|
||||
})),
|
||||
record(Event::CollectiveMajority(CollectiveEvent::Approved {
|
||||
proposal_hash: hash
|
||||
})),
|
||||
record(Event::CollectiveMajority(CollectiveEvent::Executed {
|
||||
proposal_hash: hash,
|
||||
result: Err(DispatchError::BadOrigin)
|
||||
}))
|
||||
]
|
||||
);
|
||||
});
|
||||
@@ -537,7 +629,12 @@ fn propose_works() {
|
||||
|
||||
assert_eq!(
|
||||
System::events(),
|
||||
vec![record(Event::Collective(CollectiveEvent::Proposed(1, 0, hash, 3)))]
|
||||
vec![record(Event::Collective(CollectiveEvent::Proposed {
|
||||
account: 1,
|
||||
proposal_index: 0,
|
||||
proposal_hash: hash,
|
||||
threshold: 3
|
||||
}))]
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -696,9 +793,26 @@ fn motions_vote_after_works() {
|
||||
assert_eq!(
|
||||
System::events(),
|
||||
vec![
|
||||
record(Event::Collective(CollectiveEvent::Proposed(1, 0, hash, 2))),
|
||||
record(Event::Collective(CollectiveEvent::Voted(1, hash, true, 1, 0))),
|
||||
record(Event::Collective(CollectiveEvent::Voted(1, hash, false, 0, 1))),
|
||||
record(Event::Collective(CollectiveEvent::Proposed {
|
||||
account: 1,
|
||||
proposal_index: 0,
|
||||
proposal_hash: hash,
|
||||
threshold: 2
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Voted {
|
||||
account: 1,
|
||||
proposal_hash: hash,
|
||||
voted: true,
|
||||
yes: 1,
|
||||
no: 0
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Voted {
|
||||
account: 1,
|
||||
proposal_hash: hash,
|
||||
voted: false,
|
||||
yes: 0,
|
||||
no: 1
|
||||
})),
|
||||
]
|
||||
);
|
||||
});
|
||||
@@ -812,15 +926,36 @@ fn motions_approval_with_enough_votes_and_lower_voting_threshold_works() {
|
||||
assert_eq!(
|
||||
System::events(),
|
||||
vec![
|
||||
record(Event::Collective(CollectiveEvent::Proposed(1, 0, hash, 2))),
|
||||
record(Event::Collective(CollectiveEvent::Voted(1, hash, true, 1, 0))),
|
||||
record(Event::Collective(CollectiveEvent::Voted(2, hash, true, 2, 0))),
|
||||
record(Event::Collective(CollectiveEvent::Closed(hash, 2, 0))),
|
||||
record(Event::Collective(CollectiveEvent::Approved(hash))),
|
||||
record(Event::Collective(CollectiveEvent::Executed(
|
||||
hash,
|
||||
Err(DispatchError::BadOrigin)
|
||||
))),
|
||||
record(Event::Collective(CollectiveEvent::Proposed {
|
||||
account: 1,
|
||||
proposal_index: 0,
|
||||
proposal_hash: hash,
|
||||
threshold: 2
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Voted {
|
||||
account: 1,
|
||||
proposal_hash: hash,
|
||||
voted: true,
|
||||
yes: 1,
|
||||
no: 0
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Voted {
|
||||
account: 2,
|
||||
proposal_hash: hash,
|
||||
voted: true,
|
||||
yes: 2,
|
||||
no: 0
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Closed {
|
||||
proposal_hash: hash,
|
||||
yes: 2,
|
||||
no: 0
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Approved { proposal_hash: hash })),
|
||||
record(Event::Collective(CollectiveEvent::Executed {
|
||||
proposal_hash: hash,
|
||||
result: Err(DispatchError::BadOrigin)
|
||||
})),
|
||||
]
|
||||
);
|
||||
|
||||
@@ -840,14 +975,44 @@ fn motions_approval_with_enough_votes_and_lower_voting_threshold_works() {
|
||||
assert_eq!(
|
||||
System::events(),
|
||||
vec![
|
||||
record(Event::Collective(CollectiveEvent::Proposed(1, 1, hash, 2))),
|
||||
record(Event::Collective(CollectiveEvent::Voted(1, hash, true, 1, 0))),
|
||||
record(Event::Collective(CollectiveEvent::Voted(2, hash, true, 2, 0))),
|
||||
record(Event::Collective(CollectiveEvent::Voted(3, hash, true, 3, 0))),
|
||||
record(Event::Collective(CollectiveEvent::Closed(hash, 3, 0))),
|
||||
record(Event::Collective(CollectiveEvent::Approved(hash))),
|
||||
record(Event::Collective(CollectiveEvent::Proposed {
|
||||
account: 1,
|
||||
proposal_index: 1,
|
||||
proposal_hash: hash,
|
||||
threshold: 2
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Voted {
|
||||
account: 1,
|
||||
proposal_hash: hash,
|
||||
voted: true,
|
||||
yes: 1,
|
||||
no: 0
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Voted {
|
||||
account: 2,
|
||||
proposal_hash: hash,
|
||||
voted: true,
|
||||
yes: 2,
|
||||
no: 0
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Voted {
|
||||
account: 3,
|
||||
proposal_hash: hash,
|
||||
voted: true,
|
||||
yes: 3,
|
||||
no: 0
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Closed {
|
||||
proposal_hash: hash,
|
||||
yes: 3,
|
||||
no: 0
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Approved { proposal_hash: hash })),
|
||||
record(Event::Democracy(mock_democracy::pallet::Event::<Test>::ExternalProposed)),
|
||||
record(Event::Collective(CollectiveEvent::Executed(hash, Ok(())))),
|
||||
record(Event::Collective(CollectiveEvent::Executed {
|
||||
proposal_hash: hash,
|
||||
result: Ok(())
|
||||
})),
|
||||
]
|
||||
);
|
||||
});
|
||||
@@ -873,11 +1038,32 @@ fn motions_disapproval_works() {
|
||||
assert_eq!(
|
||||
System::events(),
|
||||
vec![
|
||||
record(Event::Collective(CollectiveEvent::Proposed(1, 0, hash, 3))),
|
||||
record(Event::Collective(CollectiveEvent::Voted(1, hash, true, 1, 0))),
|
||||
record(Event::Collective(CollectiveEvent::Voted(2, hash, false, 1, 1))),
|
||||
record(Event::Collective(CollectiveEvent::Closed(hash, 1, 1))),
|
||||
record(Event::Collective(CollectiveEvent::Disapproved(hash))),
|
||||
record(Event::Collective(CollectiveEvent::Proposed {
|
||||
account: 1,
|
||||
proposal_index: 0,
|
||||
proposal_hash: hash,
|
||||
threshold: 3
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Voted {
|
||||
account: 1,
|
||||
proposal_hash: hash,
|
||||
voted: true,
|
||||
yes: 1,
|
||||
no: 0
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Voted {
|
||||
account: 2,
|
||||
proposal_hash: hash,
|
||||
voted: false,
|
||||
yes: 1,
|
||||
no: 1
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Closed {
|
||||
proposal_hash: hash,
|
||||
yes: 1,
|
||||
no: 1
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Disapproved { proposal_hash: hash })),
|
||||
]
|
||||
);
|
||||
});
|
||||
@@ -903,15 +1089,36 @@ fn motions_approval_works() {
|
||||
assert_eq!(
|
||||
System::events(),
|
||||
vec![
|
||||
record(Event::Collective(CollectiveEvent::Proposed(1, 0, hash, 2))),
|
||||
record(Event::Collective(CollectiveEvent::Voted(1, hash, true, 1, 0))),
|
||||
record(Event::Collective(CollectiveEvent::Voted(2, hash, true, 2, 0))),
|
||||
record(Event::Collective(CollectiveEvent::Closed(hash, 2, 0))),
|
||||
record(Event::Collective(CollectiveEvent::Approved(hash))),
|
||||
record(Event::Collective(CollectiveEvent::Executed(
|
||||
hash,
|
||||
Err(DispatchError::BadOrigin)
|
||||
))),
|
||||
record(Event::Collective(CollectiveEvent::Proposed {
|
||||
account: 1,
|
||||
proposal_index: 0,
|
||||
proposal_hash: hash,
|
||||
threshold: 2
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Voted {
|
||||
account: 1,
|
||||
proposal_hash: hash,
|
||||
voted: true,
|
||||
yes: 1,
|
||||
no: 0
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Voted {
|
||||
account: 2,
|
||||
proposal_hash: hash,
|
||||
voted: true,
|
||||
yes: 2,
|
||||
no: 0
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Closed {
|
||||
proposal_hash: hash,
|
||||
yes: 2,
|
||||
no: 0
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Approved { proposal_hash: hash })),
|
||||
record(Event::Collective(CollectiveEvent::Executed {
|
||||
proposal_hash: hash,
|
||||
result: Err(DispatchError::BadOrigin)
|
||||
})),
|
||||
]
|
||||
);
|
||||
});
|
||||
@@ -932,7 +1139,12 @@ fn motion_with_no_votes_closes_with_disapproval() {
|
||||
));
|
||||
assert_eq!(
|
||||
System::events()[0],
|
||||
record(Event::Collective(CollectiveEvent::Proposed(1, 0, hash, 3)))
|
||||
record(Event::Collective(CollectiveEvent::Proposed {
|
||||
account: 1,
|
||||
proposal_index: 0,
|
||||
proposal_hash: hash,
|
||||
threshold: 3
|
||||
}))
|
||||
);
|
||||
|
||||
// Closing the motion too early is not possible because it has neither
|
||||
@@ -951,11 +1163,15 @@ fn motion_with_no_votes_closes_with_disapproval() {
|
||||
// Events show that the close ended in a disapproval.
|
||||
assert_eq!(
|
||||
System::events()[1],
|
||||
record(Event::Collective(CollectiveEvent::Closed(hash, 0, 3)))
|
||||
record(Event::Collective(CollectiveEvent::Closed {
|
||||
proposal_hash: hash,
|
||||
yes: 0,
|
||||
no: 3
|
||||
}))
|
||||
);
|
||||
assert_eq!(
|
||||
System::events()[2],
|
||||
record(Event::Collective(CollectiveEvent::Disapproved(hash)))
|
||||
record(Event::Collective(CollectiveEvent::Disapproved { proposal_hash: hash }))
|
||||
);
|
||||
})
|
||||
}
|
||||
@@ -1015,10 +1231,27 @@ fn disapprove_proposal_works() {
|
||||
assert_eq!(
|
||||
System::events(),
|
||||
vec![
|
||||
record(Event::Collective(CollectiveEvent::Proposed(1, 0, hash, 2))),
|
||||
record(Event::Collective(CollectiveEvent::Voted(1, hash, true, 1, 0))),
|
||||
record(Event::Collective(CollectiveEvent::Voted(2, hash, true, 2, 0))),
|
||||
record(Event::Collective(CollectiveEvent::Disapproved(hash))),
|
||||
record(Event::Collective(CollectiveEvent::Proposed {
|
||||
account: 1,
|
||||
proposal_index: 0,
|
||||
proposal_hash: hash,
|
||||
threshold: 2
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Voted {
|
||||
account: 1,
|
||||
proposal_hash: hash,
|
||||
voted: true,
|
||||
yes: 1,
|
||||
no: 0
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Voted {
|
||||
account: 2,
|
||||
proposal_hash: hash,
|
||||
voted: true,
|
||||
yes: 2,
|
||||
no: 0
|
||||
})),
|
||||
record(Event::Collective(CollectiveEvent::Disapproved { proposal_hash: hash })),
|
||||
]
|
||||
);
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user