mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-15 04:31:08 +00:00
Refactor and timestamp test
This commit is contained in:
@@ -1,10 +1,36 @@
|
||||
use primitives::Timestamp;
|
||||
use storage::Storage;
|
||||
|
||||
pub fn timestamp() -> Timestamp {
|
||||
pub fn get() -> Timestamp {
|
||||
Storage::into(b"tim\0val")
|
||||
}
|
||||
|
||||
pub fn set_timestamp(now: Timestamp) {
|
||||
pub fn set(now: Timestamp) {
|
||||
now.store(b"tim\0val")
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use joiner::Joiner;
|
||||
use function::Function;
|
||||
use keyedvec::KeyedVec;
|
||||
use slicable::Slicable;
|
||||
use runtime_support::with_externalities;
|
||||
use primitives::{UncheckedTransaction, Transaction};
|
||||
use statichex::StaticHexInto;
|
||||
use runtime::{system, timestamp};
|
||||
use testing::{TestExternalities, HexDisplay, one, two};
|
||||
|
||||
#[test]
|
||||
fn timestamp_works() {
|
||||
let mut t = TestExternalities { storage: map![
|
||||
b"tim\0val".to_vec() => vec![].join(&42u64)
|
||||
], };
|
||||
|
||||
with_externalities(&mut t, || {
|
||||
assert_eq!(timestamp::get(), 42);
|
||||
timestamp::set(69);
|
||||
assert_eq!(timestamp::get(), 69);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user