diff --git a/ethereum/test/Work1.js b/ethereum/test/Work1.js index 9afd934..7df8dfc 100644 --- a/ethereum/test/Work1.js +++ b/ethereum/test/Work1.js @@ -1,7 +1,6 @@ const { time, loadFixture, - // setPrevRandao, } = require('@nomicfoundation/hardhat-toolbox/network-helpers'); const { expect } = require('chai'); const { ethers } = require('hardhat'); @@ -98,7 +97,7 @@ describe('Work1', () => { const { dao, work1, account1, account2, } = await loadFixture(deploy); - await dao.stakeAvailability(work1.target, 50, STAKE_DURATION, { from: account1 }); + await dao.stakeAvailability(work1.target, 50, STAKE_DURATION); const requestWork = () => work1.connect(account2).requestWork({ value: WORK1_PRICE }); await expect(requestWork()).to.emit(work1, 'WorkAssigned').withArgs(account1, 0); expect(await work1.requestCount()).to.equal(1); @@ -114,11 +113,19 @@ describe('Work1', () => { await expect(requestWork()).to.be.revertedWith('No available worker stakes'); }); + it('should not be able to request work if fee is insufficient', async () => { + const { + work1, account2, + } = await loadFixture(deploy); + const requestWork = () => work1.connect(account2).requestWork({ value: WORK1_PRICE / 2 }); + await expect(requestWork()).to.be.revertedWith('Insufficient fee'); + }); + it('should not assign work to an expired availability stake', async () => { const { - dao, work1, account1, account2, + dao, work1, account2, } = await loadFixture(deploy); - await dao.stakeAvailability(work1.target, 50, STAKE_DURATION, { from: account1 }); + await dao.stakeAvailability(work1.target, 50, STAKE_DURATION); const requestWork = () => work1.connect(account2).requestWork({ value: WORK1_PRICE }); await time.increase(61); await expect(requestWork()).to.be.revertedWith('No available worker stakes'); @@ -128,7 +135,7 @@ describe('Work1', () => { const { dao, work1, account1, account2, } = await loadFixture(deploy); - await dao.stakeAvailability(work1.target, 50, STAKE_DURATION, { from: account1 }); + await dao.stakeAvailability(work1.target, 50, STAKE_DURATION); const requestWork = () => work1.connect(account2).requestWork({ value: WORK1_PRICE }); await expect(requestWork()).to.emit(work1, 'WorkAssigned').withArgs(account1, 0); await expect(requestWork()).to.be.revertedWith('No available worker stakes');