Esempio n. 1
0
    def test_multiple_transfers(self, client: Client, payer: str, source: str):
        """Test a multiple transfers to implicit accounts, with implicit
        accounts or a manager contract as source as per parametrization.
        """
        balance_source = client.get_mutez_balance(source)
        balance_bootstrap1 = client.get_mutez_balance('bootstrap1')
        balance_bootstrap3 = client.get_mutez_balance('bootstrap3')
        amount_1 = 10.1
        amount_mutez_1 = utils.mutez_of_tez(amount_1)
        amount_3 = 11.01
        amount_mutez_3 = utils.mutez_of_tez(amount_3)
        json_obj = [
            {"destination": "bootstrap1", "amount": str(amount_1)},
            {"destination": "bootstrap3", "amount": str(amount_3)},
        ]
        json_ops = json.dumps(json_obj, separators=(',', ':'))
        client.run(client.cmd_batch(source, json_ops))
        utils.bake(client, 'bootstrap5')
        new_balance_source = client.get_mutez_balance(source)
        new_balance_bootstrap1 = client.get_mutez_balance('bootstrap1')
        new_balance_bootstrap3 = client.get_mutez_balance('bootstrap3')

        if payer == source:
            fee_first_transfer = 403
            fee_second_transfer = 307
            source_fee_mutez = fee_first_transfer + fee_second_transfer
        else:
            source_fee_mutez = 0

        assert (
            balance_source - amount_mutez_1 - amount_mutez_3 - source_fee_mutez
            == new_balance_source
        )
        assert balance_bootstrap1 + amount_mutez_1 == new_balance_bootstrap1
        assert balance_bootstrap3 + amount_mutez_3 == new_balance_bootstrap3
Esempio n. 2
0
 def test_multiple_transfers(self, client):
     balance = client.get_mutez_balance('manager')
     balance_bootstrap2 = client.get_mutez_balance('bootstrap2')
     balance_bootstrap3 = client.get_mutez_balance('bootstrap3')
     amount_2 = 10.1
     amount_mutez_2 = utils.mutez_of_tez(amount_2)
     amount_3 = 11.01
     amount_mutez_3 = utils.mutez_of_tez(amount_3)
     json_obj = [
         {
             "destination": "bootstrap2",
             "amount": str(amount_2)
         },
         {
             "destination": "bootstrap3",
             "amount": str(amount_3)
         },
     ]
     json_ops = json.dumps(json_obj, separators=(',', ':'))
     client.run(client.cmd_batch('manager', json_ops))
     client.bake('bootstrap5', BAKE_ARGS)
     new_balance = client.get_mutez_balance('manager')
     new_balance_bootstrap2 = client.get_mutez_balance('bootstrap2')
     new_balance_bootstrap3 = client.get_mutez_balance('bootstrap3')
     fee_mutez = 810 + 714
     assert balance - amount_mutez_2 - amount_mutez_3 == new_balance
     assert (balance_bootstrap2 + amount_mutez_2 -
             fee_mutez == new_balance_bootstrap2)
     assert balance_bootstrap3 + amount_mutez_3 == new_balance_bootstrap3
Esempio n. 3
0
 def test_transfer_to_manager(self, client):
     balance = client.get_mutez_balance('manager')
     balance_bootstrap = client.get_mutez_balance('bootstrap2')
     amount = 10.001
     amount_mutez = utils.mutez_of_tez(amount)
     client.transfer(amount, 'bootstrap2', 'manager', ['--gas-limit', '15285'])
     client.bake('bootstrap5', BAKE_ARGS)
     new_balance = client.get_mutez_balance('manager')
     new_balance_bootstrap = client.get_mutez_balance('bootstrap2')
     fee = 0.00178
     fee_mutez = utils.mutez_of_tez(fee)
     assert balance + amount_mutez == new_balance
     assert (balance_bootstrap - fee_mutez - amount_mutez
             == new_balance_bootstrap)
Esempio n. 4
0
 def test_simple_transfer_from_manager_to_implicit(self, client):
     balance = client.get_mutez_balance('manager')
     balance_bootstrap = client.get_mutez_balance('bootstrap2')
     amount = 10.1
     amount_mutez = utils.mutez_of_tez(amount)
     client.transfer(amount, 'manager', 'bootstrap2',
                     ['--gas-limit', '26183'])
     client.bake('bootstrap5', BAKE_ARGS)
     new_balance = client.get_mutez_balance('manager')
     new_balance_bootstrap = client.get_mutez_balance('bootstrap2')
     fee = 0.002931
     fee_mutez = utils.mutez_of_tez(fee)
     assert balance - amount_mutez == new_balance
     assert (balance_bootstrap + amount_mutez -
             fee_mutez == new_balance_bootstrap)
Esempio n. 5
0
    def test_transfer_json_to_entrypoint_with_args(
        self, big_map_entrypoints: str, client: Client, payer: str, source: str
    ):
        """Test the multiple transfers command with a single transfer
        to a contract's entrypoint, with implicit accounts or a manager
        contract as source as per parametrization.
        """
        balance_source = client.get_mutez_balance(source)
        balance_payer = client.get_mutez_balance(payer)
        fee = 0.0123
        fee_mutez = utils.mutez_of_tez(fee)
        json_obj = [
            {
                "destination": big_map_entrypoints,
                "amount": "0",
                "fee": str(fee),
                "gas-limit": "65942",
                "storage-limit": "1024",
                "arg": '"Hello"',
                "entrypoint": "mem_right",
            }
        ]
        json_ops = json.dumps(json_obj, separators=(',', ':'))
        client.run(client.cmd_batch(source, json_ops))
        utils.bake(client, 'bootstrap5')
        new_balance_source = client.get_mutez_balance(source)
        new_balance_payer = client.get_mutez_balance(payer)

        if payer != source:
            assert balance_source == new_balance_source

        assert balance_payer - fee_mutez == new_balance_payer
Esempio n. 6
0
 def test_transfer_from_manager_to_manager(self, client):
     balance = client.get_mutez_balance('manager')
     balance_dest = client.get_mutez_balance('manager2')
     balance_bootstrap = client.get_mutez_balance('bootstrap2')
     amount = 10
     amount_mutez = utils.mutez_of_tez(amount)
     client.transfer(amount, 'manager', 'manager2',
                     ['--gas-limit', '44625'])
     client.bake('bootstrap5', BAKE_ARGS)
     new_balance = client.get_mutez_balance('manager')
     new_balance_dest = client.get_mutez_balance('manager2')
     new_balance_bootstrap = client.get_mutez_balance('bootstrap2')
     fee = 0.004804
     fee_mutez = utils.mutez_of_tez(fee)
     assert balance_bootstrap - fee_mutez == new_balance_bootstrap
     assert balance - amount_mutez == new_balance
     assert balance_dest + amount_mutez == new_balance_dest
Esempio n. 7
0
 def test_transfers_bootstraps5_bootstrap1(self, client: Client):
     bootstrap5 = constants.IDENTITIES['bootstrap5']['identity']
     all_deposits = client.frozen_deposits(bootstrap5)
     balance = client.get_mutez_balance('bootstrap5')
     assert balance + all_deposits == utils.mutez_of_tez(4000000.0)
     client.transfer(
         400000,
         'bootstrap5',
         'bootstrap1',
         ['--fee', '0', '--force-low-fee'],
     )
     utils.bake(client)
     client.transfer(
         400000,
         'bootstrap1',
         'bootstrap5',
         ['--fee', '0', '--force-low-fee'],
     )
     utils.bake(client)
     all_deposits = client.frozen_deposits(bootstrap5)
     assert client.get_mutez_balance(
         'bootstrap5') + all_deposits == utils.mutez_of_tez(4000000.0)
Esempio n. 8
0
 def test_transfer_json_to_entrypoint_with_args(self, client):
     balance = client.get_mutez_balance('manager')
     balance_bootstrap = client.get_mutez_balance('bootstrap2')
     fee = 0.0123
     fee_mutez = utils.mutez_of_tez(fee)
     json_obj = [{
         "destination": "target",
         "amount": "0",
         "fee": str(fee),
         "gas-limit": "65942",
         "storage-limit": "1024",
         "arg": 'Pair "hello" 42',
         "entrypoint": "add_left",
     }]
     json_ops = json.dumps(json_obj, separators=(',', ':'))
     client.run(client.cmd_batch('manager', json_ops))
     client.bake('bootstrap5', BAKE_ARGS)
     new_balance = client.get_mutez_balance('manager')
     new_balance_bootstrap = client.get_mutez_balance('bootstrap2')
     assert balance == new_balance
     assert balance_bootstrap - fee_mutez == new_balance_bootstrap
Esempio n. 9
0
 def test_balance(self, client: Client):
     bootstrap3 = constants.IDENTITIES['bootstrap3']['identity']
     deposit = client.frozen_deposits(bootstrap3)
     balance = client.get_mutez_balance('bootstrap3')
     assert balance + deposit == utils.mutez_of_tez(4000100.0)