MCPcopy Create free account
hub / github.com/raiden-network/raiden / test_register_token

Function test_register_token

raiden/tests/integration/api/test_pythonapi.py:64–106  ·  view source on GitHub ↗
(raiden_network: List[RaidenService], retry_timeout, unregistered_token)

Source from the content-addressed store, hash-verified

62@pytest.mark.parametrize("number_of_tokens", [1])
63@pytest.mark.parametrize("environment_type", [Environment.DEVELOPMENT])
64def test_register_token(raiden_network: List[RaidenService], retry_timeout, unregistered_token):
65 app1 = raiden_network[0]
66 registry_address = app1.default_registry.address
67 token_address = unregistered_token
68
69 # Wait until Raiden can start using the token contract.
70 # Here, the block at which the contract was deployed should be confirmed by Raiden.
71 # Therefore, until that block is received.
72 waiting.wait_for_block(
73 raiden=app1,
74 block_number=BlockNumber(
75 app1.get_block_number() + DEFAULT_NUMBER_OF_BLOCK_CONFIRMATIONS + 1
76 ),
77 retry_timeout=retry_timeout,
78 )
79
80 api1 = RaidenAPI(app1)
81 assert token_address not in api1.get_tokens_list(registry_address)
82
83 api1.token_network_register(
84 registry_address=registry_address,
85 token_address=token_address,
86 channel_participant_deposit_limit=TokenAmount(UINT256_MAX),
87 token_network_deposit_limit=TokenAmount(UINT256_MAX),
88 )
89 exception = RuntimeError("Did not see the token registration within 30 seconds")
90 with gevent.Timeout(seconds=30, exception=exception):
91 wait_for_state_change(
92 app1,
93 ContractReceiveNewTokenNetwork,
94 {"token_network": {"token_address": token_address}},
95 retry_timeout,
96 )
97 assert token_address in api1.get_tokens_list(registry_address)
98
99 # Exception if we try to reregister
100 with pytest.raises(AlreadyRegisteredTokenAddress):
101 api1.token_network_register(
102 registry_address=registry_address,
103 token_address=token_address,
104 channel_participant_deposit_limit=TokenAmount(UINT256_MAX),
105 token_network_deposit_limit=TokenAmount(UINT256_MAX),
106 )
107
108
109@raise_on_failure

Callers

nothing calls this directly

Calls 5

get_tokens_listMethod · 0.95
RaidenAPIClass · 0.90
wait_for_state_changeFunction · 0.90
get_block_numberMethod · 0.80

Tested by

no test coverage detected