@@ -146,3 +146,127 @@ func TestIssueNFTCreateAndBurn(t *testing.T) {
146146 require .Nil (t , err )
147147 require .False (t , genericResponse .Docs [0 ].Found )
148148}
149+
150+ func TestIssueNFTCreateAndBurnNonFungibleV2 (t * testing.T ) {
151+ setLogLevelDebug ()
152+
153+ esClient , err := createESClient (esURL )
154+ require .Nil (t , err )
155+
156+ // ################ ISSUE NON FUNGIBLE TOKEN #########################
157+
158+ esProc , err := CreateElasticProcessor (esClient )
159+ require .Nil (t , err )
160+
161+ body := & dataBlock.Body {}
162+ header := & dataBlock.Header {
163+ Round : 50 ,
164+ TimeStamp : 5040 ,
165+ ShardID : core .MetachainShardId ,
166+ }
167+
168+ tokenIdentifier := "NON-v2"
169+
170+ address1 := "erd1ju8pkvg57cwdmjsjx58jlmnuf4l9yspstrhr9tgsrt98n9edpm2qtlgy99"
171+ pool := & outport.TransactionPool {
172+ Logs : []* outport.LogData {
173+ {
174+ TxHash : hex .EncodeToString ([]byte ("h1" )),
175+ Log : & transaction.Log {
176+ Address : decodeAddress (address1 ),
177+ Events : []* transaction.Event {
178+ {
179+ Address : decodeAddress (address1 ),
180+ Identifier : []byte ("issueNonFungible" ),
181+ Topics : [][]byte {[]byte (tokenIdentifier ), []byte ("NON-token" ), []byte ("NON" ), []byte (core .NonFungibleESDTv2 )},
182+ },
183+ nil ,
184+ },
185+ },
186+ },
187+ },
188+ }
189+
190+ err = esProc .SaveTransactions (createOutportBlockWithHeader (body , header , pool , nil , testNumOfShards ))
191+ require .Nil (t , err )
192+
193+ // ################ CREATE NON FUNGIBLE TOKEN ##########################
194+ esProc , err = CreateElasticProcessor (esClient )
195+ require .Nil (t , err )
196+
197+ header = & dataBlock.Header {
198+ Round : 51 ,
199+ TimeStamp : 5600 ,
200+ ShardID : 0 ,
201+ }
202+
203+ esdtData := & esdt.ESDigitalToken {
204+ TokenMetaData : & esdt.MetaData {
205+ Creator : decodeAddress (address1 ),
206+ },
207+ }
208+ esdtDataBytes , _ := json .Marshal (esdtData )
209+
210+ pool = & outport.TransactionPool {
211+ Logs : []* outport.LogData {
212+ {
213+ TxHash : hex .EncodeToString ([]byte ("h1" )),
214+ Log : & transaction.Log {
215+ Address : decodeAddress (address1 ),
216+ Events : []* transaction.Event {
217+ {
218+ Address : decodeAddress (address1 ),
219+ Identifier : []byte (core .BuiltInFunctionESDTNFTCreate ),
220+ Topics : [][]byte {[]byte (tokenIdentifier ), big .NewInt (2 ).Bytes (), big .NewInt (1 ).Bytes (), esdtDataBytes },
221+ },
222+ nil ,
223+ },
224+ },
225+ },
226+ },
227+ }
228+
229+ err = esProc .SaveTransactions (createOutportBlockWithHeader (body , header , pool , nil , testNumOfShards ))
230+ require .Nil (t , err )
231+
232+ ids := []string {tokenIdentifier + "-02" }
233+ genericResponse := & GenericResponse {}
234+ err = esClient .DoMultiGet (context .Background (), ids , indexerdata .TokensIndex , true , genericResponse )
235+ require .Nil (t , err )
236+ require .JSONEq (t , readExpectedResult ("./testdata/nftIssueCreateBurn/non-fungible-v2-after-create.json" ), string (genericResponse .Docs [0 ].Source ))
237+
238+ // ################ BURN NON FUNGIBLE TOKEN ##########################
239+
240+ header = & dataBlock.Header {
241+ Round : 52 ,
242+ TimeStamp : 5666 ,
243+ ShardID : 0 ,
244+ }
245+
246+ pool = & outport.TransactionPool {
247+ Logs : []* outport.LogData {
248+ {
249+ TxHash : hex .EncodeToString ([]byte ("h1" )),
250+ Log : & transaction.Log {
251+ Address : decodeAddress (address1 ),
252+ Events : []* transaction.Event {
253+ {
254+ Address : decodeAddress (address1 ),
255+ Identifier : []byte (core .BuiltInFunctionESDTNFTBurn ),
256+ Topics : [][]byte {[]byte (tokenIdentifier ), big .NewInt (2 ).Bytes (), big .NewInt (1 ).Bytes (), decodeAddress (address1 )},
257+ },
258+ nil ,
259+ },
260+ },
261+ },
262+ },
263+ }
264+
265+ err = esProc .SaveTransactions (createOutportBlockWithHeader (body , header , pool , nil , testNumOfShards ))
266+ require .Nil (t , err )
267+
268+ genericResponse = & GenericResponse {}
269+ err = esClient .DoMultiGet (context .Background (), ids , indexerdata .TokensIndex , true , genericResponse )
270+ require .Nil (t , err )
271+ require .False (t , genericResponse .Docs [0 ].Found )
272+ }
0 commit comments