Skip to content

Commit

Permalink
Add unit test for the forth isCommitmentValid case
Browse files Browse the repository at this point in the history
  • Loading branch information
fatemeh-ra committed Oct 22, 2024
1 parent 6d07ae9 commit f12d4de
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/ergoUtils/watcherUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { TxStatus } from '../../src/database/entities/observationStatusEntity';
import {
commitmentEntity,
eventTriggerEntity,
newEventTriggerEntity,
observationEntity1,
observationEntity3,
observationStatusCommitted,
Expand Down Expand Up @@ -572,4 +573,23 @@ describe('Testing the WatcherUtils & TransactionUtils', () => {
chai.spy.restore(ErgoNetwork);
});
});

describe('isCommitmentValid', () => {
/**
* @target isCommitmentValid should return false if related trigger is spent
* @dependencies
* - DataBase
* @scenario
* - mock eventTriggerByEventId to return a spent trigger object
* @expected
* - to return false when spendBlock is set for the trigger
*/
it('should return false if related trigger is spent', async () => {
chai.spy.on(dataBase, 'eventTriggerByEventId', () => ({
spendBlock: 'spendBlock',
}));
const result = await watcherUtils.isCommitmentValid(commitmentEntity);
expect(result).to.be.false;
});
});
});

0 comments on commit f12d4de

Please sign in to comment.