Skip to content

Commit 831105c

Browse files
author
Yash Agrawal
committed
feat: add test case for mint
1 parent 2638171 commit 831105c

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

test/SBT.test.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,5 +146,38 @@ describe('SBT', () => {
146146
expect(await sbt.currentIndex()).to.eq(0)
147147
expect(await sbt.balanceOf(signers.userA.address)).to.eq(0)
148148
})
149+
150+
it('The mint function can be executed by all minters', async () => {
151+
const sbt = await init()
152+
const signers = await getSigners()
153+
154+
const metadata = await getDummyEncodedMetadata(sbt)
155+
// Execute by Minter A.
156+
await expect(
157+
sbt.connect(signers.minterA).mint(signers.userA.address, metadata)
158+
)
159+
.to.emit(sbt, 'Minted')
160+
.withArgs(0, signers.userA.address)
161+
// Execute by Minter B.
162+
await expect(
163+
sbt.connect(signers.minterB).mint(signers.userA.address, metadata)
164+
)
165+
.to.emit(sbt, 'Minted')
166+
.withArgs(1, signers.userA.address)
167+
168+
const tokensOfUserA = await sbt.tokensOfOwner(signers.userA.address)
169+
expect(tokensOfUserA.length).to.eq(2)
170+
expect(tokensOfUserA[0]).to.eq(0)
171+
expect(tokensOfUserA[1]).to.eq(1)
172+
expect(await sbt.totalSupply()).to.eq(2)
173+
expect(await sbt.currentIndex()).to.eq(2)
174+
expect(await sbt.ownerOf(0)).to.eq(signers.userA.address)
175+
expect(await sbt.ownerOf(1)).to.eq(signers.userA.address)
176+
expect(await sbt.balanceOf(signers.userA.address)).to.eq(2)
177+
expect(await sbt.tokenOfOwnerByIndex(signers.userA.address, 0)).to.eq(0)
178+
expect(await sbt.tokenOfOwnerByIndex(signers.userA.address, 1)).to.eq(1)
179+
expect(await sbt.tokenByIndex(0)).to.eq(0)
180+
expect(await sbt.tokenByIndex(1)).to.eq(1)
181+
})
149182
})
150183
})

0 commit comments

Comments
 (0)