def __init__(self, contract_address, account=None, ipfs=IPFS('127.0.0.1', 5001), web3_host='localhost', web3_port=9545): """Creates the base blockchain client object (web3) then connects to the Sonar contract. It assumes you're working with a local testrpc blockchain.""" self.ipfs = ipfs self.web3 = Web3(KeepAliveRPCProvider(host=web3_host, port=str(web3_port))) if account is not None: self.account = account else: print("No account submitted... using default[2]") self.account = self.web3.eth.accounts[2] self.connect_to_contract(contract_address)
def __init__(self, contract_address, account=None, ipfs=IPFS('127.0.0.1', 5001), web3_host='localhost', web3_port=8545): """Creates the base blockchain client object (web3) then connects to the Sonar contract. It assumes you're working with a local testrpc blockchain.""" self.ipfs = ipfs #self.web3 = Web3(KeepAliveRPCProvider(host=web3_host,port=str(web3_port))) self.web3 = Web3(HTTPProvider('http://18.224.21.109:8545')) #self.web3 = Web3(Web3.EthereumTesterProvider()) #self.web3 = Web3(Web3.EthereumTesterProvider()) print('web3.version.api',self.web3.version.api) if account is not None: self.account = account else: print("No account submitted... using default[2]") self.account = self.web3.eth.accounts[2] self.connect_to_contract(contract_address)
def test_retrieval_of_stored_obj(): storage = IPFS(host='127.0.0.1', port=5001) obj_to_store = {'foo': 'bar'} address = storage.store(obj_to_store) retrieved_obj = storage.retrieve(address) assert retrieved_obj == obj_to_store