@@ -99,26 +99,30 @@ describe("Immutable ERC721 Permissioned Mintable Test Cases", function () {
9999
100100 it ( "Should allow safe minting of batch tokens" , async function ( ) {
101101 const mintRequests = [
102- { to : user . address , tokenIds : [ 2 , 3 , 4 ] } ,
103- { to : owner . address , tokenIds : [ 6 , 7 , 8 ] } ,
102+ { to : user . address , tokenIds : [ 2 , 3 , 4 , 5 , 6 ] } ,
103+ { to : owner . address , tokenIds : [ 7 , 8 , 9 , 10 , 11 ] } ,
104104 ] ;
105105 await erc721 . connect ( minter ) . safeMintBatch ( mintRequests ) ;
106- expect ( await erc721 . balanceOf ( user . address ) ) . to . equal ( 4 ) ;
107- expect ( await erc721 . balanceOf ( owner . address ) ) . to . equal ( 3 ) ;
108- expect ( await erc721 . totalSupply ( ) ) . to . equal ( 7 ) ;
106+ expect ( await erc721 . balanceOf ( user . address ) ) . to . equal ( 6 ) ;
107+ expect ( await erc721 . balanceOf ( owner . address ) ) . to . equal ( 5 ) ;
108+ expect ( await erc721 . totalSupply ( ) ) . to . equal ( 11 ) ;
109109 expect ( await erc721 . ownerOf ( 2 ) ) . to . equal ( user . address ) ;
110110 expect ( await erc721 . ownerOf ( 3 ) ) . to . equal ( user . address ) ;
111111 expect ( await erc721 . ownerOf ( 4 ) ) . to . equal ( user . address ) ;
112- expect ( await erc721 . ownerOf ( 6 ) ) . to . equal ( owner . address ) ;
112+ expect ( await erc721 . ownerOf ( 5 ) ) . to . equal ( user . address ) ;
113+ expect ( await erc721 . ownerOf ( 6 ) ) . to . equal ( user . address ) ;
113114 expect ( await erc721 . ownerOf ( 7 ) ) . to . equal ( owner . address ) ;
114115 expect ( await erc721 . ownerOf ( 8 ) ) . to . equal ( owner . address ) ;
116+ expect ( await erc721 . ownerOf ( 9 ) ) . to . equal ( owner . address ) ;
117+ expect ( await erc721 . ownerOf ( 10 ) ) . to . equal ( owner . address ) ;
118+ expect ( await erc721 . ownerOf ( 11 ) ) . to . equal ( owner . address ) ;
115119 } ) ;
116120
117121 it ( "Should allow owner or approved to burn a batch of tokens" , async function ( ) {
118- expect ( await erc721 . balanceOf ( user . address ) ) . to . equal ( 4 ) ;
122+ expect ( await erc721 . balanceOf ( user . address ) ) . to . equal ( 6 ) ;
119123 await erc721 . connect ( user ) . burnBatch ( [ 1 , 2 ] ) ;
120- expect ( await erc721 . balanceOf ( user . address ) ) . to . equal ( 2 ) ;
121- expect ( await erc721 . totalSupply ( ) ) . to . equal ( 5 ) ;
124+ expect ( await erc721 . balanceOf ( user . address ) ) . to . equal ( 4 ) ;
125+ expect ( await erc721 . totalSupply ( ) ) . to . equal ( 9 ) ;
122126 } ) ;
123127
124128 it ( "Should prevent not approved to burn a batch of tokens" , async function ( ) {
@@ -133,17 +137,84 @@ describe("Immutable ERC721 Permissioned Mintable Test Cases", function () {
133137 . to . be . revertedWith ( "IImmutableERC721TokenAlreadyBurned" )
134138 . withArgs ( 1 ) ;
135139 } ) ;
140+
141+ it ( "Should not allow owner or approved to safely burn a token when specifying the incorrect owner" , async function ( ) {
142+ await expect (
143+ erc721 . connect ( user ) . safeBurn ( owner . address , 3 )
144+ ) . to . be . revertedWith ( 'IImmutableERC721MismatchedTokenOwner' ) . withArgs ( 3 , user . address ) ;
145+ } ) ;
146+
147+ it ( "Should allow owner or approved to safely burn a token when specifying the correct owner" , async function ( ) {
148+ const originalBalance = await erc721 . balanceOf ( user . address ) ;
149+ const originalSupply = await erc721 . totalSupply ( ) ;
150+ await erc721 . connect ( user ) . safeBurn ( user . address , 3 ) ;
151+ expect ( await erc721 . balanceOf ( user . address ) ) . to . equal (
152+ originalBalance . sub ( 1 )
153+ ) ;
154+ expect ( await erc721 . totalSupply ( ) ) . to . equal (
155+ originalSupply . sub ( 1 )
156+ ) ;
157+ } ) ;
158+
159+ it ( "Should not allow owner or approved to burn a batch of tokens when specifying the incorrect owners" , async function ( ) {
160+ const burns = [
161+ {
162+ owner : user . address ,
163+ tokenIds : [ 7 , 8 , 9 ] ,
164+ } ,
165+ {
166+ owner : owner . address ,
167+ tokenIds : [ 4 , 5 , 6 ] ,
168+ } ,
169+ ] ;
170+
171+ await expect (
172+ erc721 . connect ( user ) . safeBurnBatch ( burns )
173+ ) . to . be . revertedWith ( 'IImmutableERC721MismatchedTokenOwner' ) . withArgs ( 7 , owner . address ) ;
174+ } ) ;
175+
176+ it ( "Should allow owner or approved to safely burn a batch of tokens when specifying the correct owners" , async function ( ) {
177+ const originalUserBalance = await erc721 . balanceOf ( user . address ) ;
178+ const originalOwnerBalance = await erc721 . balanceOf ( owner . address ) ;
179+ const originalSupply = await erc721 . totalSupply ( ) ;
180+
181+ // Set approval for owner to burn these tokens from user.
182+ await erc721 . connect ( user ) . approve ( owner . address , 4 ) ;
183+ await erc721 . connect ( user ) . approve ( owner . address , 5 ) ;
184+ await erc721 . connect ( user ) . approve ( owner . address , 6 ) ;
185+
186+ const burns = [
187+ {
188+ owner : owner . address ,
189+ tokenIds : [ 7 , 8 , 9 ] ,
190+ } ,
191+ {
192+ owner : user . address ,
193+ tokenIds : [ 4 , 5 , 6 ] ,
194+ } ,
195+ ] ;
196+ await erc721 . connect ( owner ) . safeBurnBatch ( burns ) ;
197+ expect ( await erc721 . balanceOf ( user . address ) ) . to . equal (
198+ originalUserBalance . sub ( 3 )
199+ ) ;
200+ expect ( await erc721 . balanceOf ( owner . address ) ) . to . equal (
201+ originalOwnerBalance . sub ( 3 )
202+ ) ;
203+ expect ( await erc721 . totalSupply ( ) ) . to . equal (
204+ originalSupply . sub ( 6 )
205+ ) ;
206+ } ) ;
136207 } ) ;
137208
138209 describe ( "Base URI and Token URI" , function ( ) {
139210 it ( "Should return a non-empty tokenURI when the base URI is set" , async function ( ) {
140- const tokenId = 10 ;
211+ const tokenId = 100 ;
141212 await erc721 . connect ( minter ) . mint ( user . address , tokenId ) ;
142213 expect ( await erc721 . tokenURI ( tokenId ) ) . to . equal ( `${ baseURI } ${ tokenId } ` ) ;
143214 } ) ;
144215
145216 it ( "Should revert with a burnt tokenId" , async function ( ) {
146- const tokenId = 10 ;
217+ const tokenId = 100 ;
147218 await erc721 . connect ( user ) . burn ( tokenId ) ;
148219 await expect ( erc721 . tokenURI ( tokenId ) ) . to . be . revertedWith (
149220 "ERC721: invalid token ID"
@@ -172,7 +243,7 @@ describe("Immutable ERC721 Permissioned Mintable Test Cases", function () {
172243
173244 it ( "Should return an empty token URI when the base URI is not set" , async function ( ) {
174245 await erc721 . setBaseURI ( "" ) ;
175- const tokenId = 12 ;
246+ const tokenId = 101 ;
176247 await erc721 . connect ( minter ) . mint ( user . address , tokenId ) ;
177248 expect ( await erc721 . tokenURI ( tokenId ) ) . to . equal ( "" ) ;
178249 } ) ;
0 commit comments