Skip to content

Commit

Permalink
storage
Browse files Browse the repository at this point in the history
  • Loading branch information
malik672 committed Dec 2, 2024
1 parent 5b02478 commit 94956ba
Showing 1 changed file with 5 additions and 21 deletions.
26 changes: 5 additions & 21 deletions examples/transient_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,34 +26,18 @@ fn transient_value() -> anyhow::Result<()> {
let mut contract = Contract::search("transient_storage")?.compile()?;
let value: i32 = 42;

// First transaction: set value
{
let info = contract.execute(&[b"set_temp(int32)".to_vec(), value.to_bytes32().to_vec()])?;
let info = contract.execute(&[
b"set_and_get_temp(int32)".to_vec(),
value.to_bytes32().to_vec(),
])?;
assert!(info.ret.is_empty());
// assert_eq!(
// info.transient_storage
// .get(&U256::from_le_bytes(TempCounter::STORAGE_KEY)),
// Some(&U256::from(value))
// );
// Verify regular storage is untouched
assert_eq!(
info.storage
.get(&U256::from_le_bytes(TempCounter::STORAGE_KEY)),
None
Some(&U256::from(value))
);
}

// Second transaction: value should be cleared
{
let info = contract.execute(&[b"get_temp()".to_vec()])?;
assert_eq!(info.ret, 0.to_bytes32());
// Verify transient storage was cleared
// assert_eq!(
// info.transient_storage
// .get(&U256::from_le_bytes(TempCounter::STORAGE_KEY)),
// None
// );
}

Ok(())
}

0 comments on commit 94956ba

Please sign in to comment.