From d205922619577ca05c28da28e6412dda98c4df85 Mon Sep 17 00:00:00 2001 From: hanako mumei <81144685+2501babe@users.noreply.github.com> Date: Thu, 22 Aug 2024 14:07:32 -0700 Subject: [PATCH] address feedback --- svm/tests/integration_test.rs | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/svm/tests/integration_test.rs b/svm/tests/integration_test.rs index 061098547e4b7b..cef61d4d5446c5 100644 --- a/svm/tests/integration_test.rs +++ b/svm/tests/integration_test.rs @@ -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); @@ -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, @@ -219,21 +218,16 @@ 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, @@ -241,6 +235,15 @@ pub enum ReturnDataAssert { Skip, } +impl From> for ReturnDataAssert { + fn from(option_ro_data: Option) -> Self { + match option_ro_data { + Some(ro_data) => Self::Some(ro_data), + None => Self::None, + } + } +} + fn program_medley() -> Vec { let mut test_entry = SvmTestEntry::default();