Custom and numbered work examples updated to work without byte arrays. Revisit this...
[robmyers:artworld-ethereum.git] / tests / test_numbered_works.py
1 from sim import Key, Simulator, load_serpent
2 from pyethereum.utils import coerce_to_bytes
3
4 class TestNumberedWorks(object):
5
6     ARTIST = Key('artist') # 8802b7f0bfa5e9f5825f2fc708e1ad00d2c2b5d6
7     BEHOLDER = Key('beholder') # 7e5188934964c0c267839653f7a49c879c2c8dfc
8     INDEX1001 = coerce_to_bytes(1001)
9     ARTWORK = "Work #"
10     ARTWORK_NUMBER = 1
11
12     @classmethod
13     def setup_class(cls):
14         cls.code = load_serpent('serpent/numbered_works.se')
15         cls.sim = Simulator({cls.ARTIST.address: 10**18,
16                              cls.BEHOLDER.address: 10**18})
17
18     def setup_method(self, method):
19         self.sim.reset()
20         self.contract = self.sim.load_contract(self.ARTIST, self.code)
21
22     def test_initial_state(self):
23         # Get storage data only returns int...
24         assert self.sim.get_storage_data(self.contract, self.INDEX1001) == 1
25
26     def test_create_work(self):
27         data = []
28         response = self.sim.tx(self.BEHOLDER, self.contract, 0, data)
29         assert coerce_to_bytes(response[0]) == self.ARTWORK
30         assert response[1] == self.ARTWORK_NUMBER