Last active
September 1, 2023 09:56
-
-
Save PokotyloMaryna/911203cf7cdd6085752c6df356b6fc38 to your computer and use it in GitHub Desktop.
State channel test scenarios
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Test 1. Verify Positive Multi-Channel Interaction and Settlement Between Alice and Bob | |
# Participants: Alice and Bob | |
# Conditions: | |
## Alice opens 1 channel with 1 participant; | |
## Consider Identical trade parameters between 2 participants; | |
## All settlements execute; | |
## All participants close their channel succesfully. | |
participants: | |
- name: Alice | |
address: "0xAliceAddress" | |
privkey: "a11ce00000000000000000000000000000000000000000000000000000000000" | |
rpc: "https://alice.com" | |
- name: Bob | |
address: "0xBobAddress" | |
privkey: "b0b0000000000000000000000000000000000000000000000000000000000000" | |
rpc: "https://bob.com" | |
actions: | |
t0: | |
- type: Connect | |
subsystem: core | |
participant: Alice | |
data: | |
endpoint: "wss://bob.com" | |
- type: Connect | |
subsystem: core | |
participant: Bob | |
data: | |
endpoint: "wss://Alice.com" | |
t1: | |
- type: OpenChannel | |
participants: | |
- Alice | |
- Bob | |
deposit: 5000 | |
is_accepted: true | |
channel_id: alice_bob_1 | |
t2: | |
- type: RecordTrade | |
participant: Alice | |
market: BTCUSDT | |
side: Buy | |
amount: 0.14 | |
price: 29000.00 | |
channel_id: alice_bob_1 | |
- type: RecordTrade | |
participant: Alice | |
market: BTCUSDT | |
side: Sell | |
amount: 0.04 | |
price: 33000.00 | |
channel_id: alice_bob_1 | |
- type: RecordTrade | |
participant: Alice | |
market: WETHUSDT | |
side: Buy | |
amount: 0.20 | |
price: 1200.00 | |
channel_id: alice_bob_1 | |
- type: RecordTrade | |
participant: Alice | |
market: SHIBUSDT | |
side: Buy | |
amount: 20000 | |
price: 0.0085 | |
channel_id: alice_bob_1 | |
t3: | |
- type: PriceUpdate | |
market: BTCUSDT | |
price: 31000.00 | |
- type: PriceUpdate | |
market: ETHUSDT | |
price: 1001.002 | |
- type: PriceUpdate | |
market: SHIBUSDT | |
price: 0.0090 | |
- type: PriceUpdate | |
market: WETHUSDT | |
price: 1255.030 | |
t4: | |
- type: MarginCall | |
is_accepted: true | |
channel_id: alice_bob_1 | |
t5: | |
- type: RequestSettlement | |
participant: Alice | |
positions: | |
- WETHUSDT | |
- BTCUSDT | |
- SHIBUSDT | |
is_accepted: true | |
channel_id: alice_bob_1 | |
t6: | |
- type: ExecuteSettlement | |
channel_id: alice_bob_1 | |
t7: | |
- type: CloseChannel | |
channel_id: alice_bob_1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Test 2. Verify Positive Multi-Channel Interaction and Settlement Between Alice, Bob and Charlie | |
# Participants: Alice, Bob, Charlie | |
# Conditions: | |
## Alice opens 2 channels with 2 participants; | |
## Consider Identical trade parameters between 2 participants; | |
## All settlements execute; | |
## All participants close their channel succesfully. | |
participants: | |
- name: Alice | |
address: "0xAliceAddress" | |
privkey: "a11ce00000000000000000000000000000000000000000000000000000000000" | |
rpc: "https://alice.com" | |
- name: Bob | |
address: "0xBobAddress" | |
privkey: "b0b0000000000000000000000000000000000000000000000000000000000000" | |
rpc: "https://bob.com" | |
- name: Charlie | |
address: "0xCharlieAddress" | |
privkey: "charlie0000000000000000000000000000000000000000000000000000000000000" | |
rpc: "https://charlie.com" | |
actions: | |
t0: | |
- type: Connect | |
subsystem: core | |
participant: Alice | |
data: | |
endpoint: "wss://bob.com" | |
- type: Connect | |
subsystem: core | |
participant: Alice | |
data: | |
endpoint: "wss://charlie.com" | |
- type: Connect | |
subsystem: core | |
participant: Bob | |
data: | |
endpoint: "wss://Alice.com" | |
- type: Connect | |
subsystem: core | |
participant: Charlie | |
data: | |
endpoint: "wss://Alice.com" | |
t1: | |
- type: OpenChannel | |
participants: | |
- Alice | |
- Bob | |
deposit: 5000 | |
is_accepted: true | |
channel_id: alice_bob_1 | |
- type: OpenChannel | |
subsystem: core | |
participants: | |
- Alice | |
- Charlie | |
deposit: 5000 | |
is_accepted: true | |
channel_id: alice_charlie_2 | |
t2: | |
- type: RecordTrade | |
participant: Alice | |
market: BTCUSDT | |
side: Buy | |
amount: 0.14 | |
price: 29000.00 | |
channel_id: alice_bob_1 | |
- type: RecordTrade | |
participant: Alice | |
market: BTCUSDT | |
side: Buy | |
amount: 0.10 | |
price: 29000.00 | |
channel_id: alice_charlie_2 | |
- type: RecordTrade | |
participant: Alice | |
market: BTCUSDT | |
side: Sell | |
amount: 0.04 | |
price: 33000.00 | |
channel_id: alice_bob_1 | |
- type: RecordTrade | |
participant: Alice | |
market: WETHUSDT | |
side: Buy | |
amount: 0.20 | |
price: 1200.00 | |
channel_id: alice_bob_1 | |
- type: RecordTrade | |
participant: Alice | |
market: WETHUSDT | |
side: Buy | |
amount: 0.30 | |
price: 1250.020 | |
channel_id: alice_charlie_2 | |
- type: RecordTrade | |
participant: Alice | |
market: SHIBUSDT | |
side: Buy | |
amount: 20000 | |
price: 0.0085 | |
channel_id: alice_bob_1 | |
- type: RecordTrade | |
participant: Alice | |
market: ETHUSDT | |
side: Buy | |
amount: 0.20 | |
price: 1000.001 | |
channel_id: alice_charlie_2 | |
t3: | |
- type: PriceUpdate | |
market: BTCUSDT | |
price: 31000.00 | |
- type: PriceUpdate | |
market: ETHUSDT | |
price: 1001.002 | |
- type: PriceUpdate | |
market: SHIBUSDT | |
price: 0.0090 | |
- type: PriceUpdate | |
market: WETHUSDT | |
price: 1255.030 | |
t4: | |
- type: MarginCall | |
is_accepted: true | |
channel_id: alice_charlie_2 | |
- type: MarginCall | |
is_accepted: true | |
channel_id: alice_bob_1 | |
t5: | |
- type: RequestSettlement | |
participant: Charlie | |
positions: | |
- WETHUSDT | |
- BTCUSDT | |
- ETHUSDT | |
is_accepted: true | |
channel_id: alice_charlie_2 | |
- type: RequestSettlement | |
participant: Alice | |
positions: | |
- WETHUSDT | |
- BTCUSDT | |
- SHIBUSDT | |
is_accepted: true | |
channel_id: alice_bob_1 | |
t6: | |
- type: ExecuteSettlement | |
channel_id: alice_charlie_2 | |
- type: ExecuteSettlement | |
channel_id: alice_bob_1 | |
t7: | |
- type: CloseChannel | |
subsystem: core | |
channel_id: alice_charlie_2 | |
- type: CloseChannel | |
subsystem: core | |
channel_id: alice_bob_1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Test 4. Verify Unhappy Common Case: Alice's Server Crash, Bob's Channel Challenge and Settlement is not finalized. | |
#Participants: Alice and Bob | |
#Condition: | |
##Alice's server crash; | |
##Alice's server is answering on margin_calls; | |
##Bob challenges Alice to retrieve money from the channel as collateral; | |
##Settlement is started, but never finalized. | |
participants: | |
- name: Alice | |
address: "0xAliceAddress" | |
privkey: "a11ce00000000000000000000000000000000000000000000000000000000000" | |
rpc: "https://alice.com" | |
- name: Bob | |
address: "0xBobAddress" | |
privkey: "b0b0000000000000000000000000000000000000000000000000000000000000" | |
rpc: "https://bob.com" | |
actions: | |
t0: | |
- type: Connect | |
subsystem: core | |
participant: Alice | |
data: | |
endpoint: "wss://bob.com" | |
- type: Connect | |
subsystem: core | |
participant: Bob | |
data: | |
endpoint: "wss://Alice.com" | |
t1: | |
- type: OpenChannel | |
subsystem: core | |
participants: | |
- Alice | |
- Bob | |
deposit: 5000 | |
is_accepted: true | |
t2: | |
- type: RecordTrade | |
participant: Alice | |
market: BTCUSDT | |
side: Buy | |
amount: 0.14 | |
price: 29000.00 | |
- type: RecordTrade | |
participant: Alice | |
market: BTCUSDT | |
side: Buy | |
amount: 0.10 | |
price: 29000.00 | |
- type: RecordTrade | |
participant: Alice | |
market: BTCUSDT | |
side: Sell | |
amount: 0.04 | |
price: 33000.00 | |
- type: RecordTrade | |
participant: Alice | |
market: WETHUSDT | |
side: Buy | |
amount: 0.20 | |
price: 1200.00 | |
- type: RecordTrade | |
participant: Alice | |
market: WETHUSDT | |
side: Buy | |
amount: 0.30 | |
price: 1250.00 | |
- type: RecordTrade | |
participant: Alice | |
market: SHIBUSDT | |
side: Buy | |
amount: 20000 | |
price: 0.0085 | |
t3: | |
- type: PriceUpdate | |
market: WETHUSDT | |
price: 1250.00 | |
t4: | |
- type: MarginCall | |
participant: Alice | |
is_accepted: true | |
t5: | |
- type: RequestSettlement | |
participant: Alice | |
positions: | |
- WETHUSDT | |
- BTCUSDT | |
- SHIBUSDT | |
is_accepted: true | |
t6: | |
- type: ExecuteSettlement | |
participant: Alice | |
is_finalized: false | |
t7: | |
- type: Challenge | |
participant: Bob | |
is_ignored: true | |
t8: | |
- type: CloseChannel | |
subsystem: core | |
participant: Bob #Bob closes the channel as Alice lost her connection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Test 3. Verify Unhappy Common Case: Alice's Server Crash and Bob's Channel Challenge | |
# Participants: Alice and Bob | |
# Conditions: | |
## Alice's server crash; | |
## Alice's server is not answering on margin_call; | |
## Bob challenges Alice to retrieve money from the channel as collateral | |
participants: | |
- name: Alice | |
address: "0xAliceAddress" | |
privkey: "a11ce00000000000000000000000000000000000000000000000000000000000" | |
rpc: "https://alice.com" | |
- name: Bob | |
address: "0xBobAddress" | |
privkey: "b0b0000000000000000000000000000000000000000000000000000000000000" | |
rpc: "https://bob.com" | |
actions: | |
t0: | |
- type: Connect | |
subsystem: core | |
participant: Alice | |
data: | |
endpoint: "wss://bob.com" | |
- type: Connect | |
subsystem: core | |
participant: Bob | |
data: | |
endpoint: "wss://Alice.com" | |
t1: | |
- type: OpenChannel | |
subsystem: core | |
participants: | |
- Alice | |
- Bob | |
deposit: 5000 | |
is_accepted: true | |
t2: | |
- type: RecordTrade | |
participant: Alice | |
market: BTCUSDT | |
side: Buy | |
amount: 0.14 | |
price: 29000.00 | |
t3: | |
- type: PriceUpdate | |
market: BTCUSDT | |
price: 31000.00 | |
t4: | |
- type: MarginCall | |
participant: Alice | |
is_accepted: false | |
t5: | |
- type: Challenge | |
participant: Bob | |
is_ignored: true | |
t6: | |
- type: TransferAllAssets | |
participant: Bob | |
t7: | |
- type: CloseChannel | |
subsystem: core | |
participant: Bob #Bob closes the channel as Alice lost her connection |
- Accept
- I think
channel_id
inRecordTrade
type identifies that one participant sells, another one buys. For instance,
- type: RecordTrade
participant: Alice
market: SHIBUSDT
side: Buy
amount: 20000
price: 0.0085
channel_id: alice_bob_1
This snap means that Alice is buyer, Bob is seller.
- Accept
- Accept
- Accept
- Accept
- Ok, but we should keep in mind that participants could fool each other by recording different trades
Test 3:
- Change
RequestDisputeResolution
toChallenge
.is_accepted
- not the best name, but anyway we need some field that will describe how another party (Alice in this case) will answer to the call, I suggestis_ignored
, wheretrue
means that Alice didn't appear, andfalse
if she did
t5:
- type: RequestDisputeResolution
participant: Bob
is_accepted: true
- There is no
ExecuteSettlement
afterChallenge
. At this case Bob could just withdraw all his assets (deposit + margin). You could useTransferAllAssets
action to keep consistency with the SC
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
{intitator}_{follower}_{channel_nonce}
, e.g.alice_bob_1
orbob_charlie_3
RecordTrades
- it is not clear what Bob and Charlie recording to their systems. Pls specify (ideally it should be the same as Alice's, but also could be divergencies)SHIBUSDT
- it is a good use case of empty price feed, but I guess this case is not part of this testparticipant
field for theMarginCall
,OpenChannel
andCloseChannel
, because it will always be Initiator of Channel