def test_get_allowance_callback(self, client: Client, token_contract: str, view): reset_viewer(client, view) client.fa12_get_allowance_callback(token_contract, 'bootstrap2', 'bootstrap3', view, BURN_CAP_ARGS) client.bake('bootstrap5', BAKE_ARGS) utils.assert_storage_contains(client, view, '0')
def test_split_bytes(self, client_regtest_scrubbed: ClientRegression): client = client_regtest_scrubbed init_with_transfer( client, path.join(OPCODES_CONTRACT_PATH, 'split_bytes.tz'), '{}', 1000, 'bootstrap1', ) client.transfer( 0, 'bootstrap1', 'split_bytes', ['-arg', '0xaabbcc', '--burn-cap', '10'], ) bake(client) assert_storage_contains(client, 'split_bytes', '{ 0xaa ; 0xbb ; 0xcc }') client.transfer( 0, 'bootstrap1', 'split_bytes', ['-arg', '0xddeeff', '--burn-cap', '10'], ) bake(client) assert_storage_contains(client, 'split_bytes', '{ 0xaa ; 0xbb ; 0xcc ; 0xdd ; 0xee ; 0xff }')
def test_ticket_read(self, client): """Test TICKETS""" init_with_transfer( client, path.join(OPCODES_CONTRACT_PATH, 'ticketer.tz'), '42', 100, 'bootstrap1', 'ticketer_read', ) bake(client) ticketer_addr = client.get_contract_address('ticketer_read') init_with_transfer( client, path.join(OPCODES_CONTRACT_PATH, 'ticket_read.tz'), '"' + ticketer_addr + '"', 100, 'bootstrap1', 'reader', ) bake(client) reader_addr = client.get_contract_address('reader') client.transfer( 100, 'bootstrap1', 'ticketer_read', ['-arg', '"' + reader_addr + '"', '--burn-cap', '10'], ) bake(client) assert_storage_contains(client, "reader", '"' + ticketer_addr + '"')
def test_sender(self, client_regtest_scrubbed: ClientRegression): client = client_regtest_scrubbed client.set_regtest(None) init_store = IDENTITIES['bootstrap4']['identity'] init_with_transfer( client, path.join(OPCODES_CONTRACT_PATH, 'sender.tz'), f'"{init_store}"', 1000, 'bootstrap1', ) # direct transfer to the contract client.transfer(0, 'bootstrap2', 'sender', ['--burn-cap', '10']) bake(client) sender_addr = IDENTITIES['bootstrap2']['identity'] assert_storage_contains(client, 'sender', f'"{sender_addr}"') # indirect transfer to the contract through proxy contract_addr = client.get_contract_address('sender') proxy_addr = client.get_contract_address('proxy') client.transfer( 0, 'bootstrap2', 'proxy', ['--burn-cap', '10', '--arg', f'"{contract_addr}"'], ) bake(client) assert_storage_contains(client, 'sender', f'"{proxy_addr}"')
def test_split_string(self, client_regtest_scrubbed: ClientRegression): client = client_regtest_scrubbed init_with_transfer( client, path.join(OPCODES_CONTRACT_PATH, 'split_string.tz'), '{}', 1000, 'bootstrap1', ) client.transfer( 0, 'bootstrap1', 'split_string', ['-arg', '"abc"', '--burn-cap', '10'], ) bake(client) assert_storage_contains(client, 'split_string', '{ "a" ; "b" ; "c" }') client.transfer( 0, 'bootstrap1', 'split_string', ['-arg', '"def"', '--burn-cap', '10'], ) bake(client) assert_storage_contains(client, 'split_string', '{ "a" ; "b" ; "c" ; "d" ; "e" ; "f" }')
def test_store_input(self, client_regtest_scrubbed): client = client_regtest_scrubbed client.transfer(1000, "bootstrap1", KEY1, ['--burn-cap', '0.257']) bake(client) client.transfer(2000, "bootstrap1", KEY2, ['--burn-cap', '0.257']) bake(client) assert_balance(client, KEY1, 1000) assert_balance(client, KEY2, 2000) # Create a contract and transfer 100 ꜩ to it init_with_transfer(client, path.join(OPCODES_CONTRACT_PATH, 'store_input.tz'), '""', 100, 'bootstrap1') client.transfer(100, "bootstrap1", "store_input", ["-arg", '"abcdefg"', '--burn-cap', '10']) bake(client) assert_balance(client, "store_input", 200) assert_storage_contains(client, "store_input", '"abcdefg"') client.transfer(100, "bootstrap1", "store_input", ["-arg", '"xyz"', '--burn-cap', '10']) bake(client) assert_storage_contains(client, "store_input", '"xyz"')
def test_get_total_supply_callback(self, client: Client, token_contract: str, view): reset_viewer(client, view) client.fa12_get_total_supply_callback(token_contract, 'bootstrap2', view, BURN_CAP_ARGS) client.bake('bootstrap5', BAKE_ARGS) expected = '20000' utils.assert_storage_contains(client, view, expected)
def test_transfer_amount(self, client_regtest_scrubbed): client = client_regtest_scrubbed init_with_transfer( client, path.join(OPCODES_CONTRACT_PATH, 'transfer_amount.tz'), '0', 100, 'bootstrap1') client.transfer(500, "bootstrap1", 'transfer_amount', ['-arg', 'Unit', '--burn-cap', '10']) bake(client) assert_storage_contains(client, "transfer_amount", '500000000')
def test_now(self, client_regtest_scrubbed): # Regtest is disabled for this test, since one would need to # scrub storage for this one as it changes (the timestamp) # on every run. client = client_regtest_scrubbed client.set_regtest(None) init_with_transfer(client, path.join(OPCODES_CONTRACT_PATH, 'store_now.tz'), '"2017-07-13T09:19:01Z"', 100, 'bootstrap1') client.transfer(500, "bootstrap1", 'store_now', ['-arg', 'Unit', '--burn-cap', '10']) bake(client) assert_storage_contains(client, 'store_now', f'"{client.get_now()}"')
def test_self(self, client_regtest_scrubbed): # Regtest is disabled for this test, since one would need to # scrub storage for this one as it changes (the contract # address) on every run. client = client_regtest_scrubbed client.set_regtest(None) init_with_transfer(client, path.join(OPCODES_CONTRACT_PATH, 'self.tz'), '"tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx"', 1000, 'bootstrap1') client.transfer(0, 'bootstrap1', 'self', ['--burn-cap', '10']) bake(client) self_addr = client.get_contract_address('self') assert_storage_contains(client, 'self', f'"{self_addr}"')
def test_guestbook(self, client: Client): contract = path.join(MACROS_CONTRACT_PATH, 'guestbook.tz') init_with_transfer( client, contract, '{ Elt "tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx" None }', 100, 'bootstrap1', ) assert_transfer_failwith( client, 0, 'bootstrap2', 'guestbook', ['--arg', '"Pas moi"', '--burn-cap', '10'], ) client.transfer( 0, 'bootstrap1', 'guestbook', ['-arg', '"Coucou"', '--burn-cap', '10'], ) bake(client) assert_storage_contains( client, 'guestbook', '{ Elt "tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx" (Some "Coucou") }', ) assert_transfer_failwith( client, 0, 'bootstrap3', 'guestbook', ['--arg', '"Pas moi non plus"', '--burn-cap', '10'], ) assert_transfer_failwith( client, 0, 'bootstrap1', 'guestbook', ['--arg', '"Recoucou ?"', '--burn-cap', '10'], )
def test_source(self, client_regtest_scrubbed): client = client_regtest_scrubbed init_store = IDENTITIES['bootstrap4']['identity'] init_with_transfer(client, path.join(OPCODES_CONTRACT_PATH, 'source.tz'), f'"{init_store}"', 1000, 'bootstrap1') # direct transfer to the contract client.transfer(0, 'bootstrap2', 'source', ['--burn-cap', '10']) bake(client) source_addr = IDENTITIES['bootstrap2']['identity'] assert_storage_contains(client, 'source', f'"{source_addr}"') # indirect transfer to the contract through proxy contract_addr = client.get_contract_address('source') client.transfer(0, 'bootstrap2', 'proxy', ['--burn-cap', '10', '--arg', f'"{contract_addr}"']) bake(client) assert_storage_contains(client, 'source', f'"{source_addr}"')
def test_level(self, client_regtest_scrubbed): client = client_regtest_scrubbed init_with_transfer( client, path.join(OPCODES_CONTRACT_PATH, 'level.tz'), '9999999', 100, 'bootstrap1', ) bake(client) client.transfer(500, "bootstrap1", 'level', ['-arg', 'Unit', '--burn-cap', '10']) bake(client) level = client.get_level() slevel = str(level) assert_storage_contains(client, 'level', slevel) bake(client) bake(client) # checks the storage hasn't changed even though the current level has assert_storage_contains(client, 'level', slevel) # Run again to check the storage gets updated client.transfer(500, "bootstrap1", 'level', ['-arg', 'Unit', '--burn-cap', '10']) bake(client) assert_storage_contains(client, 'level', str(level + 3))