Skip to content

Commit

Permalink
TestGetEdition (#22)
Browse files Browse the repository at this point in the history
Started here. I was able to cast script result into UInt64 to get the
first nftID and `get_editions_flowty_wrapped` test passed. There is
probably a better way to do this but pushing what I have for now

---------

Co-authored-by: ash <[email protected]>
  • Loading branch information
web3ashlee and ash authored Dec 20, 2023
1 parent 35a5084 commit ec46a37
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
11 changes: 11 additions & 0 deletions scripts/get_nft_ids.cdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import "NonFungibleToken"

import "FlowtyWrapped"

pub fun main(addr: Address): [UInt64] {
let cp = getAccount(addr).getCapability<&{NonFungibleToken.CollectionPublic}>(FlowtyWrapped.CollectionPublicPath).borrow()
?? panic("collection not found")

let nftIDs = cp.getIDs()
return nftIDs
}
24 changes: 18 additions & 6 deletions test/FlowtyWrapped_tests.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Test
import "test_helpers.cdc"

import "FlowtyWrapped"
import "MetadataViews"

pub let rafflesAcct = Test.getAccount(Address(0x0000000000000007))
pub let minterAccount = Test.getAccount(Address(0x0000000000000007))
Expand Down Expand Up @@ -42,6 +43,21 @@ pub fun testSetupManager() {

pub fun testMint() {
let acct = Test.createAccount()
setupForMint(acct: acct)
}

pub fun testGetEditions() {
let acct = Test.createAccount()
setupForMint(acct: acct)
let result = scriptExecutor("get_nft_ids.cdc", [acct.address])

let castedResult = result! as! [UInt64]
var nftID1 = castedResult[0]

scriptExecutor("get_editions_flowty_wrapped.cdc", [acct.address, nftID1])
}

pub fun setupForMint(acct: Test.Account) {

txExecutor("setup_flowty_wrapped.cdc", [acct], [], nil)

Expand All @@ -52,7 +68,7 @@ pub fun testMint() {
let favoriteCollections: [String] = [""]
let collections: [String] = [""]

mintFlowtyWrapped(address: acct.address, username: username, ticket: ticket, totalNftsOwned: totalNftsOwned, floatCount: floatCount, favoriteCollections: favoriteCollections, collections: collections)
txExecutor("mint_flowty_wrapped.cdc", [minterAccount], [acct.address, username, ticket, totalNftsOwned, floatCount, favoriteCollections, collections], nil)
}

pub fun testSingleMint() {
Expand All @@ -67,7 +83,7 @@ pub fun testSingleMint() {
let favoriteCollections: [String] = [""]
let collections: [String] = [""]

mintFlowtyWrapped(address: acct.address, username: username, ticket: ticket, totalNftsOwned: totalNftsOwned, floatCount: floatCount, favoriteCollections: favoriteCollections, collections: collections)
txExecutor("mint_flowty_wrapped.cdc", [minterAccount], [acct.address, username, ticket, totalNftsOwned, floatCount, favoriteCollections, collections], nil)

// now try to mint again, this should fail
txExecutor("mint_flowty_wrapped.cdc", [minterAccount], [acct.address, username, ticket, totalNftsOwned, floatCount, favoriteCollections, collections], "address has already been minted")
Expand All @@ -76,7 +92,3 @@ pub fun testSingleMint() {
pub fun registerEdition(rafflesAcct: Test.Account, removeAfterReveal: Bool, start: UInt64, end: UInt64, baseImageUrl: String, baseHtmlUrl: String) {
txExecutor("register_edition.cdc", [rafflesAcct], [removeAfterReveal, start, end, baseImageUrl, baseHtmlUrl], nil)
}

pub fun mintFlowtyWrapped(address: Address, username: String, ticket: Int, totalNftsOwned: Int, floatCount: Int, favoriteCollections: [String], collections: [String]) {
txExecutor("mint_flowty_wrapped.cdc", [minterAccount], [address, username, ticket, totalNftsOwned, floatCount, favoriteCollections, collections], nil)
}

0 comments on commit ec46a37

Please sign in to comment.