Repository navigation
Expand file tree
/
Copy pathtest_koios.py
More file actions
337 lines (243 loc) · 12.9 KB
/
Copy pathtest_koios.py
File metadata and controls
337 lines (243 loc) · 12.9 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
#!/usr/bin/env python
"""
TESTING SCRIPT FOR KOIOS_PYTHON USING PYTEST
To use this script, you must have pytest installed.
pip install pytest
Change directory to the folder containing this script and run:
pytest
Watch the terminal for the results of the tests. :)
"""
import pytest
import koios_python
from koios_python import address # We need to install and import koios_python library
##############################################################################
# ACCOUNT FUNCTIONS
# get account list
def test_get_account_list():
account_list = koios_python.get_account_list()
assert 'code' not in account_list[0]
# get account info
def test_get_account_info():
account_info = koios_python.get_account_info('stake1uyrx65wjqjgeeksd8hptmcgl5jfyrqkfq0xe8xlp367kphsckq250')
assert 'code' not in account_info[0]
# get account rewards
def test_get_account_rewards():
account_rewards = koios_python.get_account_rewards('stake1uyrx65wjqjgeeksd8hptmcgl5jfyrqkfq0xe8xlp367kphsckq250')
assert 'code' not in account_rewards[0]
# get account rewards by epoch
def test_get_account_rewards_by_epoch():
account_rewards = koios_python.get_account_rewards('stake1uyrx65wjqjgeeksd8hptmcgl5jfyrqkfq0xe8xlp367kphsckq250', 350)
assert 'code' not in account_rewards[0]
# get account updates
def test_get_account_updates():
account_updates = koios_python.get_account_updates('stake1uyrx65wjqjgeeksd8hptmcgl5jfyrqkfq0xe8xlp367kphsckq250')
assert 'code' not in account_updates[0]
# get account assets
def test_get_account_assets():
account_assets = koios_python.get_account_assets('stake1uyrx65wjqjgeeksd8hptmcgl5jfyrqkfq0xe8xlp367kphsckq250')
if len(account_assets) > 0:
assert 'code' not in account_assets[0]
# get account history
def test_get_account_history():
account_history = koios_python.get_account_history('stake1uyrx65wjqjgeeksd8hptmcgl5jfyrqkfq0xe8xlp367kphsckq250')
assert 'code' not in account_history[0]
##############################################################################
# ADDRESS FUNCTIONS
# get address info
def test_get_address_info():
address_info = koios_python.get_address_info("addr1qyp9kz50sh9c53hpmk3l4ewj9ur794t2hdqpngsjn3wkc5sztv9glpwt3frwrhdrltjaytc8ut2k4w6qrx3p98zad3fq07xe9g")
assert 'code' not in address_info[0]
# get address transactions
def test_get_address_transactions():
address_txs = koios_python.get_address_txs("addr1qyp9kz50sh9c53hpmk3l4ewj9ur794t2hdqpngsjn3wkc5sztv9glpwt3frwrhdrltjaytc8ut2k4w6qrx3p98zad3fq07xe9g")
assert 'code' not in address_txs[0]
address_txs_after_block = koios_python.get_address_txs("addr1qyp9kz50sh9c53hpmk3l4ewj9ur794t2hdqpngsjn3wkc5sztv9glpwt3frwrhdrltjaytc8ut2k4w6qrx3p98zad3fq07xe9g",1)
assert 'code' not in address_txs_after_block[0]
# get address assets
def test_get_address_assets():
address_assets = koios_python.get_address_assets("addr1qyp9kz50sh9c53hpmk3l4ewj9ur794t2hdqpngsjn3wkc5sztv9glpwt3frwrhdrltjaytc8ut2k4w6qrx3p98zad3fq07xe9g")
if len(address_assets) >0:
assert 'code' not in address_assets[0]
# get payment credentials hash
def test_get_credentials():
credentials = koios_python.get_credential_txs('025b0a8f85cb8a46e1dda3fae5d22f07e2d56abb4019a2129c5d6c52')
assert 'code' not in credentials[0]
credentials_after_block = koios_python.get_credential_txs('025b0a8f85cb8a46e1dda3fae5d22f07e2d56abb4019a2129c5d6c52',6238675)
assert 'code' not in credentials_after_block[0]
##############################################################################
# ASSET FUNCTIONS
# get asset list of all native tokens
def test_get_asset_list():
asset_list = koios_python.get_asset_list()
assert 'code' not in asset_list[0]
# get asset address list
def test_get_asset_address_list():
asset_address_list = koios_python.get_asset_address_list('750900e4999ebe0d58f19b634768ba25e525aaf12403bfe8fe130501','424f4f4b')
assert 'code' not in asset_address_list[0]
# get asset info
def test_get_asset_info():
asset_info = koios_python.get_asset_info('750900e4999ebe0d58f19b634768ba25e525aaf12403bfe8fe130501','424f4f4b')
assert 'code' not in asset_info[0]
# get asset history
def test_get_asset_history():
asset_history = koios_python.get_asset_history('750900e4999ebe0d58f19b634768ba25e525aaf12403bfe8fe130501','424f4f4b')
assert 'code' not in asset_history[0]
# get asset policy info
def test_get_asset_policy_info():
asset_policy_info = koios_python.get_asset_policy_info('750900e4999ebe0d58f19b634768ba25e525aaf12403bfe8fe130501')
assert 'code' not in asset_policy_info[0]
# get asset summary
def test_get_asset_summary():
asset_summary = koios_python.get_asset_summary('750900e4999ebe0d58f19b634768ba25e525aaf12403bfe8fe130501', '424f4f4b')
assert 'code' not in asset_summary[0]
# get asset transaction history
def test_get_asset_txs_history():
asset_txs_history = koios_python.get_asset_txs('750900e4999ebe0d58f19b634768ba25e525aaf12403bfe8fe130501', '424f4f4b')
assert 'code' not in asset_txs_history[0]
##############################################################################
# BLOCK FUNCTIONS
# get list of blocks
def test_get_blocks():
blocks = koios_python.get_blocks()
assert 'code' not in blocks[0]
# get block info
def test_get_block_info():
block_info = koios_python.get_block_info(["fb9087c9f1408a7bbd7b022fd294ab565fec8dd3a8ef091567482722a1fa4e30",
"60188a8dcb6db0d80628815be2cf626c4d17cb3e826cebfca84adaff93ad492a",
"c6646214a1f377aa461a0163c213fc6b86a559a2d6ebd647d54c4eb00aaab015"])
assert 'code' not in block_info[0]
# get block transactions
def test_get_block_txs():
block_txs = koios_python.get_block_txs(["fb9087c9f1408a7bbd7b022fd294ab565fec8dd3a8ef091567482722a1fa4e30"])
assert 'code' not in block_txs[0]
##############################################################################
# EPOCH FUNCTIONS
# get epoch info
def test_get_epoch_info():
epoch_info = koios_python.get_epoch_info()
assert 'code' not in epoch_info[0]
# get epoch params
def test_get_epoch_params():
epoch_params = koios_python.get_epoch_params()
assert 'code' not in epoch_params[0]
##############################################################################
# NETWORK FUNCTIONS
# check tip
def test_get_tip():
tip = koios_python.get_tip()
assert 'code' not in tip[0]
# check genesis info
def test_get_genesis():
genesis_info = koios_python.get_genesis()
assert 'code' not in genesis_info[0]
def test_get_totals():
epoch_totals = koios_python.get_totals()
assert 'code' not in epoch_totals[0]
##############################################################################
# POOL FUNCTIONS
# get list of pools on the network
def test_get_pool_list():
pool_list = koios_python.get_pool_list('0-10')
assert 'code' not in pool_list[0]
# get pool info
def test_get_pool_info():
pool_info = koios_python.get_pool_info(["pool100wj94uzf54vup2hdzk0afng4dhjaqggt7j434mtgm8v2gfvfgp",
"pool102s2nqtea2hf5q0s4amj0evysmfnhrn4apyyhd4azcmsclzm96m",
"pool102vsulhfx8ua2j9fwl2u7gv57fhhutc3tp6juzaefgrn7ae35wm"])
assert 'code' not in pool_info[0]
# get pool stake snapshot
def test_get_pool_stake_snapshot():
stake_snapshot = koios_python.get_pool_stake_snapshot("pool100wj94uzf54vup2hdzk0afng4dhjaqggt7j434mtgm8v2gfvfgp")
assert 'code' not in stake_snapshot[0]
# get pool delegator information
def test_get_pool_delegators():
delegator_info = koios_python.get_pool_delegators("pool100wj94uzf54vup2hdzk0afng4dhjaqggt7j434mtgm8v2gfvfgp")
assert 'code' not in delegator_info[0]
# get pool delegator history
def test_get_pool_delegators_history():
delegator_history = koios_python.get_pool_delegators_history("pool155efqn9xpcf73pphkk88cmlkdwx4ulkg606tne970qswczg3asc")
assert 'code' not in delegator_history[0]
delegator_history_epoch = koios_python.get_pool_delegators_history("pool155efqn9xpcf73pphkk88cmlkdwx4ulkg606tne970qswczg3asc", 320)
assert 'code' not in delegator_history_epoch[0]
# get pool blocks
def test_get_pool_blocks():
pool_blocks = koios_python.get_pool_blocks("pool155efqn9xpcf73pphkk88cmlkdwx4ulkg606tne970qswczg3asc")
assert 'code' not in pool_blocks[0]
pool_blocks_epoch = koios_python.get_pool_blocks("pool155efqn9xpcf73pphkk88cmlkdwx4ulkg606tne970qswczg3asc", 320)
assert 'code' not in pool_blocks_epoch[0]
# get pool history
def test_get_pool_history():
pool_history = koios_python.get_pool_history("pool155efqn9xpcf73pphkk88cmlkdwx4ulkg606tne970qswczg3asc")
assert 'code' not in pool_history[0]
pool_history_epoch = koios_python.get_pool_history("pool155efqn9xpcf73pphkk88cmlkdwx4ulkg606tne970qswczg3asc", 320)
assert 'code' not in pool_history_epoch[0]
# get pool updates
def test_get_pool_updates():
pool_updates = koios_python.get_pool_updates()
assert 'code' not in pool_updates[0]
# get pool relays
def test_get_pool_relays():
pool_relays = koios_python.get_pool_relays('0-10')
assert 'code' not in pool_relays[0]
# get pool metadata
def test_get_pool_metadata():
pool_metadata = koios_python.get_pool_metadata()
assert 'code' not in pool_metadata[0]
pool_metadata_id = koios_python.get_pool_metadata(["pool155efqn9xpcf73pphkk88cmlkdwx4ulkg606tne970qswczg3asc", "pool102s2nqtea2hf5q0s4amj0evysmfnhrn4apyyhd4azcmsclzm96m"])
assert 'code' not in pool_metadata_id[0]
##############################################################################
# SCRIPT FUNCTIONS
# get list of native scripts on the network
def test_get_native_script_list():
script_list = koios_python.get_native_script_list('0-10')
assert 'code' not in script_list[0]
# get plutus script list
def test_get_plutus_script_list():
script_list = koios_python.get_plutus_script_list('0-10')
assert 'code' not in script_list[0]
# get list of all redeemers for a given script hash
def test_get_script_redeemers():
script_redeemers = koios_python.get_script_redeemers('d8480dc869b94b80e81ec91b0abe307279311fe0e7001a9488f61ff8')
assert 'code' not in script_redeemers[0]
##############################################################################
# TRANSACTION FUNCTIONS
# get transaction(s) info
def test_tx_info():
tx_info = koios_python.get_tx_info("0b8ba3bed976fa4913f19adc9f6dd9063138db5b4dd29cecde369456b5155e94")
assert 'code' not in tx_info[0]
txs_info= koios_python.get_tx_info(["0b8ba3bed976fa4913f19adc9f6dd9063138db5b4dd29cecde369456b5155e94",
"f144a8264acf4bdfe2e1241170969c930d64ab6b0996a4a45237b623f1dd670e"])
assert 'code' not in txs_info[0]
# get transaction(s) utxos
def test_get_tx_utxos():
tx_utxos = koios_python.get_tx_utxos("0b8ba3bed976fa4913f19adc9f6dd9063138db5b4dd29cecde369456b5155e94")
assert 'code' not in tx_utxos[0]
txs_utxos = koios_python.get_tx_utxos(["0b8ba3bed976fa4913f19adc9f6dd9063138db5b4dd29cecde369456b5155e94",
"f144a8264acf4bdfe2e1241170969c930d64ab6b0996a4a45237b623f1dd670e"])
assert 'code' not in txs_utxos[0]
# get transaction(s) metadata
def test_get_tx_metadata():
tx_metadata = koios_python.get_tx_metadata("0b8ba3bed976fa4913f19adc9f6dd9063138db5b4dd29cecde369456b5155e94")
assert 'code' not in tx_metadata[0]
txs_metadata = koios_python.get_tx_metadata(["0b8ba3bed976fa4913f19adc9f6dd9063138db5b4dd29cecde369456b5155e94",
"f144a8264acf4bdfe2e1241170969c930d64ab6b0996a4a45237b623f1dd670e"])
assert 'code' not in txs_metadata[0]
# get transaction(s) metadata labels
def test_get_tx_metalabels():
tx_metalables = koios_python.get_tx_metalabels("0b8ba3bed976fa4913f19adc9f6dd9063138db5b4dd29cecde369456b5155e94")
assert 'code' not in tx_metalables[0]
txs_metalables = koios_python.get_tx_metalabels(["0b8ba3bed976fa4913f19adc9f6dd9063138db5b4dd29cecde369456b5155e94",
"f144a8264acf4bdfe2e1241170969c930d64ab6b0996a4a45237b623f1dd670e"])
assert 'code' not in txs_metalables[0]
# NOT FINISHED
# submit_tx signed cbor
# def test_submit_tx():
# tx_submit = koios_python.submit_tx("file")
# assert 'code' not in tx_submit[0]
# get tx status
def test_get_tx_status():
tx_status = koios_python.get_tx_status("0b8ba3bed976fa4913f19adc9f6dd9063138db5b4dd29cecde369456b5155e94")
assert 'code' not in tx_status[0]
txs_status = koios_python.get_tx_status(["0b8ba3bed976fa4913f19adc9f6dd9063138db5b4dd29cecde369456b5155e94",
"f144a8264acf4bdfe2e1241170969c930d64ab6b0996a4a45237b623f1dd670e"])
assert 'code' not in txs_status[0]