from brownie import AdvancedCollectiblefrom scripts.helpful_scripts import get_account, OpenSeaURL, get_contract, fund_with_linkfrom brownie import config, network # OpenSea Testnet is on rinkebydefdeploy(): account =get_account() advanced_collectible = AdvancedCollectible.deploy(get_contract("vrf_coordinator").address,get_contract("link_token").address, config["networks"][network.show_active()]["fee"], config["networks"][network.show_active()]["keyhash"], {"from": account}, publish_source = config["networks"][network.show_active()].get("verify", False) )# fund w/ linkfund_with_link(advanced_collectible.address)# create create_tx = advanced_collectible.createCollectible({"from": account}) create_tx.wait(1)print("New NFT has been created")return advanced_collectible, create_txdefmain():deploy()
We can deploy to either our local environment or rinkeby for testing. Unit testing will be done locally, while integration testing will be conducted on rinkeby.
Even if we are testing only one function (-k), brownie will collect and compile all tests - so if there are errors in the others, they will be surfaced.
Interacting with rinkeby deployment
from brownie import AdvancedCollectiblefrom scripts.helpful_scripts import fund_with_link, get_account, get_contractfrom web3 import Web3# for interacting with live rinkeby deployed contractdefmain(): account =get_account() advanced_collectible = AdvancedCollectible[-1]# fund with linkfund_with_link(advanced_collectible.address, amount=Web3.toWei(0.1, "ether"))# create create_tx = advanced_collectible.createCollectible({"from": account}) create_tx.wait(1)print("New NFT has been created")return advanced_collectible, create_tx
This will reference our most recent rinkeby deployment, as per our build folder. If there was no previous deployment or build folder was deleted, AdvancedCollectible[-1] will error out.