Fix SON operation tests
This commit is contained in:
parent
a135e4da9e
commit
9278917be0
2 changed files with 24 additions and 15 deletions
|
|
@ -17,18 +17,20 @@ void_result create_son_evaluator::do_evaluate(const son_create_operation& op)
|
|||
(op.deposit == vesting_balance_id_type(242)) &&
|
||||
(op.pay_vb == vesting_balance_id_type(242));
|
||||
if (!special_son_case) {
|
||||
FC_ASSERT(op.deposit(db()).owner == op.owner_account);
|
||||
FC_ASSERT(op.deposit(db()).balance_type == vesting_balance_type::son, "Deposit vesting must be of type SON");
|
||||
FC_ASSERT(op.deposit(db()).get_asset_amount() >= db().get_global_properties().parameters.son_vesting_amount(),
|
||||
vesting_balance_object vbo = op.deposit(db());
|
||||
FC_ASSERT(vbo.owner == op.owner_account);
|
||||
FC_ASSERT(vbo.balance_type == vesting_balance_type::son, "Deposit vesting must be of type SON");
|
||||
FC_ASSERT(vbo.get_asset_amount() >= db().get_global_properties().parameters.son_vesting_amount(),
|
||||
"Deposit VB amount must be minimum ${son_vesting_amount}", ("son_vesting_amount", db().get_global_properties().parameters.son_vesting_amount()));
|
||||
}
|
||||
FC_ASSERT(op.deposit(db()).policy.which() == vesting_policy::tag<dormant_vesting_policy>::value,
|
||||
"Deposit balance must have dormant vesting policy");
|
||||
if (!special_son_case) {
|
||||
FC_ASSERT(op.pay_vb(db()).owner == op.owner_account);
|
||||
FC_ASSERT(op.pay_vb(db()).balance_type == vesting_balance_type::normal, "Payment vesting balance must be of type NORMAL");
|
||||
FC_ASSERT(op.pay_vb(db()).policy.which() == vesting_policy::tag<linear_vesting_policy>::value,
|
||||
"Deposit balance must have linear vesting policy");
|
||||
vesting_balance_object vbo = op.pay_vb(db());
|
||||
FC_ASSERT(vbo.owner == op.owner_account);
|
||||
FC_ASSERT(vbo.balance_type == vesting_balance_type::normal, "Payment vesting balance must be of type NORMAL");
|
||||
FC_ASSERT(vbo.policy.which() == vesting_policy::tag<linear_vesting_policy>::value,
|
||||
"Payment balance must have linear vesting policy");
|
||||
}
|
||||
return void_result();
|
||||
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||
|
|
@ -68,18 +70,20 @@ void_result update_son_evaluator::do_evaluate(const son_update_operation& op)
|
|||
FC_ASSERT( idx.find(op.son_id) != idx.end() );
|
||||
|
||||
if(op.new_deposit.valid()) {
|
||||
FC_ASSERT((*op.new_deposit)(db()).owner == op.owner_account);
|
||||
FC_ASSERT((*op.new_deposit)(db()).balance_type == vesting_balance_type::son, "Deposit vesting must be of type SON");
|
||||
FC_ASSERT((*op.new_deposit)(db()).get_asset_amount() >= db().get_global_properties().parameters.son_vesting_amount(),
|
||||
vesting_balance_object vbo = (*op.new_deposit)(db());
|
||||
FC_ASSERT(vbo.owner == op.owner_account);
|
||||
FC_ASSERT(vbo.balance_type == vesting_balance_type::son, "Deposit vesting must be of type SON");
|
||||
FC_ASSERT(vbo.get_asset_amount() >= db().get_global_properties().parameters.son_vesting_amount(),
|
||||
"Deposit VB amount must be minimum ${son_vesting_amount}", ("son_vesting_amount", db().get_global_properties().parameters.son_vesting_amount()));
|
||||
FC_ASSERT((*op.new_deposit)(db()).policy.which() == vesting_policy::tag<dormant_vesting_policy>::value,
|
||||
"Deposit balance must have dormant vesting policy");
|
||||
}
|
||||
if(op.new_pay_vb.valid()) {
|
||||
FC_ASSERT((*op.new_pay_vb)(db()).owner == op.owner_account);
|
||||
FC_ASSERT((*op.new_pay_vb)(db()).balance_type == vesting_balance_type::normal, "Payment vesting balance must be of type NORMAL");
|
||||
FC_ASSERT((*op.new_pay_vb)(db()).policy.which() == vesting_policy::tag<linear_vesting_policy>::value,
|
||||
"Deposit balance must have linear vesting policy");
|
||||
vesting_balance_object vbo = (*op.new_pay_vb)(db());
|
||||
FC_ASSERT(vbo.owner == op.owner_account);
|
||||
FC_ASSERT(vbo.balance_type == vesting_balance_type::normal, "Payment vesting balance must be of type NORMAL");
|
||||
FC_ASSERT(vbo.policy.which() == vesting_policy::tag<linear_vesting_policy>::value,
|
||||
"Payment balance must have linear vesting policy");
|
||||
}
|
||||
return void_result();
|
||||
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ BOOST_AUTO_TEST_CASE( create_son_test ) {
|
|||
op.amount = asset(10*GRAPHENE_BLOCKCHAIN_PRECISION);
|
||||
op.balance_type = vesting_balance_type::son;
|
||||
op.policy = dormant_vesting_policy_initializer {};
|
||||
trx.clear();
|
||||
trx.operations.push_back(op);
|
||||
|
||||
// amount in the son balance need to be at least 50
|
||||
|
|
@ -68,9 +69,10 @@ BOOST_AUTO_TEST_CASE( create_son_test ) {
|
|||
op.owner = alice_id;
|
||||
op.amount = asset(1*GRAPHENE_BLOCKCHAIN_PRECISION);
|
||||
op.balance_type = vesting_balance_type::normal;
|
||||
|
||||
op.policy = linear_vesting_policy_initializer {};
|
||||
op.validate();
|
||||
|
||||
trx.clear();
|
||||
trx.operations.push_back(op);
|
||||
trx.validate();
|
||||
processed_transaction ptx = PUSH_TX(db, trx, ~0);
|
||||
|
|
@ -93,9 +95,12 @@ BOOST_AUTO_TEST_CASE( create_son_test ) {
|
|||
op.pay_vb = payment;
|
||||
op.signing_key = alice_public_key;
|
||||
op.sidechain_public_keys = sidechain_public_keys;
|
||||
|
||||
trx.clear();
|
||||
trx.operations.push_back(op);
|
||||
sign(trx, alice_private_key);
|
||||
PUSH_TX(db, trx, ~0);
|
||||
trx.clear();
|
||||
}
|
||||
generate_block();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue