-
Notifications
You must be signed in to change notification settings - Fork 2
/
sktest_contract_persistance.py
62 lines (42 loc) · 1.38 KB
/
sktest_contract_persistance.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
from sktest import *
from sktest_helpers import *
from solc import compile_files
from web3.contract import *
import time
import json
ch = create_default_chain(num_nodes=int(os.getenv("NUM_NODES", 4)), num_accounts=2)
ch.start()
print("started")
compiled = compile_files(["Topic.sol"])
topic_sol = compiled['Topic.sol:Topic']
print("compiled")
try:
Topic = ch.eth.contract(abi=topic_sol['abi'], bytecode=topic_sol['bin'])
tx = Topic.constructor().buildTransaction({'from':ch.accounts[0]})
hash = ch.transaction_async(data=tx['data'], to="0x0000000000000000000000000000000000000000", value=998, gas=300000)
print("async")
receipt = None
while not receipt:
receipt = ch.eth.getTransactionReceipt(hash)
time.sleep(0.1)
print(receipt)
topic1 = ch.eth.contract(
address=receipt.contractAddress,
abi=topic_sol['abi'],
)
print(topic1)
#print("Before:")
#print( topic1.functions.get().call() )
tx = topic1.functions.set('Contract Test Topic').buildTransaction({'from':ch.accounts[0]})
hash = ch.transaction_async(data=tx['data'], gas=300000)
receipt = None
while not receipt:
receipt = ch.eth.getTransactionReceipt(hash)
time.sleep(0.1)
print(receipt)
print("After:")
print( topic1.functions.get().call() )
except Exception as e:
print("excepted!")
print(str(e))
input()