Skip to content

Commit

Permalink
Update unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
msmouse committed Feb 14, 2024
1 parent fae7b19 commit a39fd1e
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ task 2 'run'. lines 32-32:
Events:
{
type: 0x1::transaction_fee::FeeStatement
data: "36000000000000000300000000000000010000000000000050c30000000000000000000000000000"
data: "30000000000000000300000000000000010000000000000030ac0000000000000000000000000000"
}mutable inputs after call: local#0: 0
return values: 0

task 3 'run'. lines 34-34:
Events:
{
type: 0x1::transaction_fee::FeeStatement
data: "04000000000000000300000000000000020000000000000000000000000000000000000000000000"
data: "05000000000000000300000000000000020000000000000018010000000000000000000000000000"
}mutable inputs after call: local#0: 0
return values: 0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Events:
}
{
type: 0x1::transaction_fee::FeeStatement
data: "6a0000000000000004000000000000000200000000000000a0860100000000000000000000000000"
data: "64000000000000000400000000000000020000000000000028720100000000000000000000000000"
}mutable inputs after call: local#0: 0
return values: 0

Expand All @@ -36,7 +36,7 @@ Events:
}
{
type: 0x1::transaction_fee::FeeStatement
data: "9f0000000000000006000000000000000300000000000000f0490200000000000000000000000000"
data: "9b0000000000000006000000000000000300000000000000c83a0200000000000000000000000000"
}mutable inputs after call: local#0: 0
return values: 0

Expand Down Expand Up @@ -96,7 +96,7 @@ Events:
}
{
type: 0x1::transaction_fee::FeeStatement
data: "6c0000000000000005000000000000000300000000000000a0860100000000000000000000000000"
data: "6b000000000000000500000000000000030000000000000018820100000000000000000000000000"
}mutable inputs after call: local#0: 0
return values: 0

Expand All @@ -116,7 +116,7 @@ Events:
}
{
type: 0x1::transaction_fee::FeeStatement
data: "6c0000000000000005000000000000000300000000000000a08601000000000050c3000000000000"
data: "6b0000000000000005000000000000000300000000000000b88201000000000058bb000000000000"
}mutable inputs after call: local#0: 0
return values: 0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ task 2 'run'. lines 36-36:
Events:
{
type: 0x1::transaction_fee::FeeStatement
data: "36000000000000000300000000000000010000000000000050c30000000000000000000000000000"
data: "30000000000000000300000000000000010000000000000030ac0000000000000000000000000000"
}mutable inputs after call: local#0: 0
return values: 0

task 3 'run'. lines 38-38:
Events:
{
type: 0x1::transaction_fee::FeeStatement
data: "04000000000000000300000000000000020000000000000000000000000000000000000000000000"
data: "05000000000000000300000000000000020000000000000018010000000000000000000000000000"
}mutable inputs after call: local#0: 0
return values: 0

Expand Down
61 changes: 34 additions & 27 deletions aptos-move/e2e-move-tests/src/tests/state_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,58 +26,65 @@ fn test_metadata_tracking() {
let account1 = harness.new_account_at(address1);

// Disable storage slot metadata tracking
harness.enable_features(vec![], vec![FeatureFlag::STORAGE_SLOT_METADATA]);
harness.enable_features(vec![], vec![
FeatureFlag::STORAGE_SLOT_METADATA,
FeatureFlag::REFUNDABLE_BYTES,
]);
// Create and fund account2
harness.run_transaction_payload(
&account1,
aptos_cached_packages::aptos_stdlib::aptos_account_transfer(address2, 100),
);
// Observe that metadata is not tracked for address2 resources
assert_eq!(
harness.read_resource_metadata(&address2, coin_store.clone()),
Some(StateValueMetadata::none()),
harness
.read_resource_metadata(&address2, coin_store.clone())
.unwrap(),
StateValueMetadata::none(),
);

// Enable storage slot metadata tracking
harness.enable_features(vec![FeatureFlag::STORAGE_SLOT_METADATA], vec![]);
harness.enable_features(
vec![
FeatureFlag::STORAGE_SLOT_METADATA,
FeatureFlag::REFUNDABLE_BYTES,
],
vec![],
);
// Create and fund account3
harness.run_transaction_payload(
&account1,
aptos_cached_packages::aptos_stdlib::aptos_account_transfer(address3, 100),
);

let slot_fee = harness
.new_vm()
.gas_params()
.unwrap()
.vm
.txn
.legacy_storage_fee_per_state_slot_create
.into();
assert!(slot_fee > 0);

// Observe that metadata is tracked for address3 resources
assert_eq!(
harness.read_resource_metadata(&address3, coin_store.clone()),
Some(StateValueMetadata::legacy(slot_fee, &timestamp)),
);
let meta3a = harness
.read_resource_metadata(&address3, coin_store.clone())
.unwrap();
assert!(meta3a.slot_deposit() > 0);
assert!(meta3a.bytes_deposit() > 0);
assert_eq!(meta3a.creation_time_usecs(), timestamp.microseconds);

// Bump the timestamp and modify the resources, observe that metadata doesn't change.
// Bump the timestamp and modify the resource, observe that metadata doesn't change.
harness.new_epoch();
harness.run_transaction_payload(
&account1,
aptos_cached_packages::aptos_stdlib::aptos_account_transfer(address2, 100),
aptos_cached_packages::aptos_stdlib::aptos_account_transfer(address3, 100),
);
let meta3b = harness
.read_resource_metadata(&address3, coin_store.clone())
.unwrap();
assert_eq!(meta3a, meta3b);

// However, enabling refundable_bytes does make StateValueMetadata::None automatically upgrade
harness.run_transaction_payload(
&account1,
aptos_cached_packages::aptos_stdlib::aptos_account_transfer(address3, 100),
);
assert_eq!(
harness.read_resource_metadata(&address2, coin_store.clone()),
Some(StateValueMetadata::none()),
aptos_cached_packages::aptos_stdlib::aptos_account_transfer(address2, 100),
);
assert_eq!(
harness.read_resource_metadata(&address3, coin_store),
Some(StateValueMetadata::legacy(slot_fee, &timestamp)),
harness
.read_resource_metadata(&address2, coin_store.clone())
.unwrap(),
StateValueMetadata::new(0, 0, &CurrentTimeMicroseconds { microseconds: 0 })
);
}
7 changes: 5 additions & 2 deletions aptos-move/e2e-move-tests/src/tests/storage_refund.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ fn test_refunds() {
],
vec![],
);
h.modify_gas_schedule(|params| params.vm.txn.max_execution_gas = 10_000_000_000.into());
h.modify_gas_schedule(|params| {
params.vm.txn.max_execution_gas = 10_000_000_000.into();
params.vm.txn.storage_fee_per_state_byte = 0.into(); // tested in DiskSpacePricing.
});
let mod_addr = AccountAddress::from_hex_literal("0xcafe").unwrap();
let user_addr = AccountAddress::from_hex_literal("0x100").unwrap();
let mod_acc = h.new_account_at(mod_addr);
Expand Down Expand Up @@ -97,7 +100,7 @@ fn read_slot_fee_from_gas_schedule(h: &MoveHarness) -> u64 {
.unwrap()
.vm
.txn
.legacy_storage_fee_per_state_slot_create
.storage_fee_per_state_slot
.into();
assert!(slot_fee > 0);
assert!(slot_fee > LEEWAY * 10);
Expand Down

0 comments on commit a39fd1e

Please sign in to comment.