-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_oracle.py
36 lines (30 loc) · 1.66 KB
/
test_oracle.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
import base64
from neo_fairy_client.rpc import FairyClient
from neo_fairy_client.utils.types import Hash160Str, Signer, WitnessScope
from neo_fairy_client.utils.interpreters import Interpreter
target_url = 'http://127.0.0.1:16868'
wallet_address = 'Nb2CHYY5wTh2ac58mTue5S3wpG6bQv5hSY'
wallet_scripthash = Hash160Str.from_address(wallet_address)
with open('../neo-fairy-oracle/oracle-demo/bin/sc/oracle-demo.nef', 'rb') as f:
nef_file = f.read()
with open('../neo-fairy-oracle/oracle-demo/bin/sc/oracle-demo.manifest.json', 'r') as f:
manifest = f.read()
with open('../neo-fairy-oracle/oracle-demo/bin/sc/oracle-demo.nefdbgnfo', 'rb') as f:
nefdbgnfo = f.read()
with open('../neo-fairy-oracle/oracle-demo/bin/sc/oracle-demo.nef.txt', 'r') as f:
dumpnef = f.read()
fairy_session = 'oracle'
client = FairyClient(target_url, wallet_address, fairy_session=fairy_session, with_print=True)
client.delete_snapshots(client.list_snapshots())
client.new_snapshots_from_current_system()
client.set_gas_balance(100_0000_0000)
client.contract_scripthash = client.virtual_deploy(nef_file, manifest)
print(client.contract_scripthash)
# client.set_debug_info(nefdbgnfo, dumpnef)
# client.set_assembly_breakpoints(65)
#
# print(client.debug_function_with_session('createRequest', ['https://www.binance.com/api/v3/ticker/price?symbol=NEOUSDT', 'price', 'callback', 'testUserData', 1_0000_0000]))
# print(client.debug_step_over_assembly())
# print(client.debug_continue())
result = client.invokefunction('createRequest', ['https://www.binance.com/api/v3/ticker/price?symbol=NEOUSDT', 'price', 'callback', 'testUserData', 1_0000_0000])
print(client.previous_raw_result['result']['oraclerequests'])