def test_token_registration(blockchain_type, raiden_network, tester_state): if blockchain_type == 'tester': pytest.skip( 'current version of the pyethereum dependency does not support the REVERT opcode' ) node1 = raiden_network[0] token_amount = 1000 token_address = node1.raiden.chain.deploy_contract( contract_name='HumanStandardToken', contract_path=get_contract_path('HumanStandardToken.sol'), constructor_parameters=(token_amount, 'raiden', 2, 'Rd'), ) api1 = RaidenAPI(node1.raiden) assert not api1.get_tokens_list() assert api1.manager_address_if_token_registered(token_address) is None node1.raiden.poll_blockchain_events() assert not api1.get_tokens_list() api1.register_token(token_address) assert api1.manager_address_if_token_registered(token_address) is not None assert api1.get_tokens_list() == [token_address]
def test_register_token(raiden_chain, token_addresses): app0, _ = raiden_chain # pylint: disable=unbalanced-tuple-unpacking api0 = RaidenAPI(app0.raiden) assert api0.manager_address_if_token_registered(token_addresses[0]) is None manager_0token = api0.register_token(token_addresses[0]) assert manager_0token == api0.manager_address_if_token_registered(token_addresses[0]) # Exception if we try to reregister with pytest.raises(ValueError): api0.register_token(token_addresses[0])
def test_second_manager_address_if_token_registered(raiden_chain, token_addresses): """Test recreating the scenario described on issue: https://github.com/raiden-network/raiden/issues/784""" app0, app1 = raiden_chain # pylint: disable=unbalanced-tuple-unpacking api0 = RaidenAPI(app0.raiden) api1 = RaidenAPI(app1.raiden) # Recreate the race condition by making sure the non-registering app won't # register at all by watching for the TokenAdded blockchain event. app1.raiden.alarm.remove_callback(app1.raiden.poll_blockchain_events) manager_0token = api0.register_token(token_addresses[0]) # The second node does not register but just confirms token is registered. # This is the behaviour the api call implement in register_token(). manager_1token = api1.manager_address_if_token_registered( token_addresses[0]) assert manager_0token == manager_1token # Now make sure the token lists are populated for both nodes tokens0_list = api0.get_tokens_list() tokens1_list = api1.get_tokens_list() assert tokens0_list == tokens1_list assert len(tokens1_list) == 1 assert token_addresses[0] == tokens1_list[0]
def test_second_manager_address_if_token_registered(raiden_chain, token_addresses): """Test recreating the scenario described on issue: https://github.com/raiden-network/raiden/issues/784""" app0, app1 = raiden_chain # pylint: disable=unbalanced-tuple-unpacking api0 = RaidenAPI(app0.raiden) api1 = RaidenAPI(app1.raiden) # Recreate the race condition by making sure the non-registering app won't # register at all by watching for the TokenAdded blockchain event. app1.raiden.alarm.remove_callback(app1.raiden.poll_blockchain_events) manager_0token = api0.register_token(token_addresses[0]) # The second node does not register but just confirms token is registered. # This is the behaviour the api call implement in register_token(). manager_1token = api1.manager_address_if_token_registered(token_addresses[0]) assert manager_0token == manager_1token # Now make sure the token lists are populated for both nodes tokens0_list = api0.get_tokens_list() tokens1_list = api1.get_tokens_list() assert tokens0_list == tokens1_list assert len(tokens1_list) == 1 assert token_addresses[0] == tokens1_list[0]
def test_token_registration(raiden_network, tester_chain): node1 = raiden_network[0] token_amount = 1000 token_address = node1.raiden.chain.deploy_contract( contract_name='HumanStandardToken', contract_path=get_contract_path('HumanStandardToken.sol'), constructor_parameters=(token_amount, 'raiden', 2, 'Rd'), ) api1 = RaidenAPI(node1.raiden) assert not api1.get_tokens_list() assert api1.manager_address_if_token_registered(token_address) is None node1.raiden.poll_blockchain_events() assert not api1.get_tokens_list() api1.register_token(token_address) assert api1.manager_address_if_token_registered(token_address) is not None assert api1.get_tokens_list() == [token_address]