-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest_datafeed.py
32 lines (24 loc) · 1.03 KB
/
test_datafeed.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
from sim import Key, Simulator, compile_serpent
from pyethereum import utils
class TestDatafeed(object):
ALICE = Key('cow')
@classmethod
def setup_class(cls):
cls.code = compile_serpent('examples/datafeed.se')
cls.sim = Simulator({cls.ALICE.address: 10**18})
def setup_method(self, method):
self.sim.reset()
self.contract = self.sim.load_contract(self.ALICE, self.code)
def test_store_single(self):
data = ['key', 'value']
ans = self.sim.tx(self.ALICE, self.contract, 0, data)
assert ans == [1]
storage = self.sim.get_storage_dict(self.contract)
assert storage.get(utils.zpad('key', 32)) == 'value'
def test_store_multiple(self):
data = ['key1', 'value1', 'key2', 'value2']
ans = self.sim.tx(self.ALICE, self.contract, 0, data)
assert ans == [1]
storage = self.sim.get_storage_dict(self.contract)
assert storage.get(utils.zpad('key1', 32)) == 'value1'
assert storage.get(utils.zpad('key2', 32)) == 'value2'