adv_deploy() + Testing

  • OpenSea testnet is on Rinkeby

from brownie import AdvancedCollectible
from scripts.helpful_scripts import get_account, OpenSeaURL, get_contract, fund_with_link
from brownie import config, network 

# OpenSea Testnet is on rinkeby
def deploy():
    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/ link
    fund_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_tx

def main():
    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.

Unit Testing

  • Since this will be executed on development network(ganache-cli), we will need mocks deployed.

  • Additionally, we will need to simulate the off-chain response to the VRF coordinator, and it calling callBackWithRandomness.

  • Here we opt to pass 777 as our random number.

  • Assert that NFT is minted

    • tokenCounter incremented

    • breed assigned

Integration Testing

This will be executed on rinkeby.

Interacting with rinkeby deployment

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.

Last updated