Alpha/Tests/delegation: add double delegation when empty test

Slight improvement of double delegation test
This commit is contained in:
bruno 2018-06-28 16:55:24 +02:00 committed by Benjamin Canou
parent a2bc2c4aad
commit 1b6eca4d89

View File

@ -893,13 +893,41 @@ let double_registration () =
(* credit 1μꜩ+ check balance *)
Op.transaction (I i) bootstrap impl_contract (Tez.one_mutez) >>=? fun create_contract ->
Incremental.add_operation i create_contract >>=? fun i ->
(* return_unit *)
Assert.balance_is ~loc:__LOC__ (I i) impl_contract Tez.one_mutez >>=? fun _ ->
(* self-delegation *)
Op.delegation (I i) impl_contract (Some pkh) >>=? fun self_delegation ->
Incremental.add_operation i self_delegation >>=? fun i ->
(* second self-delegation *)
Op.delegation (I i) impl_contract (Some pkh) >>=? fun second_registration ->
Incremental.add_operation i second_registration >>= fun err ->
Assert.proto_error ~loc:__LOC__ err (function
| Delegate_storage.Active_delegate -> true
| _ -> false)
(* with implicit contract emptied after first self-delegation *)
let double_registration_when_empty () =
Context.init 1 >>=? fun (b, bootstrap_contracts) ->
Incremental.begin_construction b >>=? fun i ->
let bootstrap = List.hd bootstrap_contracts in
let account = Account.new_account () in
let pkh = Account.(account.pkh) in
let impl_contract = Contract.implicit_contract pkh in
(* credit 1μꜩ+ check balance *)
Op.transaction (I i) bootstrap impl_contract Tez.one_mutez >>=? fun create_contract ->
Incremental.add_operation i create_contract >>=? fun i ->
Assert.balance_is ~loc:__LOC__ (I i) impl_contract Tez.one_mutez >>=? fun _ ->
(* self delegation *)
Op.delegation (I i) impl_contract (Some pkh) >>=? fun self_delegation ->
Incremental.add_operation i self_delegation >>=? fun i ->
(* empty the delegate account *)
Op.transaction (I i) impl_contract bootstrap Tez.one_mutez >>=? fun empty_contract ->
Incremental.add_operation i empty_contract >>=? fun i ->
Assert.balance_is ~loc:__LOC__ (I i) impl_contract Tez.zero >>=? fun _ ->
(* second self-delegation *)
Op.delegation (I i) impl_contract (Some pkh) >>=? fun second_registration ->
Incremental.add_operation i second_registration >>= fun err ->
Assert.proto_error ~loc:__LOC__ err (function
| Delegate_storage.Active_delegate -> true
| _ -> false)
@ -983,6 +1011,7 @@ let tests_delegate_registration =
(*** double registration ***)
Test.tztest "double registration" `Quick double_registration ;
Test.tztest "double registration when delegate account is emptied" `Quick double_registration_when_empty ;
]