Skip to content

Commit 26393fe

Browse files
author
Yash Agrawal
committed
feat: add test case for mint
1 parent 3bf13e4 commit 26393fe

File tree

1 file changed

+51
-1
lines changed

1 file changed

+51
-1
lines changed

test/SBT.test.ts

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,9 @@ describe('SBT', () => {
184184
const sbt = await init()
185185
const signers = await getSigners()
186186

187-
await sbt.addMinter(signers.minterC.address)
187+
await sbt
188+
.connect(signers.minterUpdater)
189+
.addMinter(signers.minterC.address)
188190
const metadata = await getDummyEncodedMetadata(sbt)
189191
// Execute by Minter A.
190192
await expect(
@@ -223,5 +225,53 @@ describe('SBT', () => {
223225
expect(await sbt.tokenByIndex(1)).to.eq(1)
224226
expect(await sbt.tokenByIndex(2)).to.eq(2)
225227
})
228+
229+
it('The mint function should function correctly for multiple users', async () => {
230+
const sbt = await init()
231+
const signers = await getSigners()
232+
233+
const metadata = await getDummyEncodedMetadata(sbt)
234+
await expect(
235+
sbt.connect(signers.minterA).mint(signers.userA.address, metadata)
236+
)
237+
.to.emit(sbt, 'Minted')
238+
.withArgs(0, signers.userA.address)
239+
240+
let tokensOfUserA = await sbt.tokensOfOwner(signers.userA.address)
241+
expect(tokensOfUserA.length).to.eq(1)
242+
expect(tokensOfUserA[0]).to.eq(0)
243+
expect(await sbt.totalSupply()).to.eq(1)
244+
expect(await sbt.currentIndex()).to.eq(1)
245+
expect(await sbt.ownerOf(0)).to.eq(signers.userA.address)
246+
expect(await sbt.balanceOf(signers.userA.address)).to.eq(1)
247+
expect(await sbt.tokenOfOwnerByIndex(signers.userA.address, 0)).to.eq(0)
248+
expect(await sbt.tokenByIndex(0)).to.eq(0)
249+
250+
await expect(
251+
sbt.connect(signers.minterA).mint(signers.userB.address, metadata)
252+
)
253+
.to.emit(sbt, 'Minted')
254+
.withArgs(1, signers.userB.address)
255+
256+
// System checks
257+
expect(await sbt.totalSupply()).to.eq(2)
258+
expect(await sbt.currentIndex()).to.eq(2)
259+
// UserA checks
260+
tokensOfUserA = await sbt.tokensOfOwner(signers.userA.address)
261+
expect(tokensOfUserA.length).to.eq(1)
262+
expect(tokensOfUserA[0]).to.eq(0)
263+
expect(await sbt.ownerOf(0)).to.eq(signers.userA.address)
264+
expect(await sbt.balanceOf(signers.userA.address)).to.eq(1)
265+
expect(await sbt.tokenOfOwnerByIndex(signers.userA.address, 0)).to.eq(0)
266+
expect(await sbt.tokenByIndex(0)).to.eq(0)
267+
// UserB checks
268+
const tokensOfUserB = await sbt.tokensOfOwner(signers.userB.address)
269+
expect(tokensOfUserB.length).to.eq(1)
270+
expect(tokensOfUserB[0]).to.eq(1)
271+
expect(await sbt.ownerOf(1)).to.eq(signers.userB.address)
272+
expect(await sbt.balanceOf(signers.userB.address)).to.eq(1)
273+
expect(await sbt.tokenOfOwnerByIndex(signers.userB.address, 0)).to.eq(1)
274+
expect(await sbt.tokenByIndex(1)).to.eq(1)
275+
})
226276
})
227277
})

0 commit comments

Comments
 (0)