-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathblock_timestamp_tests.cpp
More file actions
34 lines (23 loc) · 953 Bytes
/
block_timestamp_tests.cpp
File metadata and controls
34 lines (23 loc) · 953 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <eosio/chain/block_timestamp.hpp>
#include <boost/test/unit_test.hpp>
#include <fc/time.hpp>
#include <fc/exception/exception.hpp>
using namespace eosio;
using namespace chain;
BOOST_AUTO_TEST_SUITE(block_timestamp_tests)
BOOST_AUTO_TEST_CASE(constructor_test) {
block_timestamp_type bt;
BOOST_TEST( bt.slot == 0u, "Default constructor gives wrong value");
fc::time_point t(fc::seconds(978307200));
block_timestamp_type bt2(t);
BOOST_TEST( bt2.slot == (978307200u - 946684800u)*2, "Time point constructor gives wrong value");
}
BOOST_AUTO_TEST_CASE(conversion_test) {
block_timestamp_type bt;
fc::time_point t = (fc::time_point)bt;
BOOST_TEST(t.time_since_epoch().to_seconds() == 946684800ll, "Time point conversion failed");
block_timestamp_type bt1(200);
t = (fc::time_point)bt1;
BOOST_TEST(t.time_since_epoch().to_seconds() == 946684900ll, "Time point conversion failed");
}
BOOST_AUTO_TEST_SUITE_END()