base.py (1650B)
1 # external imports 2 from chainlib.eth.unittest.ethtester import EthTesterCase 3 from chainlib.connection import RPCConnection 4 from chainlib.eth.nonce import RPCNonceOracle 5 from chainlib.eth.tx import receipt 6 7 # local imports 8 from eth_writer import EthWriter 9 10 11 class TestEthWriterInterface: 12 13 def test_add_delete(self): 14 writer_contract_address = self.contracts['writer'] 15 publisher_address = self.roles.get('publisher') 16 writer_account = self.roles['writer'] 17 18 nonce_oracle = RPCNonceOracle(self.publisher, conn=self.conn) 19 c = EthWriter(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) 20 21 o = c.is_writer(writer_contract_address, publisher_address, sender_address=publisher_address) 22 r = self.rpc.do(o) 23 self.assertEqual(int(r, 16), 1) 24 25 self.alice = self.accounts[1] 26 (tx_hash, o) = c.add_writer(writer_contract_address, publisher_address, writer_account) 27 self.rpc.do(o) 28 o = receipt(tx_hash) 29 r = self.rpc.do(o) 30 self.assertEqual(r['status'], 1) 31 32 o = c.is_writer(writer_contract_address, writer_account, sender_address=publisher_address) 33 r = self.rpc.do(o) 34 self.assertEqual(int(r, 16), 1) 35 36 self.alice = self.accounts[1] 37 (tx_hash, o) = c.delete_writer(writer_contract_address, publisher_address, writer_account) 38 self.rpc.do(o) 39 o = receipt(tx_hash) 40 r = self.rpc.do(o) 41 self.assertEqual(r['status'], 1) 42 43 o = c.is_writer(writer_contract_address, self.alice, sender_address=publisher_address) 44 r = self.rpc.do(o) 45 self.assertEqual(int(r, 16), 0)