Skip to content

Commit

Permalink
address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
2501babe committed Aug 22, 2024
1 parent b530053 commit d205922
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions svm/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl SvmTestEntry {
}

// edit an existing account to reflect changes you expect the transaction to make to it
pub fn update_account(&mut self, pubkey: Pubkey, account: &AccountSharedData) {
pub fn update_expected_account_data(&mut self, pubkey: Pubkey, account: &AccountSharedData) {
let mut account = account.clone();
account.set_rent_epoch(u64::MAX);

Expand Down Expand Up @@ -171,7 +171,6 @@ impl Default for TransactionBatchItem {
// asserts for a given transaction in a batch
// we can automatically check whether it executed, whether it succeeded
// log items we expect to see (exect match only), and rodata
// rodata is a doubly-nested Option. None means no check is performed, Some(None) means we assert no rodata
#[derive(Clone, Debug)]
pub struct TransactionBatchItemAsserts {
pub executed: bool,
Expand Down Expand Up @@ -219,28 +218,32 @@ impl TransactionBatchItemAsserts {
}
}

match (&self.return_data, &execution_details.return_data) {
(ReturnDataAssert::Some(expected_ro_data), Some(actual_ro_data)) => {
assert_eq!(expected_ro_data, actual_ro_data)
}
(ReturnDataAssert::None, None) => {}
(ReturnDataAssert::Skip, _) => {}
(left, right) => panic!(
"assertion `left == right` failed\n {:?}\n {:?}",
left, right
),
if self.return_data != ReturnDataAssert::Skip {
assert_eq!(
self.return_data,
execution_details.return_data.clone().into()
);
}
}
}

#[derive(Clone, Debug, Default)]
#[derive(Clone, Debug, Default, PartialEq)]
pub enum ReturnDataAssert {
Some(TransactionReturnData),
None,
#[default]
Skip,
}

impl From<Option<TransactionReturnData>> for ReturnDataAssert {
fn from(option_ro_data: Option<TransactionReturnData>) -> Self {
match option_ro_data {
Some(ro_data) => Self::Some(ro_data),
None => Self::None,
}
}
}

fn program_medley() -> Vec<SvmTestEntry> {
let mut test_entry = SvmTestEntry::default();

Expand Down

0 comments on commit d205922

Please sign in to comment.