Skip to content

Commit

Permalink
fix(ref-imp): updated default protocol parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
thehenrytsai committed Dec 14, 2020
1 parent 0baa6b3 commit a65d2ee
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
1 change: 0 additions & 1 deletion lib/core/versions/latest/FeeManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export default class FeeManager {
*
* @param normalizedFee The normalized fee for the current transaction.
* @param numberOfOperations The number of operations to write.
* @param feeMarkupFactor Markup to be added to the calculated fee.
*
* @throws if the number of operations are <= 0.
*/
Expand Down
6 changes: 3 additions & 3 deletions lib/core/versions/latest/protocol-parameters.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
"maxCasUriLength": 100,
"maxCoreIndexFileSizeInBytes": 1000000,
"maxProvisionalIndexFileSizeInBytes": 1000000,
"maxProofFileSizeInBytes": 2000000,
"maxProofFileSizeInBytes": 2500000,
"maxChunkFileSizeInBytes": 10000000,
"maxNumberOfOperationsPerTransactionTime": 600000,
"maxNumberOfTransactionsPerTransactionTime": 300,
"maxOperationsPerBatch": 10000,
"maxDeltaSizeInBytes": 1000,
"maxNumberOfOperationsForNoValueTimeLock": 100,
"maxWriterLockIdInBytes": 200,
"normalizedFeeToPerOperationFeeMultiplier": 0.01,
"valueTimeLockAmountMultiplier": 600
"normalizedFeeToPerOperationFeeMultiplier": 0.001,
"valueTimeLockAmountMultiplier": 60000
}
20 changes: 15 additions & 5 deletions tests/core/FeeManager.spec.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
import ErrorCode from '../../lib/core/versions/latest/ErrorCode';
import FeeManager from '../../lib/core/versions/latest/FeeManager';
import JasmineSidetreeErrorValidator from '../JasmineSidetreeErrorValidator';
import ProtocolParameters from '../../lib/core/versions/latest/ProtocolParameters';

describe('FeeManager', async () => {

beforeAll(() => {
ProtocolParameters.maxNumberOfOperationsForNoValueTimeLock = 100;
ProtocolParameters.normalizedFeeToPerOperationFeeMultiplier = 0.001;
});

describe('computeMinimumTransactionFee', async () => {

it('should return calculated fee if it is greater', async () => {
const fee = FeeManager.computeMinimumTransactionFee(2, 10000);
it('should calculate fee correctly.', async () => {
const normalizedFee = 1000;
const numberOfOperations = 1000;
const fee = FeeManager.computeMinimumTransactionFee(normalizedFee, numberOfOperations);

expect(fee).toEqual(200);
expect(fee).toEqual(1000);
});

it('should return at least the normalized fee if the calculated fee is lower', async () => {
Expand Down Expand Up @@ -50,11 +58,13 @@ describe('FeeManager', async () => {
});

it('should throw if the fee paid is less than the expected fee', async () => {
const feeToPay = FeeManager.computeMinimumTransactionFee(100, 100);
const feePaid = 2000; // Make fee paid very small.
const numberOfOperations = 10000;
const normalizedFee = 1000;

// Make the next call w/ a large number of operations to simulate the error condition.
JasmineSidetreeErrorValidator.expectSidetreeErrorToBeThrown(
() => FeeManager.verifyTransactionFeeAndThrowOnError(feeToPay, 1000, 100),
() => FeeManager.verifyTransactionFeeAndThrowOnError(feePaid, numberOfOperations, normalizedFee),
ErrorCode.TransactionFeePaidInvalid);
});

Expand Down

0 comments on commit a65d2ee

Please sign in to comment.