Skip to content

Commit

Permalink
Update MS/BF scenarios to use new assert_events filters
Browse files Browse the repository at this point in the history
  • Loading branch information
ulope committed Sep 20, 2019
1 parent 6983c90 commit 4717870
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 16 deletions.
21 changes: 16 additions & 5 deletions raiden/tests/scenarios/bf1_basic_functionality.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,11 @@ scenario:
name: "Assert after closing channel between 0 and 4"
tasks:
- wait: 10
- assert_events: {contract_name: "TokenNetwork", event_name: "ChannelClosed", num_events: 1}
- assert_events:
contract_name: "TokenNetwork"
event_name: "ChannelClosed"
num_events: 1
event_args: {closing_participant: 0}
- assert: {from: 0, to: 4, state: "closed"}
- serial:
name: "Make 100 payments from 3 to 0"
Expand All @@ -214,13 +218,20 @@ scenario:
- close_channel: {from: 3, to: 4}
## Wait for channel to be closed
- wait_blocks: 1
- assert: {from: 3 ,to: 4, state: "closed"}
- assert_events: {contract_name: "TokenNetwork", event_name: "ChannelClosed", num_events: 2}
- assert: {from: 3, to: 4, state: "closed"}
- assert_events:
contract_name: "TokenNetwork"
event_name: "ChannelClosed"
num_events: 1
event_args: {closing_participant: 3}

## The MS reacts after 0.8 * settle_timeout at the latest. 0.8 * 500 = 400
- wait_blocks: 401
# Below line should potentially have num_events: 2
- assert_events: {contract_name: "TokenNetwork", event_name: "NonClosingBalanceProofUpdated", num_events: 2}
- assert_events:
contract_name: "TokenNetwork"
event_name: "NonClosingBalanceProofUpdated"
num_events: 1
event_args: {closing_participant: 3}

## Monitored channel must be settled before the monitoring service can claim its reward
## Settlement timeout is 500, but we've already waited 400 blocks, leaving 100 blocks
Expand Down
14 changes: 11 additions & 3 deletions raiden/tests/scenarios/ms1_simple_monitoring.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,20 @@ scenario:
- close_channel: {from: 0, to: 1}
## Wait for channel to be closed
- wait_blocks: 1
- assert: {from: 0 ,to: 1, total_deposit: 1000, balance: 500, state: "closed"}
- assert_events: {contract_name: "TokenNetwork", event_name: "ChannelClosed", num_events: 1}
- assert: {from: 0, to: 1, total_deposit: 1000, balance: 500, state: "closed"}
- assert_events:
contract_name: "TokenNetwork"
event_name: "ChannelClosed"
num_events: 1
event_args: {closing_participant: 0}

## The MS reacts after 0.8 * settle_timeout at the latest. 0.8 * 500 = 400
- wait_blocks: 401
- assert_events: {contract_name: "TokenNetwork", event_name: "NonClosingBalanceProofUpdated", num_events: 1}
- assert_events:
contract_name: "TokenNetwork"
event_name: "NonClosingBalanceProofUpdated"
num_events: 1
event_args: {closing_participant: 0}

## Monitored channel must be settled before the monitoring service can claim its reward
## Settlement timeout is 500, but we've already waited 400 blocks, leaving 100 blocks
Expand Down
12 changes: 10 additions & 2 deletions raiden/tests/scenarios/ms2_simple_monitoring.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,19 @@ scenario:
## Wait for channel to be closed
- wait_blocks: 10
- assert: {from: 0 ,to: 1, total_deposit: 1000, balance: 500, state: "closed"}
- assert_events: {contract_name: "TokenNetwork", event_name: "ChannelClosed", num_events: 1}
- assert_events:
contract_name: "TokenNetwork"
event_name: "ChannelClosed"
num_events: 1
event_args: {closing_participant: 0}

## The MS reacts after 0.8 * settle_timeout at the latest. 0.8 * 500 = 400
- wait_blocks: 401
- assert_events: {contract_name: "TokenNetwork", event_name: "NonClosingBalanceProofUpdated", num_events: 1}
- assert_events:
contract_name: "TokenNetwork"
event_name: "NonClosingBalanceProofUpdated"
num_events: 1
event_args: {closing_participant: 0}

## Node1 gets back online after the MS has reacted.
## The MS should claim the reward
Expand Down
12 changes: 10 additions & 2 deletions raiden/tests/scenarios/ms3_simple_monitoring.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ scenario:
## Wait for channel to be closed
- wait_blocks: 1
- assert: {from: 0 ,to: 1, total_deposit: 1000, balance: 500, state: "closed"}
- assert_events: {contract_name: "TokenNetwork", event_name: "ChannelClosed", num_events: 1}
- assert_events:
contract_name: "TokenNetwork"
event_name: "ChannelClosed"
num_events: 1
event_args: {closing_participant: 0}

## node1 gets back online before the MS reacts
## node1 should call updateNonClosingBalanceProof in this case and the MS wont react
Expand All @@ -56,7 +60,11 @@ scenario:
## The MS reacts after 0.8 * settle_timeout at the latest. 0.8 * 500 = 400
## But we just need to check for the event from node1 before the monitoring service reacts
- wait_blocks: 20
- assert_events: {contract_name: "TokenNetwork", event_name: "NonClosingBalanceProofUpdated", num_events: 1}
- assert_events:
contract_name: "TokenNetwork"
event_name: "NonClosingBalanceProofUpdated"
num_events: 1
event_args: {closing_participant: 0}

## Monitored channel must be settled before the monitoring service can claim its reward
## Settlement timeout is 500 blocks -> 500 * 15s in Kovan = 7500s
Expand Down
22 changes: 18 additions & 4 deletions raiden/tests/scenarios/ms4_udc_too_low.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ scenario:
- open_channel: {from: 0, to: 1, total_deposit: 1000}
- serial:
name: "Make 10 payments from node0 to node1"
repeat: 10
repeat: 10
tasks:
- transfer: {from: 0, to: 1, amount: 50, expected_http_status: 200}
- serial:
Expand All @@ -65,19 +65,33 @@ scenario:
tasks:
- wait_blocks: 1
- assert: {from: 0 ,to: 1, total_deposit: 1000, balance: 500, state: "closed"}
- assert_events: {contract_name: "TokenNetwork", event_name: "ChannelClosed", num_events: 1}
- assert_events:
contract_name: "TokenNetwork"
event_name: "ChannelClosed"
num_events: 1
event_args: {closing_participant: 0}

- serial:
name: "Wait for MS to not react"
tasks:
# The MS reacts after 0.8 * settle_timeout at the latest. 0.8 * 500 = 400
- wait_blocks: 401
# Note that 0 events are expected
- assert_events: {contract_name: "TokenNetwork", event_name: "NonClosingBalanceProofUpdated", num_events: 0}
- assert_events:
contract_name: "TokenNetwork"
event_name: "NonClosingBalanceProofUpdated"
num_events: 0
event_args: {closing_participant: 0}

- serial:
name: "Wait for remaining timeout period to expire and check again that MS did not react"
tasks:
# Monitored channel must be settled before the monitoring service can claim its reward
# Settlement timeout is 500, but we've already waited 400 blocks, leaving 100 blocks
# To make sure the transactions gets mined in time, 10 additional blocks are added
- wait_blocks: 110
- assert_events: {contract_name: "TokenNetwork", event_name: "NonClosingBalanceProofUpdated", num_events: 0}
- assert_events:
contract_name: "TokenNetwork"
event_name: "NonClosingBalanceProofUpdated"
num_events: 0
event_args: {closing_participant: 0}

0 comments on commit 4717870

Please sign in to comment.