Tests - operation in Hive - limit order create operation
Operation: limit_order_create_operation, // 5
Configuration:
HIVE_MAX_LIMIT_ORDER_EXPIRATION, default mainnet value: 28 days
All numbers and calculations are in the attached excel file.
Test cases:
-
1. User creates limit order Hive to HBD with {fill_or_kill} = true
and there is no matching order on the market. -
2. User creates limit order HBD to HIVE with {fill_or_kill} = true
and there is no matching order on the market.
Preconditions (test 1 and 2):
- Order 1 is on the market, but it doesn't match to the order created by the user.
Steps (test 1 and 2):
Step 1: User creates limit order (order 2) Hive to HBD/HBD to Hive with {fill_or_kill}= true.
Expected results:
- The operation failed.
- The operation is not added to the block.
Test cases:
-
3. User creates limit order Hive to HBD with {fill_or_kill} = true
and there is one matching order on the market. -
4. User creates limit order HBD to HIVE with {fill_or_kill} = true
and there is one matching order on the market.
Preconditions (test 3 and 4):
- The order 1 and order 2 are on the market.
Steps (test 3 and 4):
order 3
with {fill_or_kill}= true.
Step 1: User creates limit order Expected results:
- (order 3) The {owner} account balance in HIVE/HBD is reduced by correct amount.
- (order 3) The {owner} account balance in HBD/HIVE is increased by correct amount.
- (order 3) RC is reduced.
- (order 3) The virtual operation: fill_order_operation is generated.
- (order 1) The left amount of the order 1 is correct.
Test cases:
-
5. User creates limit order Hive to HBD with {fill_or_kill} = true
and there are three matching orders on the market. -
6. User creates limit order HBD to HIVE with {fill_or_kill} = true
and there are three matching orders on the market.
Preconditions (test 5 and 6):
- The order 1, order 2, order 3 and order 4 are on the market.
Steps (test 5 and 6):
order 5
with {fill_or_kill}= true.
Step 1: User creates limit order Expected results:
- (order 5) The {owner} account balance in HIVE/HBD is reduced by correct amount.
- (order 5) The {owner} account balance in HBD/HIVE is increased by correct amount.
- (order 5) RC is reduced.
- (order 5) The virtual operation: fill_order_operation is generated.
- (order 1) The left amount of the order 1 is correct.
- (order 2) The left amount of the order 2 is correct.
- (order 3) The left amount of the order 3 is correct.
- (order 4) The left amount of the order 4 is correct.
Test cases:
-
7. User creates limit order Hive to HBD with {fill_or_kill} = false
and there is no matching order on the market. -
8. User creates limit order HBD to HIVE with {fill_or_kill} = false
and there is no matching order on the market.
Preconditions (test 7 and 8):
- Order 1 is on the market, but it doesn't match to the order created by the user.
- {expiration} < HIVE_MAX_LIMIT_ORDER_EXPIRATION
Steps (test 7 and 8):
Step 1: User creates limit order (order 2) Hive to HBD/HBD to Hive with {fill_or_kill}= false.
Expected results:
- After operation: {owner} account balance is reduced by amount of order 2.
- After operation: RC is reduced.
- After {expiration}: {owner} account balance is increased by amount of order 2.
Test cases:
-
9. User creates limit order Hive to HBD with {fill_or_kill} = false
and there is a one fully matching order on the market. -
10. User creates limit order HBD to HIVE with {fill_or_kill} = false
and there is a one fully matching order on the market.
Preconditions (test 9 and 10):
- The order 1 and order 2 are on the market.
Steps (test 9 and 10):
order 3
with {fill_or_kill}= false.
Step 1: User creates limit order Expected results:
- (order 3) The {owner} account balance in HIVE/HBD is reduced by correct amount.
- (order 3) The {owner} account balance in HBD/HIVE is increased by correct amount.
- (order 3) RC is reduced.
- (order 3) The virtual operation: fill_order_operation is generated.
- (order 1) The left amount of the order 1 is correct.
- (order 2) The left amount of the order 2 is correct.
- After {expiration}: {owner} account balance is not increased.
Test cases:
-
11. User creates limit order Hive to HBD with {fill_or_kill} = false
and the matching order comes later. -
12. User creates limit order HBD to HIVE with {fill_or_kill} = false
and the matching order comes later.
Preconditions (test 11 and 12):
- There are no orders on the market.
Steps (test 11 and 12):
order 1
with {fill_or_kill}= false.
Step 1: User creates limit order Expected results:
- (order 1) The {owner} account balance in HIVE/HBD is reduced by correct amount.
- (order 1) RC is reduced.
order 2
is comming - no match.
Step 2: The Expected results:
- (order 1) The {owner} account balance in HIVE/HBD is not reduced.
- (order 1) The {owner} account balance in HBD/HIVE is not increased.
order 3
is comming - the is a full match.
Step 3: The Expected results:
- (order 1) The {owner} account balance in HIVE/HBD is reduced by correct amount.
- (order 1) The {owner} account balance in HBD/HIVE is increased by correct amount.
- (order 1) RC is not reduced.
- (order 1) The virtual operation: fill_order_operation is generated.
- (order 2) The left amount of the order 2 is correct.
- (order 3) The left amount of the order 3 is correct.
- After {expiration}: {owner} account balance is not increased.
Test cases:
-
13. User creates limit order Hive to HBD with {fill_or_kill} = false
and there is a partially matching order on the market, the second matching order comes later. -
14. User creates limit order HBD to HIVE with {fill_or_kill} = false
and there is a partially matching order on the market, the second matching order comes later.
Preconditions (test 13 and 14):
- There are order 1 and order 2 on the market.
Steps (test 13 and 14):
order 3
with {fill_or_kill}= false.
Step 1: User creates limit order Expected results:
- (order 3) The {owner} account balance in HIVE/HBD is reduced by correct amount.
- (order 3) The {owner} account balance in HBD/HIVE is increased by correct amount.
- (order 3) RC is reduced.
- (order 3) The virtual operation: fill_order_operation is generated.
- (order 1) The left amount of the order 1 is correct.
- (order 2) The left amount of the order 2 is correct.
order 4
is comming - the is a full match.
Step 2: The Expected results:
- (order 3) The {owner} account balance in HIVE/HBD is reduced by correct amount.
- (order 3) The {owner} account balance in HBD/HIVE is increased by correct amount.
- (order 3) RC is not reduced.
- (order 3) The virtual operation: fill_order_operation is generated.
- (order 1) The left amount of the order 1 is correct.
- (order 2) The left amount of the order 2 is correct.
- (order 3) The left amount of the order 3 is correct.
- (order 4) The left amount of the order 4 is correct.
- After {expiration}: {owner} account balance is not increased.
Test cases:
-
15. User creates limit order Hive to HBD with {fill_or_kill} = false
and the matching orders are coming later. -
16. User creates limit order HBD to HIVE with {fill_or_kill} = false
and the matching orders are coming later
Preconditions (test 15 and 16):
- There is no orders on the market.
Steps (test 15 and 16):
order 1
with {fill_or_kill}= false.
Step 1: User creates limit order Expected results:
- (order 1) The {owner} account balance in HIVE/HBD is reduced by correct amount.
- (order 1) RC is reduced.
order 2
is comming - no match.
Step 2: The Expected results:
- (order 1) The {owner} account balance in HIVE/HBD is not increased.
order 3
is comming - the is a partial match.
Step 3: The Expected results:
- (order 1) The {owner} account balance in HIVE/HBD is reduced by correct amount.
- (order 1) The {owner} account balance in HBD/HIVE is increased by correct amount.
- (order 1) RC is not reduced.
- (order 1) The virtual operation: fill_order_operation is generated.
- (order 2) The left amount of the order 2 is correct.
- (order 3) The left amount of the order 3 is correct.
order 4
is comming - the is a partial match.
Step 4: The Expected results:
- (order 1) The {owner} account balance in HIVE/HBD is reduced by correct amount.
- (order 1) The {owner} account balance in HBD/HIVE is increased by correct amount.
- (order 1) RC is not reduced.
- (order 1) The virtual operation: fill_order_operation is generated.
- (order 2) The left amount of the order 2 is correct.
- (order 3) The left amount of the order 3 is correct.
- (order 4) The left amount of the order 4 is correct.
order 5
is comming - the is a partial match.
Step 5: The Expected results:
- (order 1) The {owner} account balance in HIVE/HBD is reduced by correct amount.
- (order 1) The {owner} account balance in HBD/HIVE is increased by correct amount.
- (order 1) RC is not reduced.
- (order 1) The virtual operation: fill_order_operation is generated.
- (order 2) The left amount of the order 2 is correct.
- (order 3) The left amount of the order 3 is correct.
- (order 4) The left amount of the order 4 is correct.
- (order 5) The left amount of the order 5 is correct.
- After {expiration}: {owner} account balance is not increased.
Test cases:
-
17. User creates limit order Hive to HBD with {fill_or_kill} = false
and there is a partially matching order on the market and then the order expires. -
18. User creates limit order HBD to HIVE with {fill_or_kill} = false
and there is a partially matching order on the market and then the order expires.
Preconditions (test 17 and 18):
- There are order 1 and order 2 on the market.
Steps (test 17 and 18):
order 3
with {fill_or_kill}= false.
Step 1: User creates limit order Expected results:
- (order 3) The {owner} account balance in HIVE/HBD is reduced by correct amount.
- (order 3) The {owner} account balance in HBD/HIVE is increased by correct amount.
- (order 3) RC is reduced.
- (order 3) The virtual operation: fill_order_operation is generated.
- (order 1) The left amount of the order 1 is correct.
- (order 2) The left amount of the order 2 is correct.
- After {expiration}: {owner} account balance is increased by correct amount.
Test cases:
-
19. User creates limit order Hive to HBD with {fill_or_kill} = false
and the partially matching orders are coming later. -
20. User creates limit order HBD to HIVE with {fill_or_kill} = false
and the partially matching orders are coming later
Preconditions (test 19 and 20):
- There is no orders on the market.
Steps (test 19 and 20):
order 1
with {fill_or_kill}= false.
Step 1: User creates limit order Expected results:
- (order 1) The {owner} account balance in HIVE/HBD is reduced by correct amount.
- (order 1) RC is reduced.
order 2
is comming - no match.
Step 2: The Expected results:
- (order 1) The {owner} account balance in HIVE/HBD is not reduced.
- (order 1) The {owner} account balance in HBD/HIVE is not increased.
order 3
is comming - the is a partial match.
Step 3: The Expected results:
- (order 1) The {owner} account balance in HIVE/HBD is reduced by correct amount.
- (order 1) The {owner} account balance in HBD/HIVE is increased by correct amount.
- (order 1) RC is not reduced.
- (order 1) The virtual operation: fill_order_operation is generated.
- (order 2) The left amount of the order 2 is correct.
- (order 3) The left amount of the order 3 is correct.
- After {expiration}: {owner} account balance is increased.
Test cases:
-
21. User creates limit order Hive to HBD with {fill_or_kill} = false
and there are three matching orders on the market but later the order expires. -
22. User creates limit order HBD to HIVE with {fill_or_kill} = false
and there are three matching orders on the marketbut later the order expires.
Preconditions (test 21 and 22):
- The order 1, order 2, order 3 and order 4 are on the market.
Steps (test 21 and 2):
order 5
with {fill_or_kill}= false.
Step 1: User creates limit order Expected results:
- (order 5) The {owner} account balance in HIVE/HBD is reduced by correct amount.
- (order 5) The {owner} account balance in HBD/HIVE is increased by correct amount.
- (order 5) RC is reduced.
- (order 5) The virtual operation: fill_order_operation is generated.
- (order 1) The left amount of the order 1 is correct.
- (order 2) The left amount of the order 1 is correct.
- (order 3) The left amount of the order 1 is correct.
- (order 4) The left amount of the order 1 is correct.
- After {expiration}: {owner} account balance is increased.
Test cases:
-
23. User creates limit order Hive to HBD with {fill_or_kill} = false
and the matching orders are coming later but later the order expires. -
24. User creates limit order HBD to HIVE with {fill_or_kill} = false
and the matching orders are coming later but later the order expires.
Preconditions (test 23 and 24):
- There is no orders on the market.
Steps (test 23 and 24):
order 1
with {fill_or_kill}= false.
Step 1: User creates limit order Expected results:
- (order 1) The {owner} account balance in HIVE/HBD is reduced by correct amount.
- (order 1) RC is reduced.
order 2
is comming - no match.
Step 2: The Expected results:
- (order 1) The {owner} account balance in HIVE/HBD is not reduced.
- (order 1) The {owner} account balance in HBD/HIVE is not increased.
order 3
is comming - the is a partial match.
Step 3: The Expected results:
- (order 1) The {owner} account balance in HIVE/HBD is reduced by correct amount.
- (order 1) The {owner} account balance in HBD/HIVE is increased by correct amount.
- (order 1) RC is not reduced.
- (order 1) The virtual operation: fill_order_operation is generated.
- (order 2) The left amount of the order 2 is correct.
- (order 3) The left amount of the order 3 is correct.
order 4
is comming - the is a partial match.
Step 4: The Expected results:
- (order 1) The {owner} account balance in HIVE/HBD is reduced by correct amount.
- (order 1) The {owner} account balance in HBD/HIVE is increased by correct amount.
- (order 1) RC is not reduced.
- (order 1) The virtual operation: fill_order_operation is generated.
- (order 2) The left amount of the order 2 is correct.
- (order 3) The left amount of the order 3 is correct.
- (order 4) The left amount of the order 4 is correct.
order 5
is comming - the is a partial match.
Step 5: The Expected results:
- (order 1) The {owner} account balance in HIVE/HBD is reduced by correct amount.
- (order 1) The {owner} account balance in HBD/HIVE is increased by correct amount.
- (order 1) RC is not reduced.
- (order 1) The virtual operation: fill_order_operation is generated.
- (order 2) The left amount of the order 2 is correct.
- (order 3) The left amount of the order 3 is correct.
- (order 4) The left amount of the order 4 is correct.
- (order 5) The left amount of the order 5 is correct.
- After {expiration}: {owner} account balance is increased.
Test cases:
-
25. User creates limit order Hive to HBD with {fill_or_kill} = false
and there is a partially matching order on the market, the second matching order comes later and then the order expires. -
26. User creates limit order HBD to HIVE with {fill_or_kill} = false
and there is a partially matching order on the market, the second matching order comes later and then the order expires.
Preconditions (test 25 and 26):
- There are order 1 and order 2 on the market.
Steps (test 25 and 26):
order 3
with {fill_or_kill}= false.
Step 1: User creates limit order Expected results:
- (order 3) The {owner} account balance in HIVE/HBD is reduced by correct amount.
- (order 3) The {owner} account balance in HBD/HIVE is increased by correct amount.
- (order 3) RC is reduced.
- (order 3) The virtual operation: fill_order_operation is generated.
- (order 1) The left amount of the order 1 is correct.
- (order 2) The left amount of the order 2 is correct.
order 4
is comming - the is a partial match.
Step 2: The Expected results:
- (order 3) The {owner} account balance in HIVE/HBD is reduced by correct amount.
- (order 3) The {owner} account balance in HBD/HIVE is increased by correct amount.
- (order 3) RC is not reduced.
- (order 3) The virtual operation: fill_order_operation is generated.
- (order 1) The left amount of the order 1 is correct.
- (order 2) The left amount of the order 2 is correct.
- (order 3) The left amount of the order 3 is correct.
- (order 4) The left amount of the order 4 is correct.
- (order 3) After {expiration}: {owner} account balance is increased.
Edited by Mateusz Kudela