Skip to content

Commit

Permalink
fix(dapi): fix fetchProofForStateTransitionFactory.js unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
pshenmic committed Feb 13, 2025
1 parent f719e7d commit 7b40975
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function fetchProofForStateTransitionFactory(driveClient, dpp) {

const requestV0 = new GetProofsRequestV0();

let dataContractsCache = {};
const dataContractsCache = {};

if (stateTransition.isDocumentStateTransition()) {
const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ const {
} = require('@dashevo/dapi-grpc');

const generateRandomIdentifierAsync = require('@dashevo/wasm-dpp/lib/test/utils/generateRandomIdentifierAsync');
const { StateTransitionTypes } = require('@dashevo/wasm-dpp');
const {
StateTransitionTypes,
DocumentTransition,
} = require('@dashevo/wasm-dpp');

const fetchProofForStateTransitionFactory = require('../../../../lib/externalApis/drive/fetchProofForStateTransitionFactory');

Expand Down Expand Up @@ -81,14 +84,15 @@ describe('fetchProofForStateTransition', () => {

it('should fetch documents proofs', async function it() {
stateTransitionFixture.isDocumentStateTransition.returns(true);
stateTransitionFixture.getTransitions = this.sinon.stub().returns([
{
getDataContractId: this.sinon.stub().returns(await generateRandomIdentifierAsync()),
getType: this.sinon.stub().returns('niceDocument'),
getId: this.sinon.stub().returns(await generateRandomIdentifierAsync()),
hasPrefundedBalance: this.sinon.stub().returns(true),
},
]);
const mockDocumentTransition = Object.create(DocumentTransition.prototype);

mockDocumentTransition.getDataContractId = this.sinon.stub()
.returns(await generateRandomIdentifierAsync());
mockDocumentTransition.getType = this.sinon.stub().returns('niceDocument');
mockDocumentTransition.getId = this.sinon.stub().returns(await generateRandomIdentifierAsync());
mockDocumentTransition.hasPrefundedBalance = this.sinon.stub().returns(true);

stateTransitionFixture.getTransitions = this.sinon.stub().returns([mockDocumentTransition]);

const result = await fetchProofForStateTransition(stateTransitionFixture);
expect(result.serializeBinary()).to.deep
Expand Down

0 comments on commit 7b40975

Please sign in to comment.