-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_rte.py
65 lines (53 loc) · 2 KB
/
test_rte.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
from modules import *
# import pytest
from pytest_steps import test_steps, StepsDataHolder, depends_on
accounts = []
symbol = []
def createAccounts(steps_data, INSTANCE, cleartxpool):
global accounts
logging.info("create a couple of accounts")
reset_wallet(INSTANCE)
accounts = create_accounts(INSTANCE, num=2)
assert accounts != False
steps_data.accounts = accounts
def createAssets(steps_data, INSTANCE, cleartxpool):
global symbol
logging.info("create a couple of assets")
symbol1 = create_asset(INSTANCE)
assert symbol1 != False
symbol2 = create_asset(INSTANCE)
assert symbol2 != False
steps_data.symbol = [symbol1, symbol2]
symbol = [symbol1, symbol2]
def initMarket(steps_data, INSTANCE, cleartxpool):
global accounts, symbol
logging.info("create a couple of accounts and assets")
reset_wallet(INSTANCE)
accounts = create_accounts(INSTANCE, num=2)
assert accounts != False
steps_data.accounts = accounts
symbol1 = create_asset(INSTANCE)
assert symbol1 != False
symbol2 = create_asset(INSTANCE)
assert symbol2 != False
steps_data.symbol = [symbol1, symbol2]
symbol = [symbol1, symbol2]
@test_steps(initMarket)
def test_market(test_step, steps_data: StepsDataHolder, INSTANCE, cleartxpool):
logging.info('test asset market')
test_step(steps_data, INSTANCE, cleartxpool)
accounts = steps_data.accounts
symbol1 = steps_data.symbol[0]
symbol2 = steps_data.symbol[1]
asset1 = cybex.Asset(symbol1)
asset2 = cybex.Asset(symbol2)
m = cybex.Market(base = asset1, quote = asset2,
cybex_instance = INSTANCE)
alice = cybex.Account(accounts[0]['account'])
bob = cybex.Account(accounts[1]['account'])
alice_asset1_balance_ahead = alice.balance(asset1)
alice_asset2_balance_ahead = alice.balance(asset2)
assert alice_asset1_balance_ahead.amount == 0
assert alice_asset2_balance_ahead.amount == 0
assert len(alice.openorders) == 0
assert len(bob.openorders) == 0