def deploy_api_contract(get_account, get_oracle, get_job_id, chainlink_fee, get_link_token): # Arrange / Act api_consumer = APIConsumer.deploy(get_oracle.address, get_job_id, chainlink_fee, get_link_token.address, {'from': get_account}) # Assert assert api_consumer is not None return api_consumer
def main(): dev = accounts.add(config["wallets"]["from_key"]) return APIConsumer.deploy( config["networks"][network.show_active()]["oracle"], config["networks"][network.show_active()]["jobId"], config["networks"][network.show_active()]["fee"], config["networks"][network.show_active()]["link_token"], {"from": dev}, publish_source=config["verify"], )
def test_chainlink_api_call_without_link(job_id, dev_account, node_account, chainlink_fee): # Arrange link_token = LinkToken.deploy({"from": dev_account}) oracle = MockOracle.deploy(link_token.address, {"from": dev_account}) api_consumer = APIConsumer.deploy(oracle.address, job_id, chainlink_fee, link_token.address, {"from": dev_account}) oracle.setFulfillmentPermission(node_account, True, {"from": dev_account}) # Act / Assert with pytest.raises(brownie.exceptions.VirtualMachineError): api_consumer.requestVolumeData({"from": dev_account})
def deploy_api_contract(get_testnet_account): # Arrange if network.show_active() != 'kovan': pytest.skip('Only works for kovan network') # Act api_consumer = APIConsumer.deploy( config['networks'][network.show_active()]['oracle'], config['networks'][network.show_active()]['jobId'], config['networks'][network.show_active()]['fee'], {'from': get_testnet_account}) # Assert assert api_consumer is not None return api_consumer
def test_chainlink_api_call_with_link(job_id, dev_account, node_account, chainlink_fee): # Arrange link_token = LinkToken.deploy({"from": dev_account}) oracle = MockOracle.deploy(link_token.address, {"from": dev_account}) api_consumer = APIConsumer.deploy(oracle.address, job_id, chainlink_fee, link_token.address, {"from": dev_account}) oracle.setFulfillmentPermission(node_account, True, {"from": dev_account}) link_token.transfer(api_consumer.address, chainlink_fee, {"from": dev_account}) # Act transaction_data = api_consumer.requestVolumeData({"from": dev_account}) # Assert assert oracle.address == transaction_data.logs[3].address
def deploy_api_contract(get_job_id, chainlink_fee): # Arrange / Act api_consumer = APIConsumer.deploy( get_contract("oracle").address, get_job_id, chainlink_fee, get_contract("link_token").address, {"from": get_account()}, ) block_confirmations=6 if network.show_active() in LOCAL_BLOCKCHAIN_ENVIRONMENTS: block_confirmations=1 api_consumer.tx.wait(block_confirmations) # Assert assert api_consumer is not None return api_consumer
def deploy_api_consumer(): jobId = config["networks"][network.show_active()]["jobId"] fee = config["networks"][network.show_active()]["fee"] account = get_account() oracle = get_contract("oracle").address link_token = get_contract("link_token").address api_consumer = APIConsumer.deploy( oracle, Web3.toHex(text=jobId), fee, link_token, {"from": account}, ) if (config["networks"][network.show_active()].get("verify", False)): api_consumer.tx.wait(BLOCK_CONFIRMATIONS_FOR_VERIFICATION) APIConsumer.publish_source(api_consumer) else: api_consumer.tx.wait(1) print(f"API Consumer deployed to {api_consumer.address}") return api_consumer
def test_chainlink_api_call_with_link_fulfilled(job_id, dev_account, node_account, chainlink_fee, expiry_time): # Arrange link_token = LinkToken.deploy({"from": dev_account}) oracle = MockOracle.deploy(link_token.address, {"from": dev_account}) api_consumer = APIConsumer.deploy( oracle.address, "29fa9aa13bf1468788b7cc4a500a45b8", chainlink_fee, link_token.address, {"from": dev_account}, ) oracle.setFulfillmentPermission(node_account, True, {"from": dev_account}) link_token.transfer(api_consumer.address, chainlink_fee * 3, {"from": dev_account}) transaction_receipt = api_consumer.requestVolumeData({"from": dev_account}) reqid = transaction_receipt.events["ChainlinkRequested"]["id"] selector = "" # Act for key, value in api_consumer.__dict__["selectors"].items(): if value == "fulfill": selector = key # We cheated and added `exp_time` to a public variable in the Oracle.sol # This is all needed because fulfillOracleRequest hashes all the params and checks to make sure the # Hashes all match # We are using a modified Oracle.sol successful = oracle.fulfillOracleRequest( reqid, chainlink_fee, api_consumer.address, selector, oracle.exp_time(), "", {"from": node_account}, ) assert successful.status == 1
def main(): dev = accounts.add(os.getenv(config['wallets']['from_key'])) return APIConsumer.deploy( config['networks'][network.show_active()]['oracle'], config['networks'][network.show_active()]['jobId'], config['networks'][network.show_active()]['fee'], {'from': dev})