@@ -67,27 +67,27 @@ impl InstructionResult {
6767 let check_units = * units;
6868 let actual_units = self . compute_units_consumed ;
6969 assert_eq ! (
70- check_units , actual_units ,
71- "Checking compute units consumed: expected {}, got {}" ,
72- check_units , actual_units
70+ actual_units , check_units ,
71+ "CHECK: compute units: got: {}, expected {}" ,
72+ actual_units , check_units ,
7373 ) ;
7474 }
7575 CheckType :: ExecutionTime ( time) => {
7676 let check_time = * time;
7777 let actual_time = self . execution_time ;
7878 assert_eq ! (
79- check_time , actual_time ,
80- "Checking execution time: expected {}, got {}" ,
81- check_time , actual_time
79+ actual_time , check_time ,
80+ "CHECK: execution time: got: {}, expected {}" ,
81+ actual_time , check_time ,
8282 ) ;
8383 }
8484 CheckType :: ProgramResult ( result) => {
8585 let check_result = result;
8686 let actual_result = & self . program_result ;
8787 assert_eq ! (
88- check_result , actual_result ,
89- "Checking program result: expected {:?}, got {:?}" ,
90- check_result , actual_result
88+ actual_result , check_result ,
89+ "CHECK: program result: got {:?}, expected {:?}" ,
90+ actual_result , check_result ,
9191 ) ;
9292 }
9393 CheckType :: ResultingAccount ( account) => {
@@ -103,25 +103,41 @@ impl InstructionResult {
103103 if let Some ( check_data) = account. check_data {
104104 let actual_data = resulting_account. data ( ) ;
105105 assert_eq ! (
106- check_data, actual_data,
107- "Checking account data: expected {:?}, got {:?}" ,
108- check_data, actual_data
106+ actual_data, check_data,
107+ "CHECK: account data: got {:?}, expected {:?}" ,
108+ actual_data, check_data,
109+ ) ;
110+ }
111+ if let Some ( check_executable) = account. check_executable {
112+ let actual_executable = resulting_account. executable ( ) ;
113+ assert_eq ! (
114+ actual_executable, check_executable,
115+ "CHECK: account executable: got {}, expected {}" ,
116+ actual_executable, check_executable,
109117 ) ;
110118 }
111119 if let Some ( check_lamports) = account. check_lamports {
112120 let actual_lamports = resulting_account. lamports ( ) ;
113121 assert_eq ! (
114- check_lamports , actual_lamports ,
115- "Checking account lamports: expected {}, got {}" ,
116- check_lamports , actual_lamports
122+ actual_lamports , check_lamports ,
123+ "CHECK: account lamports: got {}, expected {}" ,
124+ actual_lamports , check_lamports ,
117125 ) ;
118126 }
119127 if let Some ( check_owner) = account. check_owner {
120128 let actual_owner = resulting_account. owner ( ) ;
121129 assert_eq ! (
122- check_owner, actual_owner,
123- "Checking account owner: expected {}, got {}" ,
124- check_owner, actual_owner
130+ actual_owner, check_owner,
131+ "CHECK: account owner: got {}, expected {}" ,
132+ actual_owner, check_owner,
133+ ) ;
134+ }
135+ if let Some ( check_space) = account. check_space {
136+ let actual_space = resulting_account. data ( ) . len ( ) ;
137+ assert_eq ! (
138+ actual_space, check_space,
139+ "CHECK: account space: got {}, expected {}" ,
140+ actual_space, check_space,
125141 ) ;
126142 }
127143 if let Some ( check_state) = & account. check_state {
@@ -130,7 +146,7 @@ impl InstructionResult {
130146 assert_eq ! (
131147 & AccountSharedData :: default ( ) ,
132148 resulting_account,
133- "Checking account closed: expected true, got false "
149+ "CHECK: account closed: got false, expected true "
134150 ) ;
135151 }
136152 }
@@ -199,8 +215,10 @@ enum AccountStateCheck {
199215struct AccountCheck < ' a > {
200216 pubkey : Pubkey ,
201217 check_data : Option < & ' a [ u8 ] > ,
218+ check_executable : Option < bool > ,
202219 check_lamports : Option < u64 > ,
203220 check_owner : Option < & ' a Pubkey > ,
221+ check_space : Option < usize > ,
204222 check_state : Option < AccountStateCheck > ,
205223}
206224
@@ -209,8 +227,10 @@ impl AccountCheck<'_> {
209227 Self {
210228 pubkey : * pubkey,
211229 check_data : None ,
230+ check_executable : None ,
212231 check_lamports : None ,
213232 check_owner : None ,
233+ check_space : None ,
214234 check_state : None ,
215235 }
216236 }
@@ -237,6 +257,11 @@ impl<'a> AccountCheckBuilder<'a> {
237257 self
238258 }
239259
260+ pub fn executable ( mut self , executable : bool ) -> Self {
261+ self . check . check_executable = Some ( executable) ;
262+ self
263+ }
264+
240265 pub fn lamports ( mut self , lamports : u64 ) -> Self {
241266 self . check . check_lamports = Some ( lamports) ;
242267 self
@@ -247,6 +272,11 @@ impl<'a> AccountCheckBuilder<'a> {
247272 self
248273 }
249274
275+ pub fn space ( mut self , space : usize ) -> Self {
276+ self . check . check_space = Some ( space) ;
277+ self
278+ }
279+
250280 pub fn build ( self ) -> Check < ' a > {
251281 Check :: new ( CheckType :: ResultingAccount ( self . check ) )
252282 }
0 commit comments