Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
);
// Mock an instance of Value token contract.
mockValueTokenContract = sinon.mock(
Contracts.getEIP20Token(web3, valueTokenAddress),
);
const valueTokenContract = mockValueTokenContract.object;
spyContract = sinon.replace(
Contracts,
'getEIP20Token',
sinon.fake.returns(valueTokenContract),
);
// Fake the allowance call.
spyGetAllowance = sinon.replace(
valueTokenContract.methods,
'allowance',
sinon.fake.returns(() => {
return Promise.resolve(approvedAmount);
}),
);
// Add spy on stakeHelper.isBountyAmountApproved.
spyIsStakeAmountApproved = sinon.spy(stakeHelper, 'isStakeAmountApproved');
};
it('should create the correct abi encoded data', async () => {
const sessionKey = '0x0000000000000000000000000000000000000003';
const mockSessionKeyData = 'mockSessionKeyData';
const sessionKeyDataSpy = sinon.replace(
tokenHolder.contract.methods,
'sessionKeys',
sinon.fake.returns({
call: () => Promise.resolve(mockSessionKeyData)
})
);
const response = await tokenHolder.getSessionKeyData(sessionKey);
assert.strictEqual(response, mockSessionKeyData);
Spy.assert(sessionKeyDataSpy, 1, [[sessionKey]]);
});
const setup = () => {
spyCall = sinon.spy(anchor, 'getLatestInfo');
spyGetLatestStateRootBlockHeight = sinon.replace(
anchor,
'getLatestStateRootBlockHeight',
sinon.fake.resolves(getLatestStateRootBlockHeightResult),
);
spyGetStateRootResult = sinon.replace(
anchor,
'getStateRoot',
sinon.fake.returns(getStateRootResult),
);
};
const setup = () => {
spyRawTx = sinon.replace(
gateway,
'progressUnstakeRawTx',
sinon.fake.resolves(mockedTx),
);
spyCall = sinon.spy(gateway, 'progressUnstake');
spySendTransaction = sinon.replace(
Utils,
'sendTransaction',
sinon.fake.resolves(true),
);
};
const setup = () => {
spyCall = sinon.spy(facilitator, 'performProgressStake');
spyGetOutboxMessageStatus = sinon.replace(
facilitator.gateway,
'getOutboxMessageStatus',
sinon.fake.resolves(getOutboxMessageStatusResult),
);
spyProgressStake = sinon.replace(
facilitator.gateway,
'progressStake',
sinon.fake.resolves(progressStakeResult),
);
};
const setup = () => {
spyMethod = sinon.replace(
coGateway.contract.methods,
'getOutboxMessageStatus',
sinon.fake.returns(() => {
return Promise.resolve(mockedMessageStatus);
}),
);
spyCall = sinon.spy(coGateway, 'getOutboxMessageStatus');
};
const setup = () => {
spyConfirmStakeIntent = sinon.replace(
facilitator,
'confirmStakeIntent',
sinon.fake.resolves(confirmStakeIntentResult),
);
spyProgressStakeMessage = sinon.replace(
facilitator,
'progressStakeMessage',
sinon.fake.resolves(progressStakeMessageResult),
);
spyGetMesageHash = sinon.replace(
Message,
'getStakeMessageHash',
sinon.fake.returns(getMessageHashResult),
);
spyCall = sinon.spy(facilitator, 'progressStake');
};
const setup = () => {
spyRawTx = sinon.replace(
coGateway,
'_confirmStakeIntentRawTx',
sinon.fake.resolves(mockedTx),
);
spyCall = sinon.spy(coGateway, 'confirmStakeIntent');
spySendTransaction = sinon.replace(
Utils,
'sendTransaction',
sinon.fake.resolves(true),
);
};
spyGetOutboxMessageStatus = sinon.replace(
facilitator.coGateway,
'getOutboxMessageStatus',
sinon.fake.resolves(getOutboxMessageStatusResult),
);
spyGetInboxMessageStatus = sinon.replace(
facilitator.gateway,
'getInboxMessageStatus',
sinon.fake.resolves(getInboxMessageStatusResult),
);
spyGetCoGatewayProof = sinon.replace(
facilitator,
'getCoGatewayProof',
sinon.fake.resolves(getCoGatewayProofResult),
);
spyProveGateway = sinon.replace(
facilitator.gateway,
'proveGateway',
sinon.fake.resolves(proveGatewayResult),
);
spyConfirmRedeemIntent = sinon.replace(
facilitator.gateway,
'confirmRedeemIntent',
sinon.fake.resolves(confirmRedeemIntentResult),
);
spyCall = sinon.spy(facilitator, 'confirmRedeemIntent');
};
const setup = () => {
spyMethod = sinon.replace(
gateway.contract.methods,
'progressUnstake',
sinon.fake.resolves(mockedTx),
);
spyCall = sinon.spy(gateway, 'progressUnstakeRawTx');
};