1
- const { expect } = require ( 'chai' ) ;
1
+ const { expect, assert } = require ( 'chai' ) ;
2
2
const { ethers } = require ( "hardhat" ) ;
3
3
const { json } = require ( 'hardhat/internal/core/params/argumentTypes' ) ;
4
+ const { getEventFromTx } = require ( "../../helpers/utils" )
5
+
6
+
4
7
5
8
let metadata = { "uptime" :100 , "image" :"ipfs://123" }
6
9
let signers
@@ -11,7 +14,11 @@ describe('AccessLists tests', function () {
11
14
this . accessListContract = await ethers . getContractFactory ( 'AccessList' ) ;
12
15
this . accessListContract = await this . accessListContract . deploy ( "AccessList" , "A" ) ;
13
16
await this . accessListContract . deployed ( ) ;
14
-
17
+ const txReceipt = await this . accessListContract . deployTransaction . wait ( ) ;
18
+ let event = getEventFromTx ( txReceipt , 'NewAccessList' )
19
+ assert ( event , "Cannot find NewAccessList event" )
20
+ const contractAddress = event . args [ 0 ] ;
21
+ assert ( contractAddress == this . accessListContract . address , "Access list contract address missmatch" )
15
22
// Get the contractOwner and collector address
16
23
signers = await ethers . getSigners ( ) ;
17
24
@@ -30,7 +37,12 @@ describe('AccessLists tests', function () {
30
37
31
38
32
39
it ( 'Mints one token, using mint' , async function ( ) {
33
- await this . accessListContract . mint ( signers [ 0 ] . address , JSON . stringify ( metadata ) ) ;
40
+ const tx = await this . accessListContract . mint ( signers [ 0 ] . address , JSON . stringify ( metadata ) ) ;
41
+ const txReceipt = await tx . wait ( ) ;
42
+ let event = getEventFromTx ( txReceipt , 'AddressAdded' )
43
+ assert ( event , "Cannot find AddressAdded event" )
44
+ const walletAddress = event . args [ 0 ] ;
45
+ assert ( walletAddress == signers [ 0 ] . address , "AddressAdded event: wallet address missmatch" )
34
46
this . tokenID ++ ;
35
47
expect ( await this . accessListContract . balanceOf ( signers [ 0 ] . address ) ) . to . equal ( 1 ) ;
36
48
expect ( await this . accessListContract . ownerOf ( this . tokenID ) ) . to . equal ( signers [ 0 ] . address ) ;
@@ -93,9 +105,15 @@ describe('AccessLists tests', function () {
93
105
} ) ;
94
106
95
107
it ( 'Owner should be able to burn' , async function ( ) {
108
+ const thisTokenId = 6
96
109
const howMany = await this . accessListContract . balanceOf ( signers [ 1 ] . address )
97
- expect ( await this . accessListContract . ownerOf ( 6 ) ) . to . equal ( signers [ 1 ] . address ) ;
98
- await this . accessListContract . burn ( 6 ) ;
110
+ expect ( await this . accessListContract . ownerOf ( thisTokenId ) ) . to . equal ( signers [ 1 ] . address ) ;
111
+ const tx = await this . accessListContract . burn ( thisTokenId ) ;
112
+ const txReceipt = await tx . wait ( ) ;
113
+ let event = getEventFromTx ( txReceipt , 'AddressRemoved' )
114
+ assert ( event , "Cannot find AddressRemoved event" )
115
+ const walletAddress = event . args [ 0 ] ;
116
+ assert ( event . args [ 0 ] == thisTokenId , "AddressRemoved event: tokenId missmatch" )
99
117
expect ( await this . accessListContract . balanceOf ( signers [ 1 ] . address ) ) . to . equal ( howMany - 1 ) ;
100
118
101
119
0 commit comments