Merge pull request #52 from peerplays-network/qa_gpos_18.04_gcc7_fix

Enable building on Ubuntu 18.04 using GCC 7 compiler
This commit is contained in:
pbattu123 2019-08-20 15:42:13 -03:00 committed by GitHub
commit 4f66954fab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 197 additions and 590 deletions

View file

@ -119,7 +119,11 @@ else( WIN32 ) # Apple AND Linux
message( STATUS "Configuring BitShares on Linux" )
set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -std=c++11 -Wall" )
set( rt_library rt )
set( pthread_library pthread)
#set( pthread_library pthread)
set(CMAKE_LINKER_FLAGS "-pthread" CACHE STRING "Linker Flags" FORCE)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_LINKER_FLAGS}" CACHE STRING "" FORCE)
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS}" CACHE STRING "" FORCE)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS}" CACHE STRING "" FORCE)
if ( NOT DEFINED crypto_library )
# I'm not sure why this is here, I guess someone has openssl and can't detect it with find_package()?
# if you have a normal install, you can define crypto_library to the empty string to avoid a build error

View file

@ -32,16 +32,15 @@ cd boost_1_67_0/
## Building Peerplays
```
export BOOST_ROOT=/root/boost_1_67_0
export CC=gcc-5 ; export CXX=g++-5
cd $HOME/src
export BOOST_ROOT=$HOME/src/boost_1_67_0
git clone https://github.com/peerplays-network/peerplays.git
mkdir $HOME/peerplays/build; cd $HOME/src/peerplays/build
cd peerplays
git submodule update --init --recursive
cmake -DBOOST_ROOT="$BOOST_ROOT" -DCMAKE_BUILD_TYPE=Release ..
cmake -DBOOST_ROOT="$BOOST_ROOT" -DCMAKE_BUILD_TYPE=Release
make -j$(nproc)
ake install # this can install the executable files under /usr/local
make install # this can install the executable files under /usr/local
```
Rest of the instructions on starting the chain remains same.

View file

@ -279,6 +279,17 @@ void_result account_update_evaluator::do_evaluate( const account_update_operatio
void_result account_update_evaluator::do_apply( const account_update_operation& o )
{ try {
database& d = db();
if( o.new_options.valid() )
{
d.modify( acnt->statistics( d ), [&]( account_statistics_object& aso )
{
if((o.new_options->votes != acnt->options.votes ||
o.new_options->voting_account != acnt->options.voting_account))
aso.last_vote_time = d.head_block_time();
} );
}
bool sa_before, sa_after;
d.modify( *acnt, [&](account_object& a){
if( o.owner )
@ -320,7 +331,6 @@ void_result account_update_evaluator::do_apply( const account_update_operation&
sa.account = o.account;
} );
}
return void_result();
} FC_CAPTURE_AND_RETHROW( (o) ) }

View file

@ -82,6 +82,11 @@ namespace graphene { namespace chain {
*/
share_type pending_vested_fees;
/**
* Keep the date of the last voting activity for this account.
*/
time_point_sec last_vote_time;
/// @brief Split up and pay out @ref pending_fees and @ref pending_vested_fees
void process_fees(const account_object& a, database& d) const;
@ -463,6 +468,7 @@ FC_REFLECT_DERIVED( graphene::chain::account_statistics_object,
(total_core_in_orders)
(lifetime_fees_paid)
(pending_fees)(pending_vested_fees)
(last_vote_time)
)
FC_REFLECT_DERIVED( graphene::chain::pending_dividend_payout_balance_for_holder_object,

View file

@ -188,8 +188,9 @@ namespace graphene { namespace chain {
ordered_non_unique< tag<by_asset_balance>,
composite_key<
vesting_balance_object,
const_mem_fun<vesting_balance_object, asset_id_type, &vesting_balance_object::get_asset_id>,
const_mem_fun<vesting_balance_object, share_type, &vesting_balance_object::get_asset_amount>
member_offset<vesting_balance_object, asset_id_type, (size_t) (offsetof(vesting_balance_object,balance) + offsetof(asset,asset_id))>,
member<vesting_balance_object, vesting_balance_type, &vesting_balance_object::balance_type>,
member_offset<vesting_balance_object, share_type, (size_t) (offsetof(vesting_balance_object,balance) + offsetof(asset,amount))>
//member<vesting_balance_object, account_id_type, &vesting_balance_object::owner>
//member_offset<vesting_balance_object, account_id_type, (size_t) (offset_s(vesting_balance_object,owner))>
>,

View file

@ -13,7 +13,7 @@ target_link_libraries( graphene_net
PUBLIC fc graphene_db )
target_include_directories( graphene_net
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include"
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../chain/include"
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../chain/include" "${CMAKE_CURRENT_BINARY_DIR}/../chain/include"
)
if(MSVC)

View file

@ -10,7 +10,7 @@ if( PERL_FOUND AND DOXYGEN_FOUND AND NOT "${CMAKE_GENERATOR}" STREQUAL "Ninja" )
COMMAND ${DOXYGEN_EXECUTABLE}
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile include/graphene/wallet/wallet.hpp )
add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/api_documentation.cpp
COMMAND PERLLIB=${CMAKE_CURRENT_SOURCE_DIR} ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/generate_api_documentation.pl ${CMAKE_CURRENT_BINARY_DIR}/api_documentation.cpp.new
COMMAND PERLLIB=${CMAKE_CURRENT_BINARY_DIR} ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/generate_api_documentation.pl ${CMAKE_CURRENT_BINARY_DIR}/api_documentation.cpp.new
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/api_documentation.cpp.new ${CMAKE_CURRENT_BINARY_DIR}/api_documentation.cpp
COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_CURRENT_BINARY_DIR}/api_documentation.cpp.new

View file

@ -1,83 +0,0 @@
# Endpoint for P2P node to listen on
p2p-endpoint = 0.0.0.0:9777
# P2P nodes to connect to on startup (may specify multiple times)
# seed-node =
# JSON array of P2P nodes to connect to on startup
# seed-nodes =
# Pairs of [BLOCK_NUM,BLOCK_ID] that should be enforced as checkpoints.
# checkpoint =
# Endpoint for websocket RPC to listen on
rpc-endpoint = 0.0.0.0:8090
# Endpoint for TLS websocket RPC to listen on
# rpc-tls-endpoint =
# The TLS certificate file for this server
# server-pem =
# Password for this certificate
# server-pem-password =
# File to read Genesis State from
genesis-json =genesis.json
# Block signing key to use for init witnesses, overrides genesis file
# dbg-init-key =
# JSON file specifying API permissions
# api-access =
# Enable block production, even if the chain is stale.
enable-stale-production = true
# Percent of witnesses (0-99) that must be participating in order to produce blocks
required-participation = false
# ID of witness controlled by this node (e.g. "1.6.5", quotes are required, may specify multiple times)
# witness-id =
# IDs of multiple witnesses controlled by this node (e.g. ["1.6.5", "1.6.6"], quotes are required)
witness-ids = ["1.6.1", "1.6.2", "1.6.3", "1.6.4", "1.6.5", "1.6.6", "1.6.7", "1.6.8", "1.6.9", "1.6.10", "1.6.11"]
# Tuple of [PublicKey, WIF private key] (may specify multiple times)
private-key = ["TEST6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV","5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3"]
# Account ID to track history for (may specify multiple times)
# track-account =
# Keep only those operations in memory that are related to account history tracking
# partial-operations =
# Maximum number of operations per account will be kept in memory
# max-ops-per-account =
# Track market history by grouping orders into buckets of equal size measured in seconds specified as a JSON array of numbers
bucket-size = [15,60,300,3600,86400]
# How far back in time to track history for each bucket size, measured in the number of buckets (default: 1000)
history-per-size = 1000
# declare an appender named "stderr" that writes messages to the console
[log.console_appender.stderr]
stream=std_error
# declare an appender named "p2p" that writes messages to p2p.log
[log.file_appender.p2p]
filename=logs/p2p/p2p.log
# filename can be absolute or relative to this config file
# route any messages logged to the default logger to the "stderr" logger we
# declared above, if they are info level are higher
[logger.default]
level=info
appenders=stderr
# route messages sent to the "p2p" logger to the p2p appender declared above
[logger.p2p]
level=info
appenders=p2p

View file

@ -1,496 +0,0 @@
{
"initial_timestamp": "2019-01-02T19:42:12",
"max_core_supply": "1000000000000000",
"initial_parameters": {
"current_fees": {
"parameters": [[
0,{
"fee": 2000000,
"price_per_kbyte": 1000000
}
],[
1,{
"fee": 500000
}
],[
2,{
"fee": 0
}
],[
3,{
"fee": 2000000
}
],[
4,{}
],[
5,{
"basic_fee": 500000,
"premium_fee": 200000000,
"price_per_kbyte": 100000
}
],[
6,{
"fee": 2000000,
"price_per_kbyte": 100000
}
],[
7,{
"fee": 300000
}
],[
8,{
"membership_annual_fee": 200000000,
"membership_lifetime_fee": 1000000000
}
],[
9,{
"fee": 50000000
}
],[
10,{
"symbol3": "50000000000",
"symbol4": "30000000000",
"long_symbol": 500000000,
"price_per_kbyte": 10
}
],[
11,{
"fee": 50000000,
"price_per_kbyte": 10
}
],[
12,{
"fee": 50000000
}
],[
13,{
"fee": 50000000
}
],[
14,{
"fee": 2000000,
"price_per_kbyte": 100000
}
],[
15,{
"fee": 2000000
}
],[
16,{
"fee": 100000
}
],[
17,{
"fee": 10000000
}
],[
18,{
"fee": 50000000
}
],[
19,{
"fee": 100000
}
],[
20,{
"fee": 500000000
}
],[
21,{
"fee": 2000000
}
],[
22,{
"fee": 2000000,
"price_per_kbyte": 10
}
],[
23,{
"fee": 2000000,
"price_per_kbyte": 10
}
],[
24,{
"fee": 100000
}
],[
25,{
"fee": 100000
}
],[
26,{
"fee": 100000
}
],[
27,{
"fee": 2000000,
"price_per_kbyte": 10
}
],[
28,{
"fee": 0
}
],[
29,{
"fee": 500000000
}
],[
30,{
"fee": 2000000
}
],[
31,{
"fee": 100000
}
],[
32,{
"fee": 100000
}
],[
33,{
"fee": 2000000
}
],[
34,{
"fee": 500000000
}
],[
35,{
"fee": 100000,
"price_per_kbyte": 10
}
],[
36,{
"fee": 100000
}
],[
37,{}
],[
38,{
"fee": 2000000,
"price_per_kbyte": 10
}
],[
39,{
"fee": 500000,
"price_per_output": 500000
}
],[
40,{
"fee": 500000,
"price_per_output": 500000
}
],[
41,{
"fee": 500000
}
],[
42,{}
],[
43,{
"fee": 2000000
}
],[
44,{}
],[
45,{
"fee": 100000
}
],[
46,{
"fee": 100000
}
],[
47,{
"fee": 100000
}
],[
48,{
"fee": 50000000
}
],[
49,{
"distribution_base_fee": 0,
"distribution_fee_per_holder": 0
}
],[
50,{}
],[
51,{
"fee": 100000
}
],[
52,{
"fee": 100000
}
],[
53,{
"fee": 100000
}
],[
54,{
"fee": 100000
}
],[
55,{
"fee": 100000
}
],[
56,{
"fee": 100000
}
],[
57,{
"fee": 100000
}
],[
58,{
"fee": 100000
}
],[
59,{
"fee": 100000
}
],[
60,{
"fee": 100000
}
],[
61,{
"fee": 100000
}
],[
62,{
"fee": 1000
}
],[
63,{
"fee": 100000
}
],[
64,{}
],[
65,{}
],[
66,{
"fee": 100000
}
],[
67,{}
],[
68,{
"fee": 0
}
],[
69,{}
],[
70,{
"fee": 100000
}
],[
71,{
"fee": 100000
}
],[
72,{
"fee": 100000
}
],[
73,{
"fee": 100000
}
],[
74,{
"fee": 100000
}
],[
75,{}
],[
76,{}
]
],
"scale": 10000
},
"block_interval": 3,
"maintenance_interval": 900,
"maintenance_skip_slots": 3,
"committee_proposal_review_period": 2000,
"maximum_transaction_size": 2048,
"maximum_block_size": 1228800000,
"maximum_time_until_expiration": 86400,
"maximum_proposal_lifetime": 2419200,
"maximum_asset_whitelist_authorities": 10,
"maximum_asset_feed_publishers": 10,
"maximum_witness_count": 1001,
"maximum_committee_count": 1001,
"maximum_authority_membership": 10,
"reserve_percent_of_fee": 2000,
"network_percent_of_fee": 2000,
"lifetime_referrer_percent_of_fee": 3000,
"cashback_vesting_period_seconds": 31536000,
"cashback_vesting_threshold": 10000000,
"count_non_member_votes": true,
"allow_non_member_whitelists": false,
"witness_pay_per_block": 1000000,
"worker_budget_per_day": "50000000000",
"max_predicate_opcode": 1,
"fee_liquidation_threshold": 10000000,
"accounts_per_fee_scale": 1000,
"account_fee_scale_bitshifts": 4,
"max_authority_depth": 2,
"witness_schedule_algorithm": 1,
"min_round_delay": 0,
"max_round_delay": 600,
"min_time_per_commit_move": 0,
"max_time_per_commit_move": 600,
"min_time_per_reveal_move": 0,
"max_time_per_reveal_move": 600,
"rake_fee_percentage": 300,
"maximum_registration_deadline": 2592000,
"maximum_players_in_tournament": 256,
"maximum_tournament_whitelist_length": 1000,
"maximum_tournament_start_time_in_future": 2419200,
"maximum_tournament_start_delay": 604800,
"maximum_tournament_number_of_wins": 100,
"extensions": {}
},
"initial_bts_accounts": [],
"initial_accounts": [{
"name": "init0",
"owner_key": "TEST6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV",
"active_key": "TEST6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV",
"is_lifetime_member": true
},{
"name": "init1",
"owner_key": "TEST6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV",
"active_key": "TEST6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV",
"is_lifetime_member": true
},{
"name": "init2",
"owner_key": "TEST6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV",
"active_key": "TEST6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV",
"is_lifetime_member": true
},{
"name": "init3",
"owner_key": "TEST6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV",
"active_key": "TEST6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV",
"is_lifetime_member": true
},{
"name": "init4",
"owner_key": "TEST6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV",
"active_key": "TEST6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV",
"is_lifetime_member": true
},{
"name": "init5",
"owner_key": "TEST6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV",
"active_key": "TEST6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV",
"is_lifetime_member": true
},{
"name": "init6",
"owner_key": "TEST6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV",
"active_key": "TEST6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV",
"is_lifetime_member": true
},{
"name": "init7",
"owner_key": "TEST6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV",
"active_key": "TEST6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV",
"is_lifetime_member": true
},{
"name": "init8",
"owner_key": "TEST6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV",
"active_key": "TEST6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV",
"is_lifetime_member": true
},{
"name": "init9",
"owner_key": "TEST6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV",
"active_key": "TEST6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV",
"is_lifetime_member": true
},{
"name": "init10",
"owner_key": "TEST6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV",
"active_key": "TEST6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV",
"is_lifetime_member": true
},{
"name": "nathan",
"owner_key": "TEST6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV",
"active_key": "TEST6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV",
"is_lifetime_member": false
}
],
"initial_assets": [],
"initial_balances": [{
"owner": "TESTFAbAx7yuxt725qSZvfwWqkdCwp9ZnUama",
"asset_symbol": "TEST",
"amount": "1000000000000000"
}
],
"initial_vesting_balances": [],
"initial_active_witnesses": 11,
"initial_witness_candidates": [{
"owner_name": "init0",
"block_signing_key": "TEST6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV"
},{
"owner_name": "init1",
"block_signing_key": "TEST6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV"
},{
"owner_name": "init2",
"block_signing_key": "TEST6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV"
},{
"owner_name": "init3",
"block_signing_key": "TEST6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV"
},{
"owner_name": "init4",
"block_signing_key": "TEST6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV"
},{
"owner_name": "init5",
"block_signing_key": "TEST6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV"
},{
"owner_name": "init6",
"block_signing_key": "TEST6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV"
},{
"owner_name": "init7",
"block_signing_key": "TEST6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV"
},{
"owner_name": "init8",
"block_signing_key": "TEST6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV"
},{
"owner_name": "init9",
"block_signing_key": "TEST6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV"
},{
"owner_name": "init10",
"block_signing_key": "TEST6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV"
}
],
"initial_committee_candidates": [{
"owner_name": "init0"
},{
"owner_name": "init1"
},{
"owner_name": "init2"
},{
"owner_name": "init3"
},{
"owner_name": "init4"
},{
"owner_name": "init5"
},{
"owner_name": "init6"
},{
"owner_name": "init7"
},{
"owner_name": "init8"
},{
"owner_name": "init9"
},{
"owner_name": "init10"
}
],
"initial_worker_candidates": [],
"initial_chain_id": "aa34045518f1469a28fa4578240d5f039afa9959c0b95ce3b39674efa691fb21",
"immutable_parameters": {
"min_committee_member_count": 11,
"min_witness_count": 11,
"num_special_accounts": 0,
"num_special_assets": 0
}
}

View file

@ -0,0 +1,166 @@
/*
* Copyright (c) 2018 oxarbitrage, and contributors.
*
* The MIT License
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <boost/test/unit_test.hpp>
#include <graphene/app/database_api.hpp>
#include <graphene/chain/exceptions.hpp>
#include <iostream>
#include "../common/database_fixture.hpp"
using namespace graphene::chain;
using namespace graphene::chain::test;
BOOST_FIXTURE_TEST_SUITE(voting_tests, database_fixture)
BOOST_AUTO_TEST_CASE(last_voting_date)
{
try
{
ACTORS((alice));
transfer(committee_account, alice_id, asset(100));
// we are going to vote for this witness
auto witness1 = witness_id_type(1)(db);
auto stats_obj = alice_id(db).statistics(db);
BOOST_CHECK_EQUAL(stats_obj.last_vote_time.sec_since_epoch(), 0);
// alice votes
graphene::chain::account_update_operation op;
op.account = alice_id;
op.new_options = alice.options;
op.new_options->votes.insert(witness1.vote_id);
trx.operations.push_back(op);
sign(trx, alice_private_key);
PUSH_TX( db, trx, ~0 );
auto now = db.head_block_time().sec_since_epoch();
// last_vote_time is updated for alice
stats_obj = alice_id(db).statistics(db);
BOOST_CHECK_EQUAL(stats_obj.last_vote_time.sec_since_epoch(), now);
} FC_LOG_AND_RETHROW()
}
BOOST_AUTO_TEST_CASE(last_voting_date_proxy)
{
try
{
ACTORS((alice)(proxy)(bob));
transfer(committee_account, alice_id, asset(100));
transfer(committee_account, bob_id, asset(200));
transfer(committee_account, proxy_id, asset(300));
generate_block();
// witness to vote for
auto witness1 = witness_id_type(1)(db);
// round1: alice changes proxy, this is voting activity
{
graphene::chain::account_update_operation op;
op.account = alice_id;
op.new_options = alice_id(db).options;
op.new_options->voting_account = proxy_id;
trx.operations.push_back(op);
sign(trx, alice_private_key);
PUSH_TX( db, trx, ~0 );
}
// alice last_vote_time is updated
auto alice_stats_obj = alice_id(db).statistics(db);
auto round1 = db.head_block_time().sec_since_epoch();
BOOST_CHECK_EQUAL(alice_stats_obj.last_vote_time.sec_since_epoch(), round1);
generate_block();
// round 2: alice update account but no proxy or voting changes are done
{
graphene::chain::account_update_operation op;
op.account = alice_id;
op.new_options = alice_id(db).options;
trx.operations.push_back(op);
sign(trx, alice_private_key);
set_expiration( db, trx );
PUSH_TX( db, trx, ~0 );
}
// last_vote_time is not updated
auto round2 = db.head_block_time().sec_since_epoch();
alice_stats_obj = alice_id(db).statistics(db);
BOOST_CHECK_EQUAL(alice_stats_obj.last_vote_time.sec_since_epoch(), round1);
generate_block();
// round 3: bob votes
{
graphene::chain::account_update_operation op;
op.account = bob_id;
op.new_options = bob_id(db).options;
op.new_options->votes.insert(witness1.vote_id);
trx.operations.push_back(op);
sign(trx, bob_private_key);
set_expiration( db, trx );
PUSH_TX(db, trx, ~0);
}
// last_vote_time for bob is updated as he voted
auto round3 = db.head_block_time().sec_since_epoch();
auto bob_stats_obj = bob_id(db).statistics(db);
BOOST_CHECK_EQUAL(bob_stats_obj.last_vote_time.sec_since_epoch(), round3);
generate_block();
// round 4: proxy votes
{
graphene::chain::account_update_operation op;
op.account = proxy_id;
op.new_options = proxy_id(db).options;
op.new_options->votes.insert(witness1.vote_id);
trx.operations.push_back(op);
sign(trx, proxy_private_key);
PUSH_TX(db, trx, ~0);
}
// proxy just voted so the last_vote_time is updated
auto round4 = db.head_block_time().sec_since_epoch();
auto proxy_stats_obj = proxy_id(db).statistics(db);
BOOST_CHECK_EQUAL(proxy_stats_obj.last_vote_time.sec_since_epoch(), round4);
// alice haves proxy, proxy votes but last_vote_time is not updated for alice
alice_stats_obj = alice_id(db).statistics(db);
BOOST_CHECK_EQUAL(alice_stats_obj.last_vote_time.sec_since_epoch(), round1);
// bob haves nothing to do with proxy so last_vote_time is not updated
bob_stats_obj = bob_id(db).statistics(db);
BOOST_CHECK_EQUAL(bob_stats_obj.last_vote_time.sec_since_epoch(), round3);
} FC_LOG_AND_RETHROW()
}
BOOST_AUTO_TEST_SUITE_END()