Skip to content

Commit 2591813

Browse files
committed
添加单元测试
1 parent 1fbe632 commit 2591813

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

w2_2_code/test/Score.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,19 @@ describe('Score', function () {
2121
teacher = await Teacher.deploy(score.address)
2222

2323
// 设置wallet1为teacher
24-
await score.setTeacher(wallet.address)
24+
await score.setTeacher(teacher.address)
2525
})
2626

2727
it('only teacher can modify score', async function () {
28-
await expect(score.connect(wallet2).setScore(wallet3.address, 99)).to.be.revertedWith('Score: NOT_TEACHER')
28+
await expect(score.setScore(wallet3.address, 99)).to.be.revertedWith('Score: NOT_TEACHER')
2929
})
3030

3131
it('score must be below 100', async function () {
32-
await expect(score.setScore(wallet3.address, 101)).to.be.revertedWith('Score: INVALID_SCORE')
32+
await expect(teacher.setScore(wallet3.address, 101)).to.be.revertedWith('Score: INVALID_SCORE')
3333
})
3434

3535
it('score must be set correct', async function () {
36-
await score.setScore(wallet3.address, 98)
36+
await teacher.setScore(wallet3.address, 98)
3737
expect(await score.studentScore(wallet3.address)).to.be.equal(98)
3838
})
3939
})

0 commit comments

Comments
 (0)