From ec46a3701daa71b744c6f51b82bcd27e51ef10ce Mon Sep 17 00:00:00 2001 From: ashlee <100004665+web3ashlee@users.noreply.github.com> Date: Wed, 20 Dec 2023 09:33:41 -0600 Subject: [PATCH] TestGetEdition (#22) 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 --- scripts/get_nft_ids.cdc | 11 +++++++++++ test/FlowtyWrapped_tests.cdc | 24 ++++++++++++++++++------ 2 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 scripts/get_nft_ids.cdc diff --git a/scripts/get_nft_ids.cdc b/scripts/get_nft_ids.cdc new file mode 100644 index 0000000..bb59168 --- /dev/null +++ b/scripts/get_nft_ids.cdc @@ -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 +} \ No newline at end of file diff --git a/test/FlowtyWrapped_tests.cdc b/test/FlowtyWrapped_tests.cdc index 162f33f..98742e4 100644 --- a/test/FlowtyWrapped_tests.cdc +++ b/test/FlowtyWrapped_tests.cdc @@ -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)) @@ -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) @@ -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() { @@ -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") @@ -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) -} \ No newline at end of file