Refactor and timestamp test

This commit is contained in:
Gav
2018-01-19 08:49:38 +01:00
parent f179adbc4e
commit ba0d71a551
9 changed files with 110 additions and 72 deletions
@@ -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);
});
}
}