提交 58b0d7f6 编写于 作者: K Khaled Al-Hassanieh

Fixed producer_info abi, bug in claimrewards

上级 58b78df6
......@@ -131,11 +131,14 @@
"name": "producer_info",
"base": "",
"fields": [
{"name":"owner", "type":"account_name"},
{"name":"total_votes", "type":"uint128"},
{"name":"packed_key", "type":"public_key"},
{"name":"per_block_payments", "type":"uint64"},
{"name":"last_claim_time", "type":"time"}
{"name":"owner", "type":"account_name"},
{"name":"total_votes", "type":"float64"},
{"name":"producer_key", "type":"public_key"},
{"name":"produced_blocks", "type":"uint32"},
{"name":"last_claim_time", "type":"time"},
{"name":"location", "type":"uint16"},
{"name":"time_became_active", "type":"time"},
{"name":"last_produced_block_time", "type":"time"}
]
},{
"name": "regproducer",
......
......@@ -51,7 +51,7 @@ namespace eosiosystem {
double total_votes = 0;
eosio::public_key producer_key; /// a packed public key object
uint32_t produced_blocks;
time last_rewards_claim = 0;
time last_claim_time = 0;
uint16_t location = 0;
block_timestamp time_became_active = 0;
block_timestamp last_produced_block_time = 0;
......@@ -62,7 +62,7 @@ namespace eosiosystem {
// explicit serialization macro is not necessary, used here only to improve compilation time
EOSLIB_SERIALIZE( producer_info, (owner)(total_votes)(producer_key)
(produced_blocks)(last_rewards_claim)
(produced_blocks)(last_claim_time)(location)
(time_became_active)(last_produced_block_time) )
};
......
......@@ -94,8 +94,8 @@ namespace eosiosystem {
auto prod = _producers.find( owner );
eosio_assert( prod != _producers.end(), "account name is not in producer list" );
if( prod->last_rewards_claim > 0 ) {
eosio_assert(now() >= prod->last_rewards_claim + seconds_per_day, "already claimed rewards within a day");
if( prod->last_claim_time > 0 ) {
eosio_assert(now() >= prod->last_claim_time + seconds_per_day, "already claimed rewards within a day");
}
auto parameters = _global.get();
......@@ -118,10 +118,10 @@ namespace eosiosystem {
_global.set( parameters, _self );
INLINE_ACTION_SENDER(eosio::token, transfer)( N(eosio.token), {N(eosio),N(active)},
{ N(eosio), owner, perblock_pay + perblock_pay, std::string("producer claiming rewards") } );
{ N(eosio), owner, perblock_pay + pervote_pay, std::string("producer claiming rewards") } );
_producers.modify( prod, 0, [&](auto& p) {
p.last_rewards_claim = now();
p.last_claim_time = now();
p.produced_blocks = 0;
});
......
......@@ -1169,8 +1169,6 @@ BOOST_FIXTURE_TEST_CASE(producer_pay, eosio_system_tester) try {
issue( "alice", "10000.0000 EOS", config::system_account_name);
BOOST_REQUIRE_EQUAL( asset::from_string("10000.0000 EOS"), get_balance( "alice" ) );
fc::variant params = producer_parameters_example(50);
// 1 block produced
BOOST_REQUIRE_EQUAL(success(), regproducer(N(alice)));
......@@ -1178,8 +1176,6 @@ BOOST_FIXTURE_TEST_CASE(producer_pay, eosio_system_tester) try {
BOOST_REQUIRE_EQUAL("alice", prod["owner"].as_string());
BOOST_REQUIRE_EQUAL(0, prod["total_votes"].as_uint64());
REQUIRE_EQUAL_OBJECTS(params, prod["prefs"]);
issue("bob", "2000.0000 EOS", config::system_account_name);
BOOST_REQUIRE_EQUAL( asset::from_string("2000.0000 EOS"), get_balance( "bob" ) );
......@@ -1198,15 +1194,16 @@ BOOST_FIXTURE_TEST_CASE(producer_pay, eosio_system_tester) try {
)
);
produce_blocks(10);
produce_blocks(20);
prod = get_producer_info("alice");
BOOST_REQUIRE(prod["per_block_payments"].as_uint64() > 0);
// this test fails as there isn't enough total activated stake and onblock is a noop
BOOST_REQUIRE(prod["produced_blocks"].as<uint32_t>() > 0);
BOOST_REQUIRE_EQUAL(success(), push_action(N(alice), N(claimrewards), mvo()
("owner", "alice")
)
);
prod = get_producer_info("alice");
BOOST_REQUIRE_EQUAL(0, prod["per_block_payments"].as_uint64());
BOOST_REQUIRE_EQUAL(0, prod["produced_blocks"].as<uint32_t>());
} FC_LOG_AND_RETHROW()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册