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

Commit

Permalink
Major update of PoS unit tests (#9193)
Browse files Browse the repository at this point in the history
* Improve Stake command unit tests

* Fix test case when downstake allows more upstake capacity

* Fix stake test not initializing Staker Store data

* Fix and rename `RegisterValidatorCommand` tests and add `isUsername()` tests

* Fix punished accounts unlock scenario

* Fix format issue
  • Loading branch information
bobanm authored Jan 8, 2024
1 parent 7fde5ff commit 2062593
Show file tree
Hide file tree
Showing 6 changed files with 442 additions and 355 deletions.
2 changes: 1 addition & 1 deletion framework/src/modules/pos/commands/stake.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export class StakeCommand extends BaseCommand {
return {
status: VerifyStatus.FAIL,
error: new ValidationError(
'Amount should be multiple of 10 * 10^8.',
`Amount should be multiple of ${this._baseStakeAmount}.`,
stake.amount.toString(),
),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { PrefixedStateReadWriter } from '../../../../../src/state_machine/prefix
import { createFakeBlockHeader, InMemoryPrefixedStateDB } from '../../../../../src/testing';
import { createStoreGetter } from '../../../../../src/testing/utils';

describe('Change Commission command', () => {
describe('Claim Rewards command', () => {
const pos = new PoSModule();
const publicKey = utils.getRandomBytes(32);
const senderAddress = address.getAddressFromPublicKey(publicKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
VALIDATOR_REGISTRATION_FEE,
} from '../../../../../src/modules/pos/constants';
import { ValidatorRegisteredEvent } from '../../../../../src/modules/pos/events/validator_registered';
import { liskToBeddows } from '../../../../utils/assets';

describe('Validator registration command', () => {
const pos = new Modules.PoS.PoSModule();
Expand All @@ -53,7 +54,6 @@ describe('Validator registration command', () => {
generatorKey: utils.getRandomBytes(32),
blsKey: utils.getRandomBytes(48),
proofOfPossession: utils.getRandomBytes(96),
validatorRegistrationFee: VALIDATOR_REGISTRATION_FEE,
};
const defaultValidatorInfo = {
name: transactionParams.name,
Expand All @@ -77,7 +77,7 @@ describe('Validator registration command', () => {
command: 'registerValidator',
senderPublicKey: publicKey,
nonce: BigInt(0),
fee: BigInt(1000000000),
fee: liskToBeddows(20),
params: encodedTransactionParams,
signatures: [publicKey],
});
Expand Down Expand Up @@ -206,7 +206,7 @@ describe('Validator registration command', () => {
command: 'registerValidator',
senderPublicKey: publicKey,
nonce: BigInt(0),
fee: BigInt(100000000),
fee: liskToBeddows(1),
params: invalidParams,
signatures: [publicKey],
});
Expand Down
Loading

0 comments on commit 2062593

Please sign in to comment.