Skip to content

Commit

Permalink
fix: add mock to unit test on estimateFee and createAccount (#166)
Browse files Browse the repository at this point in the history
  • Loading branch information
stanleyyconsensys authored Nov 7, 2023
1 parent 41fea1b commit d500465
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/starknet-snap/test/src/createAccount.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ describe('Test function: createAccount', function () {
sandbox.stub(utils, 'deployAccount').callsFake(async () => {
return createAccountFailedProxyResp;
});
sandbox.stub(utils, 'callContract').resolves(getBalanceResp);
sandbox.stub(utils, 'getSigner').throws(new Error());
sandbox.stub(utils, 'estimateAccountDeployFee').callsFake(async () => {
return estimateDeployFeeResp;
Expand All @@ -298,6 +299,7 @@ describe('Test function: createAccount', function () {
sandbox.stub(utils, 'deployAccount').callsFake(async () => {
return createAccountProxyResp;
});
sandbox.stub(utils, 'callContract').resolves(getBalanceResp);
sandbox.stub(utils, 'getSigner').throws(new Error());
sandbox.stub(utils, 'estimateAccountDeployFee').callsFake(async () => {
return estimateDeployFeeResp;
Expand Down
4 changes: 3 additions & 1 deletion packages/starknet-snap/test/src/estimateFee.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
estimateFeeResp,
estimateFeeResp2,
getBip44EntropyStub,
getBalanceResp,
} from '../constants.test';
import { Mutex } from 'async-mutex';
import { ApiParams, EstimateFeeRequestParams } from '../../src/types/snapApi';
Expand Down Expand Up @@ -45,6 +46,7 @@ describe('Test function: estimateFee', function () {
beforeEach(async function () {
walletStub.rpcStubs.snap_getBip44Entropy.callsFake(getBip44EntropyStub);
apiParams.keyDeriver = await getAddressKeyDeriver(walletStub);
sandbox.stub(utils, 'callContract').resolves(getBalanceResp);
});

afterEach(function () {
Expand Down Expand Up @@ -98,7 +100,7 @@ describe('Test function: estimateFee', function () {
sandbox.stub(utils, 'getSigner').callsFake(async () => {
return account2.publicKey;
});
sandbox.stub(utils, 'estimateFeeBulk').throws(new Error());
sandbox.stub(utils, 'estimateFee').throws(new Error());
apiParams.requestParams = requestObject;

let result;
Expand Down

0 comments on commit d500465

Please sign in to comment.