Skip to content

Commit

Permalink
[skip ci] Comment and indentation style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
konradkonrad authored and LefterisJP committed Sep 8, 2017
1 parent 70b296f commit 555f631
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 18 deletions.
4 changes: 2 additions & 2 deletions docs/api_walkthrough.rst
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ Interacting with the Raiden Echo Node
=====================================
For easy testing of Raiden, there is a specialized Raiden node running, the "Raiden Echo Node". The Echo Node responds to received transfers by sending a transfer back to the initiator. The echo transfer follows certain rules:

- consecutive transfers with the same ``identifier`` and same ``amount`` are ignored
- consecutive transfers with the same ``identifier`` and same ``amount`` are ignored (as in: the Echo Node just keeps your money)
- the ``echo_identifier`` of all echo transfers is ``identifier + echo_amount``
- transfers with an ``amount`` divisible by ``3`` will be answered with an echo transfer of ``echo_amount = amount - 1``
- transfers with an ``amount = 7`` are special lottery transfers. They will go to a lottery pool. After the Echo Node has received seven lottery transfers, it will choose a winner that receives an echo transfer with ``echo_amount = 49`` and the pool is reset. To query the current number of tickets in the pool, a participant can send another transfer with ``amount = 7`` -- if the participant already takes part in the current draw, the Echo Node will respond with a transfer with ``echo_amount = lottery_pool_size``, otherwise it will enter the pool.
Expand All @@ -323,7 +323,7 @@ You can obtain RTT tokens by calling the ``mint()`` function of the token. In ja
var rtt_token_abi = [{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"name":"approve","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"mint","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"supply","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"version","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"amount","type":"uint256"}],"name":"mint","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"amount","type":"uint256"},{"name":"target","type":"address"}],"name":"mintFor","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"},{"name":"_extraData","type":"bytes"}],"name":"approveAndCall","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"}],"name":"allowance","outputs":[{"name":"remaining","type":"uint256"}],"payable":false,"type":"function"},{"inputs":[{"name":"_tokenName","type":"string"},{"name":"_tokenSymbol","type":"string"}],"payable":false,"type":"constructor"},{"payable":false,"type":"fallback"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_from","type":"address"},{"indexed":true,"name":"_to","type":"address"},{"indexed":false,"name":"_value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_owner","type":"address"},{"indexed":true,"name":"_spender","type":"address"},{"indexed":false,"name":"_value","type":"uint256"}],"name":"Approval","type":"event"}];
var rtt_token_address = "0x0f114a1e9db192502e7856309cc899952b3db1ed";
var rtt_token = web3.eth.contract(rtt_token_abi).at(rtt_token_address);
rtt_token.mint({from: eth.accounts[0]}); // adjust to your raiden account
rtt_token.mint({from: eth.accounts[0]}); // adjust to your raiden account and unlock first!


Then you can send a transfer to it via the transfer endpoint: ``POST /api/1/transfers/0x0f114a1e9db192502e7856309cc899952b3db1ed/0x02f4b6bc65561a792836212ebc54434db0ab759a`` and with a payload containing the amount you want to send and an optional identifier::
Expand Down
22 changes: 7 additions & 15 deletions raiden/tests/integration/test_echo_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@
@pytest.mark.parametrize('channels_per_node', [CHAIN])
@pytest.mark.parametrize('reveal_timeout', [18])
@pytest.mark.parametrize('settle_timeout', [64])
def test_event_transfer_received_success(
token_addresses,
raiden_chain,
):
def test_event_transfer_received_success(token_addresses, raiden_chain):
app0, app1, app2, receiver_app = raiden_chain
token_address = token_addresses[0]
start_block = receiver_app.raiden.get_block_number()
Expand Down Expand Up @@ -58,10 +55,7 @@ def test_event_transfer_received_success(
@pytest.mark.parametrize('channels_per_node', [CHAIN])
@pytest.mark.parametrize('reveal_timeout', [18])
@pytest.mark.parametrize('settle_timeout', [64])
def test_echo_node_response(
token_addresses,
raiden_chain,
):
def test_echo_node_response(token_addresses, raiden_chain):
app0, app1, app2, echo_app = raiden_chain
address_to_app = {app.raiden.address: app for app in raiden_chain}
token_address = token_addresses[0]
Expand Down Expand Up @@ -115,10 +109,7 @@ def test_echo_node_response(
@pytest.mark.parametrize('channels_per_node', [CHAIN])
@pytest.mark.parametrize('reveal_timeout', [20])
@pytest.mark.parametrize('settle_timeout', [120])
def test_echo_node_lottery(
token_addresses,
raiden_chain,
):
def test_echo_node_lottery(token_addresses, raiden_chain):
app0, app1, app2, app3, echo_app, app4, app5, app6 = raiden_chain
address_to_app = {app.raiden.address: app for app in raiden_chain}
token_address = token_addresses[0]
Expand All @@ -145,12 +136,13 @@ def test_echo_node_lottery(
# test duplicated identifier + amount is ignored
transfer_event = RaidenAPI(app5.raiden).transfer_async(
token_address,
amount,
amount, # same amount as before
echo_app.raiden.address,
10 ** 6
10 ** 6 # app5 used this identifier before
).wait(timeout=20)

# test pool size querying
pool_query_identifier = 77
pool_query_identifier = 77 # unused identifier different from previous one
transfer_event = RaidenAPI(app5.raiden).transfer_async(
token_address,
amount,
Expand Down
2 changes: 1 addition & 1 deletion raiden/utils/echo_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def poll_all_received_events(self):
event['block_number']
for event in received_transfers
)
# proceed last_poll_block if the blockchain proceeded
# increase last_poll_block if the blockchain proceeded
delta_blocks = self.api.raiden.get_block_number() - self.last_poll_block
if delta_blocks > 1:
self.last_poll_block += 1
Expand Down

0 comments on commit 555f631

Please sign in to comment.