Skip to content

Commit

Permalink
Merge branch 'dev' into 'master'
Browse files Browse the repository at this point in the history
Dev

See merge request ergo/rosen-bridge/watcher!316
  • Loading branch information
zargarzadehm committed Oct 22, 2024
2 parents 0140d8f + 5cda77a commit e0e8dde
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 4 deletions.
File renamed without changes.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @rosen-bridge/watcher

## 4.0.2

### Patch Changes

- Fix redeem job to redeem the invalid commitment after the reward transaction

## 4.0.1

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rosen-bridge/watcher",
"version": "4.0.1",
"version": "4.0.2",
"description": "Rosen bridge Watcher service",
"main": "index.js",
"type": "module",
Expand Down
3 changes: 2 additions & 1 deletion src/utils/watcherUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ class WatcherUtils {
* 1 - Not triggered after the specified period
* 2 - Created after the related trigger
* 3 - It's a duplicate commitment and a valid one merged to create the trigger (WID exists in trigger)
* 4 - It's information is not valid and trigger was spent without rewarding the commitment
* @param commitment
* @returns true if the commitment is still valid and false otherwise
*/
Expand All @@ -405,7 +406,7 @@ class WatcherUtils {
commitment.eventId
);

if (eventTrigger == null) {
if (eventTrigger == null || eventTrigger.spendBlock !== undefined) {
return false;
}

Expand Down
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 e0e8dde

Please sign in to comment.