def get_proposal_list(self): nr_proposals = self.sim.get_storage_data(self.contract, coerce_to_bytes(2**162 - 1)) proposals = [] for idx in range(nr_proposals): proposals.append( coerce_addr_to_hex( self.sim.get_storage_data(self.contract, coerce_to_bytes(2**162 + idx)))) return proposals
def get_account_list(self): nr_accounts = self.sim.get_storage_data(self.contract, coerce_to_bytes(2**160 - 1)) accounts = [] for idx in range(nr_accounts): accounts.append( coerce_addr_to_hex( self.sim.get_storage_data(self.contract, coerce_to_bytes(2**160 + idx)))) return accounts
def test_exhibit(self): data = ["exhibit"] response = self.sim.tx(self.accounts["artist"], self.contract, 0, data) print response work = '' for fragment in response: work += coerce_to_bytes(fragment) assert work == self.WORK
def result(ans): if ans[0] != 0: # error if len(ans) > 1: raise ContractError(coerce_to_bytes(ans[1])) else: raise ContractError() else: return ans[1:]
def test_create_work(self): data = [] response = self.sim.tx(self.accounts["beholder"], self.contract, 0, data) assert coerce_to_bytes(response[0]) == self.ARTWORK assert response[1] == self.ARTWORK_NUMBER
def get_proposal_votes(self, proposal): proposal_id = self.get_proposal_id(proposal) return self.sim.get_storage_data(self.contract, coerce_to_bytes(proposal_id + 2**163 + 2))
def get_proposal_list(self): nr_proposals = self.sim.get_storage_data(self.contract, coerce_to_bytes(2**162-1)) proposals = [] for idx in range(nr_proposals): proposals.append(coerce_addr_to_hex(self.sim.get_storage_data(self.contract, coerce_to_bytes(2**162 + idx)))) return proposals
def get_account_list(self): nr_accounts = self.sim.get_storage_data(self.contract, coerce_to_bytes(2**160-1)) accounts = [] for idx in range(nr_accounts): accounts.append(coerce_addr_to_hex(self.sim.get_storage_data(self.contract, coerce_to_bytes(2**160 + idx)))) return accounts
def get_proposal_recipient(self, proposal): proposal_id = self.get_proposal_id(proposal) return coerce_addr_to_hex(self.sim.get_storage_data(self.contract, coerce_to_bytes(proposal_id + 2**163)))
def test_toggle(self): data = ["toggle"] ans = self.sim.tx(self.accounts["artist"], self.contract, 0, data) assert coerce_to_bytes(ans[0]) == "is" ans = self.sim.tx(self.accounts["artist"], self.contract, 0, data) assert coerce_to_bytes(ans[0]) == "is not"
def get_commons_balance(self): return self.sim.get_storage_data(self.contract, coerce_to_bytes(42))
def get_account_timestamp(self, address): return self.sim.get_storage_data( self.contract, coerce_to_bytes(int(address, 16) + 2**161 + 1))
def test_work(self): data = [] response = self.sim.tx(self.accounts["artist"], self.contract, 0, data) assert coerce_to_bytes(response[0]) == self.WORK
def get_account_tax_credits(self, address): return self.sim.get_storage_data( self.contract, coerce_to_bytes(int(address, 16) + 2**161 + 2))
def get_proposal_votes(self, proposal): proposal_id = self.get_proposal_id(proposal) return self.sim.get_storage_data( self.contract, coerce_to_bytes(proposal_id + 2**163 + 2))
def get_proposal_recipient(self, proposal): proposal_id = self.get_proposal_id(proposal) return coerce_addr_to_hex( self.sim.get_storage_data(self.contract, coerce_to_bytes(proposal_id + 2**163)))
def test_exhibit(self): data = ["exhibit"] response = self.sim.tx(self.accounts["beholder"], self.contract, 0, data) assert coerce_to_bytes(response[0]) == self.WORK
def test_create_work(self): data = ["create"] response = self.sim.tx(self.accounts["beholder"], self.contract, 0, data) artwork = "".join([coerce_to_bytes(fragment) for fragment in response]) assert artwork == self.ARTWORK_FOR_BEHOLDER
def get_account_timestamp(self, address): return self.sim.get_storage_data(self.contract, coerce_to_bytes(int(address, 16) + 2**161 + 1))
def test_do_nothing(self): data = [] ans = self.sim.tx(self.accounts["artist"], self.contract, 0, data) assert coerce_to_bytes(ans[0]) == "is not"
def get_account_tax_credits(self, address): return self.sim.get_storage_data(self.contract, coerce_to_bytes(int(address, 16) + 2**161 + 2))