Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
areshand committed Nov 26, 2024
1 parent 666f8f1 commit 4955ab9
Show file tree
Hide file tree
Showing 26 changed files with 73 additions and 215 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ task 1 'publish'. lines 4-26:
Error: VMError with status STLOC_UNSAFE_TO_DESTROY_ERROR at location Module ModuleId { address: f75daa73fc071f93593335eb9033da804777eb94491650dd3f095ce6f778acb6, name: Identifier("m") } at index 0 for function definition at code offset 11 in function definition 0

task 2 'run'. lines 28-28:
Error: Failed to execute transaction. ExecutionStatus: MiscellaneousError(None)
Error: Failed to execute transaction. ExecutionStatus: MiscellaneousError(Some(LINKER_ERROR))

task 3 'run'. lines 30-44:
Error: Failed to execute transaction. ExecutionStatus: MiscellaneousError(None)
Error: Failed to execute transaction. ExecutionStatus: MiscellaneousError(Some(STLOC_UNSAFE_TO_DESTROY_ERROR))
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ task 1 'publish'. lines 4-26:
Error: VMError with status STLOC_UNSAFE_TO_DESTROY_ERROR at location Module ModuleId { address: f75daa73fc071f93593335eb9033da804777eb94491650dd3f095ce6f778acb6, name: Identifier("m") } at index 0 for function definition at code offset 11 in function definition 0

task 2 'run'. lines 28-28:
Error: Failed to execute transaction. ExecutionStatus: MiscellaneousError(None)
Error: Failed to execute transaction. ExecutionStatus: MiscellaneousError(Some(LINKER_ERROR))

task 3 'run'. lines 30-44:
Error: Failed to execute transaction. ExecutionStatus: MiscellaneousError(None)
Error: Failed to execute transaction. ExecutionStatus: MiscellaneousError(Some(STLOC_UNSAFE_TO_DESTROY_ERROR))
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@ bug: BYTECODE VERIFICATION FAILED


task 3 'run'. lines 70-70:
Error: Failed to execute transaction. ExecutionStatus: MiscellaneousError(None)
Error: Failed to execute transaction. ExecutionStatus: MiscellaneousError(Some(LINKER_ERROR))
11 changes: 1 addition & 10 deletions aptos-move/aptos-vm-types/src/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ pub struct VMOutput {
module_write_set: ModuleWriteSet,
fee_statement: FeeStatement,
status: TransactionStatus,
auxiliary_data: TransactionAuxiliaryData,
}

impl VMOutput {
Expand All @@ -43,14 +42,12 @@ impl VMOutput {
module_write_set: ModuleWriteSet,
fee_statement: FeeStatement,
status: TransactionStatus,
auxiliary_data: TransactionAuxiliaryData,
) -> Self {
Self {
change_set,
module_write_set,
fee_statement,
status,
auxiliary_data,
}
}

Expand All @@ -60,7 +57,6 @@ impl VMOutput {
module_write_set: ModuleWriteSet::empty(),
fee_statement: FeeStatement::zero(),
status,
auxiliary_data: TransactionAuxiliaryData::default(),
}
}

Expand Down Expand Up @@ -102,10 +98,6 @@ impl VMOutput {
&self.status
}

pub fn auxiliary_data(&self) -> &TransactionAuxiliaryData {
&self.auxiliary_data
}

pub fn materialized_size(&self) -> u64 {
let mut size = 0;
for (state_key, write_size) in self
Expand Down Expand Up @@ -179,7 +171,6 @@ impl VMOutput {
module_write_set,
fee_statement,
status,
auxiliary_data,
} = self;
let (write_set, events) = change_set
.try_combine_into_storage_change_set(module_write_set)?
Expand All @@ -189,7 +180,7 @@ impl VMOutput {
events,
fee_statement.gas_used(),
status,
auxiliary_data,
TransactionAuxiliaryData::default(),
))
}

Expand Down
3 changes: 1 addition & 2 deletions aptos-move/aptos-vm-types/src/tests/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use aptos_types::{
fee_statement::FeeStatement,
on_chain_config::CurrentTimeMicroseconds,
state_store::{state_key::StateKey, state_value::StateValueMetadata},
transaction::{ExecutionStatus, TransactionAuxiliaryData, TransactionStatus},
transaction::{ExecutionStatus, TransactionStatus},
write_set::WriteOp,
};
use move_binary_format::errors::PartialVMResult;
Expand Down Expand Up @@ -252,7 +252,6 @@ pub(crate) fn build_vm_output(
ModuleWriteSet::new(false, module_write_set.into_iter().collect()),
FeeStatement::new(GAS_USED, GAS_USED, 0, 0, 0),
STATUS,
TransactionAuxiliaryData::default(),
)
}

Expand Down
19 changes: 4 additions & 15 deletions aptos-move/aptos-vm/src/aptos_vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ use aptos_types::{
authenticator::AnySignature, signature_verified_transaction::SignatureVerifiedTransaction,
BlockOutput, EntryFunction, ExecutionError, ExecutionStatus, ModuleBundle, Multisig,
MultisigTransactionPayload, Script, SignedTransaction, Transaction, TransactionArgument,
TransactionAuxiliaryData, TransactionOutput, TransactionPayload, TransactionStatus,
VMValidatorResult, ViewFunctionOutput, WriteSetPayload,
TransactionOutput, TransactionPayload, TransactionStatus, VMValidatorResult,
ViewFunctionOutput, WriteSetPayload,
},
vm_status::{AbortLocation, StatusCode, VMStatus},
};
Expand Down Expand Up @@ -186,7 +186,6 @@ pub(crate) fn get_system_transaction_output(
ModuleWriteSet::empty(),
FeeStatement::zero(),
TransactionStatus::Keep(ExecutionStatus::Success),
TransactionAuxiliaryData::default(),
))
}

Expand Down Expand Up @@ -471,7 +470,7 @@ impl AptosVM {
}
}

let (txn_status, txn_aux_data) = TransactionStatus::from_vm_status(
let txn_status = TransactionStatus::from_vm_status(
error_vm_status.clone(),
self.features()
.is_enabled(FeatureFlag::CHARGE_INVARIANT_VIOLATION),
Expand All @@ -493,7 +492,6 @@ impl AptosVM {
resolver,
module_storage,
status,
txn_aux_data,
log_context,
change_set_configs,
traversal_context,
Expand Down Expand Up @@ -541,7 +539,6 @@ impl AptosVM {
resolver: &impl AptosMoveResolver,
module_storage: &impl AptosModuleStorage,
status: ExecutionStatus,
txn_aux_data: TransactionAuxiliaryData,
log_context: &AdapterLogSchema,
change_set_configs: &ChangeSetConfigs,
traversal_context: &mut TraversalContext,
Expand Down Expand Up @@ -672,13 +669,7 @@ impl AptosVM {
)
})?;

epilogue_session.finish(
fee_statement,
status,
txn_aux_data,
change_set_configs,
module_storage,
)
epilogue_session.finish(fee_statement, status, change_set_configs, module_storage)
}

fn success_transaction_cleanup(
Expand Down Expand Up @@ -728,7 +719,6 @@ impl AptosVM {
let output = epilogue_session.finish(
fee_statement,
ExecutionStatus::Success,
TransactionAuxiliaryData::default(),
change_set_configs,
module_storage,
)?;
Expand Down Expand Up @@ -2307,7 +2297,6 @@ impl AptosVM {
module_write_set,
FeeStatement::zero(),
TransactionStatus::Keep(ExecutionStatus::Success),
TransactionAuxiliaryData::default(),
);
Ok((VMStatus::Executed, output))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::{
use aptos_gas_algebra::Fee;
use aptos_types::{
fee_statement::FeeStatement,
transaction::{ExecutionStatus, TransactionAuxiliaryData, TransactionStatus},
transaction::{ExecutionStatus, TransactionStatus},
};
use aptos_vm_types::{
change_set::VMChangeSet, module_and_script_storage::module_storage::AptosModuleStorage,
Expand Down Expand Up @@ -104,7 +104,6 @@ impl<'r, 'l> EpilogueSession<'r, 'l> {
self,
fee_statement: FeeStatement,
execution_status: ExecutionStatus,
txn_aux_data: TransactionAuxiliaryData,
change_set_configs: &ChangeSetConfigs,
module_storage: &impl AptosModuleStorage,
) -> Result<VMOutput, VMStatus> {
Expand Down Expand Up @@ -135,7 +134,6 @@ impl<'r, 'l> EpilogueSession<'r, 'l> {
module_write_set,
fee_statement,
TransactionStatus::Keep(execution_status),
txn_aux_data,
))
}
}
14 changes: 4 additions & 10 deletions aptos-move/e2e-move-tests/src/harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,11 @@ impl MoveHarness {

/// Runs a signed transaction. On success, applies the write set.
pub fn run_raw(&mut self, txn: SignedTransaction) -> TransactionOutput {
let mut output = self.executor.execute_transaction(txn);
let output = self.executor.execute_transaction(txn);
if matches!(output.status(), TransactionStatus::Keep(_)) {
self.executor.apply_write_set(output.write_set());
self.executor.append_events(output.events().to_vec());
}
output.fill_error_status();
output
}

Expand Down Expand Up @@ -239,12 +238,11 @@ impl MoveHarness {
&mut self,
txn_block: Vec<SignedTransaction>,
) -> Vec<TransactionOutput> {
let mut result = assert_ok!(self.executor.execute_block(txn_block));
for output in &mut result {
let result = assert_ok!(self.executor.execute_block(txn_block));
for output in &result {
if matches!(output.status(), TransactionStatus::Keep(_)) {
self.executor.apply_write_set(output.write_set());
}
output.fill_error_status();
}
result
}
Expand Down Expand Up @@ -979,11 +977,7 @@ impl MoveHarness {
offset,
txns.len()
);
let mut outputs = harness.run_block_get_output(txns);
let _ = outputs
.iter_mut()
.map(|t| t.fill_error_status())
.collect::<Vec<_>>();
let outputs = harness.run_block_get_output(txns);
for (idx, (error, output)) in errors.into_iter().zip(outputs.iter()).enumerate() {
if error == SUCCESS {
assert_success!(
Expand Down
15 changes: 4 additions & 11 deletions aptos-move/e2e-move-tests/src/tests/code_publishing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,17 +242,10 @@ fn code_publishing_upgrade_loader_cache_consistency() {
|_| {},
),
];
let result = h.run_block_get_output(txns);
assert_success!(result[0].status().to_owned());
assert_success!(result[1].status().to_owned());
assert_eq!(
result[2]
.auxiliary_data()
.get_detail_error_message()
.unwrap()
.status_code(),
StatusCode::BACKWARD_INCOMPATIBLE_MODULE_UPDATE
)
let result = h.run_block(txns);
assert_success!(result[0]);
assert_success!(result[1]);
assert_vm_status!(result[2], StatusCode::BACKWARD_INCOMPATIBLE_MODULE_UPDATE)
}

#[test]
Expand Down
11 changes: 1 addition & 10 deletions aptos-move/e2e-move-tests/src/tests/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,6 @@ fn failed_transaction_cleanup_charges_gas(status_code: StatusCode) {
balance,
)
.1;

assert_eq!(
output
.auxiliary_data()
.get_detail_error_message()
.unwrap()
.status_code(),
status_code
);
let write_set: Vec<(&StateKey, &WriteOp)> = output
.concrete_write_set_iter()
.map(|(k, v)| (k, assert_some!(v)))
Expand All @@ -59,6 +50,6 @@ fn failed_transaction_cleanup_charges_gas(status_code: StatusCode) {
assert!(!output.status().is_discarded());
assert_ok_eq!(
output.status().as_kept_status(),
ExecutionStatus::MiscellaneousError(None)
ExecutionStatus::MiscellaneousError(Some(status_code))
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,12 @@ Ok(
gas_used: 3,
status: Keep(
MiscellaneousError(
None,
),
),
auxiliary_data: V1(
TransactionAuxiliaryDataV1 {
detail_error_message: Some(
VMErrorDetail {
status_code: TYPE_MISMATCH,
message: None,
},
Some(
TYPE_MISMATCH,
),
},
),
),
auxiliary_data: None,
},
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,12 @@ Ok(
gas_used: 3,
status: Keep(
MiscellaneousError(
None,
),
),
auxiliary_data: V1(
TransactionAuxiliaryDataV1 {
detail_error_message: Some(
VMErrorDetail {
status_code: NEGATIVE_STACK_SIZE_WITHIN_BLOCK,
message: None,
},
Some(
NEGATIVE_STACK_SIZE_WITHIN_BLOCK,
),
},
),
),
auxiliary_data: None,
},
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,12 @@ Ok(
gas_used: 3,
status: Keep(
MiscellaneousError(
None,
),
),
auxiliary_data: V1(
TransactionAuxiliaryDataV1 {
detail_error_message: Some(
VMErrorDetail {
status_code: LINKER_ERROR,
message: None,
},
Some(
LINKER_ERROR,
),
},
),
),
auxiliary_data: None,
},
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,12 @@ Ok(
gas_used: 3,
status: Keep(
MiscellaneousError(
None,
),
),
auxiliary_data: V1(
TransactionAuxiliaryDataV1 {
detail_error_message: Some(
VMErrorDetail {
status_code: LOOKUP_FAILED,
message: None,
},
Some(
LOOKUP_FAILED,
),
},
),
),
auxiliary_data: None,
},
],
)
Loading

0 comments on commit 4955ab9

Please sign in to comment.