Skip to content
This repository was archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
Add missing unit tests for the pos methods (#8421)
Browse files Browse the repository at this point in the history
✅ Add unit tests

Add missing `getStaker ` and `getValidator` unit tests.

Refactor the invalid address in the unit test
  • Loading branch information
mosmartin authored May 5, 2023
1 parent 950f6ad commit 50c3a4b
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions framework/test/unit/modules/pos/method.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ describe('PoSMethod', () => {
let validatorSubStore: ValidatorStore;
let nameSubStore: NameStore;
const address = utils.getRandomBytes(20);
const invalidAddress = Buffer.alloc(0);
const stakerData = {
stakes: [
{
Expand Down Expand Up @@ -139,6 +140,14 @@ describe('PoSMethod', () => {
expect(stakerDataReturned).toStrictEqual(stakerData);
});
});

describe('when input address is invalid', () => {
it('should throw error', async () => {
await expect(posMethod.getStaker(methodContext, invalidAddress)).rejects.toThrow(
invalidAddress.toString('hex'),
);
});
});
});

describe('getValidator', () => {
Expand All @@ -150,6 +159,14 @@ describe('PoSMethod', () => {
expect(validatorDataReturned).toStrictEqual(validatorData);
});
});

describe('when input address is invalid', () => {
it('should throw error', async () => {
await expect(posMethod.getValidator(methodContext, invalidAddress)).rejects.toThrow(
invalidAddress.toString('hex'),
);
});
});
});

describe('updateSharedRewards', () => {
Expand Down

0 comments on commit 50c3a4b

Please sign in to comment.