Skip to content

Commit

Permalink
partially ready
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex6323 committed Dec 1, 2023
1 parent b4ebc82 commit 5a0ad4e
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions bindings/nodejs/tests/types/protocol_parameters.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,35 @@

import { plainToInstance, Type } from 'class-transformer';
import { describe, it } from '@jest/globals';
import { expect } from '@jest/globals';
import * as protocol_parameters from '../../../../sdk/tests/types/fixtures/protocol_parameters.json';
import { ProtocolParameters } from '../../lib/types/models/info/node-info-protocol';
import { ProtocolParameters, WorkScoreParameters, ManaParameters } from '../../lib/types/models/info/node-info-protocol';
import { StorageScoreParameters } from '../../lib/types/models';

describe('ProtocolParameters tests', () => {

it('creates ProtocolParameters from a fixture', async () => {

// TODO: is there a way around `as unknown`? The string->bigint parameters are the issue.
const params = protocol_parameters.params as unknown as ProtocolParameters;

expect(params.type).toBe(0);
expect(params.version).toBe(3);
expect(params.networkName).toBe("TestJungle");
expect(params.bech32Hrp).toBe("tgl");
// Check whether parameters were correctly set
expect(params.type).toEqual(0);
expect(params.version).toEqual(3);
expect(params.networkName).toEqual("TestJungle");
expect(params.bech32Hrp).toEqual("tgl");

// TODO: is there a way around `as unknown`? The string->bigint parameters are the issue.
const storageScoreParams = protocol_parameters.params.storageScoreParameters as unknown as StorageScoreParameters;

expect(storageScoreParams.storageCost).toEqual("0");
expect(storageScoreParams.factorData).toEqual(0);
expect(storageScoreParams.offsetOutputOverhead).toEqual("0");
expect(storageScoreParams.offsetEd25519BlockIssuerKey).toEqual("0");
expect(storageScoreParams.offsetStakingFeature).toEqual("0");
expect(storageScoreParams.offsetDelegation).toEqual("0");

const workScoreParameters = protocol_parameters.params.workScoreParameters as WorkScoreParameters;
const manaParameters = protocol_parameters.params.manaParameters as ManaParameters;
});
});

0 comments on commit 5a0ad4e

Please sign in to comment.