Alpha/Tests/delegation: deactivation and self-delegation when empty
This commit is contained in:
parent
523d44354c
commit
1368eed80c
@ -129,6 +129,46 @@ let deactivation_then_self_delegation () =
|
|||||||
Assert.equal_tez ~loc:__LOC__ start_balance balance >>=? fun () ->
|
Assert.equal_tez ~loc:__LOC__ start_balance balance >>=? fun () ->
|
||||||
check_rolls b deactivated_account
|
check_rolls b deactivated_account
|
||||||
|
|
||||||
|
let deactivation_then_empty_then_self_delegation () =
|
||||||
|
run_until_deactivation () >>=?
|
||||||
|
fun (b, ((deactivated_contract, deactivated_account) as deactivated, _start_balance),
|
||||||
|
(_a2, m2)) ->
|
||||||
|
(* empty the contract *)
|
||||||
|
Context.Contract.balance (B b) deactivated_contract >>=? fun balance ->
|
||||||
|
let sink_account = Account.new_account () in
|
||||||
|
let sink_contract = Contract.implicit_contract sink_account.pkh in
|
||||||
|
Op.transaction (B b) deactivated_contract sink_contract balance >>=? fun empty_contract ->
|
||||||
|
Block.bake ~policy:(By_account m2.pkh) ~operation:empty_contract b >>=? fun b ->
|
||||||
|
(* self delegation *)
|
||||||
|
Op.delegation (B b) deactivated_contract (Some deactivated_account.pkh) >>=? fun self_delegation ->
|
||||||
|
Block.bake ~policy:(By_account m2.pkh) ~operation:self_delegation b >>=? fun b ->
|
||||||
|
|
||||||
|
check_activate_staking_balance ~loc:__LOC__ ~deactivated:false b deactivated >>=? fun () ->
|
||||||
|
Context.Contract.balance (B b) deactivated_contract >>=? fun balance ->
|
||||||
|
Assert.equal_tez ~loc:__LOC__ Tez.zero balance >>=? fun () ->
|
||||||
|
check_rolls b deactivated_account
|
||||||
|
|
||||||
|
let deactivation_then_empty_then_self_delegation_then_recredit () =
|
||||||
|
run_until_deactivation () >>=?
|
||||||
|
fun (b, ((deactivated_contract, deactivated_account) as deactivated, start_balance),
|
||||||
|
(_a2, m2)) ->
|
||||||
|
(* empty the contract *)
|
||||||
|
Context.Contract.balance (B b) deactivated_contract >>=? fun balance ->
|
||||||
|
let sink_account = Account.new_account () in
|
||||||
|
let sink_contract = Contract.implicit_contract sink_account.pkh in
|
||||||
|
Op.transaction (B b) deactivated_contract sink_contract balance >>=? fun empty_contract ->
|
||||||
|
Block.bake ~policy:(By_account m2.pkh) ~operation:empty_contract b >>=? fun b ->
|
||||||
|
(* self delegation *)
|
||||||
|
Op.delegation (B b) deactivated_contract (Some deactivated_account.pkh) >>=? fun self_delegation ->
|
||||||
|
Block.bake ~policy:(By_account m2.pkh) ~operation:self_delegation b >>=? fun b ->
|
||||||
|
(* recredit *)
|
||||||
|
Op.transaction (B b) sink_contract deactivated_contract balance >>=? fun recredit_contract ->
|
||||||
|
Block.bake ~policy:(By_account m2.pkh) ~operation:recredit_contract b >>=? fun b ->
|
||||||
|
|
||||||
|
check_activate_staking_balance ~loc:__LOC__ ~deactivated:false b deactivated >>=? fun () ->
|
||||||
|
Context.Contract.balance (B b) deactivated_contract >>=? fun balance ->
|
||||||
|
Assert.equal_tez ~loc:__LOC__ start_balance balance >>=? fun () ->
|
||||||
|
check_rolls b deactivated_account
|
||||||
|
|
||||||
let delegation () =
|
let delegation () =
|
||||||
Context.init 2 >>=? fun (b,accounts) ->
|
Context.init 2 >>=? fun (b,accounts) ->
|
||||||
@ -180,5 +220,7 @@ let tests = [
|
|||||||
Test.tztest "simple staking rights after baking" `Quick (simple_staking_rights_after_baking) ;
|
Test.tztest "simple staking rights after baking" `Quick (simple_staking_rights_after_baking) ;
|
||||||
Test.tztest "deactivation then bake" `Quick (deactivation_then_bake) ;
|
Test.tztest "deactivation then bake" `Quick (deactivation_then_bake) ;
|
||||||
Test.tztest "deactivation then self delegation" `Quick (deactivation_then_self_delegation) ;
|
Test.tztest "deactivation then self delegation" `Quick (deactivation_then_self_delegation) ;
|
||||||
|
Test.tztest "deactivation then empty then self delegation" `Quick (deactivation_then_empty_then_self_delegation) ;
|
||||||
|
Test.tztest "deactivation then empty then self delegation then recredit" `Quick (deactivation_then_empty_then_self_delegation_then_recredit) ;
|
||||||
Test.tztest "delegation" `Quick (delegation) ;
|
Test.tztest "delegation" `Quick (delegation) ;
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user