Skip to content

Commit

Permalink
fix: lint issue
Browse files Browse the repository at this point in the history
  • Loading branch information
stanleyyconsensys committed Apr 11, 2024
1 parent 213b2e2 commit 63e405a
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { WalletMock } from '../wallet.mock.test';
import { SnapState } from '../../src/types/snapState';
import { verifySignedMessage } from '../../src/verifySignedMessage';
import { STARKNET_SEPOLIA_TESTNET_NETWORK } from '../../src/utils/constants';
import { account1, getBip44EntropyStub, signature1, signature2, unfoundUserAddress } from '../constants.test';
import { account1, getBip44EntropyStub, signature1 } from '../constants.test';
import { getAddressKeyDeriver } from '../../src/utils/keyPair';
import * as utils from '../../src/utils/starknetUtils';
import { Mutex } from 'async-mutex';
Expand Down
51 changes: 42 additions & 9 deletions packages/starknet-snap/test/utils/starknetUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ describe('Test function: getAccountInstance', function () {
});

it('should return account instance with default cairo version', async function () {
const result = await utils.getAccountInstance(STARKNET_SEPOLIA_TESTNET_NETWORK, account1.address, account1.publicKey);
const result = await utils.getAccountInstance(
STARKNET_SEPOLIA_TESTNET_NETWORK,
account1.address,
account1.publicKey,
);
expect(result).to.be.instanceOf(Account);
expect(result.cairoVersion).to.equal(CAIRO_VERSION);
});
Expand Down Expand Up @@ -75,15 +79,27 @@ describe('Test function: findAddressIndex', function () {
});

it('should find address index', async function () {
const result = await utils.findAddressIndex(STARKNET_SEPOLIA_TESTNET_NETWORK.chainId, account1.address, 'div', state, 1);
const result = await utils.findAddressIndex(
STARKNET_SEPOLIA_TESTNET_NETWORK.chainId,
account1.address,
'div',
state,
1,
);
expect(result).to.be.contains({
index: 0,
cairoVersion: 1,
});
});

it('should find address index address match account legacy', async function () {
const result = await utils.findAddressIndex(STARKNET_SEPOLIA_TESTNET_NETWORK.chainId, account2.address, 'div', state, 1);
const result = await utils.findAddressIndex(
STARKNET_SEPOLIA_TESTNET_NETWORK.chainId,
account2.address,
'div',
state,
1,
);
expect(result).to.be.contains({
index: 0,
cairoVersion: 0,
Expand All @@ -93,7 +109,13 @@ describe('Test function: findAddressIndex', function () {
it('should throw error if address not found', async function () {
let result = null;
try {
result = await utils.findAddressIndex(STARKNET_SEPOLIA_TESTNET_NETWORK.chainId, account3.address, 'div', state, 1);
result = await utils.findAddressIndex(
STARKNET_SEPOLIA_TESTNET_NETWORK.chainId,
account3.address,
'div',
state,
1,
);
} catch (err) {
result = err;
} finally {
Expand Down Expand Up @@ -259,7 +281,11 @@ describe('Test function: getVersion', function () {
it('should trigger callContract correct', async function () {
const result = await utils.getVersion(account1.address, STARKNET_SEPOLIA_TESTNET_NETWORK);
expect(result).to.be.eq(expected);
expect(callContractStub).to.have.been.calledOnceWith(STARKNET_SEPOLIA_TESTNET_NETWORK, account1.address, 'getVersion');
expect(callContractStub).to.have.been.calledOnceWith(
STARKNET_SEPOLIA_TESTNET_NETWORK,
account1.address,
'getVersion',
);
});
});

Expand All @@ -278,7 +304,11 @@ describe('Test function: getOwner', function () {
it('should trigger callContract correct', async function () {
const result = await utils.getOwner(account1.address, STARKNET_SEPOLIA_TESTNET_NETWORK);
expect(result).to.be.eq(expected);
expect(callContractStub).to.have.been.calledOnceWith(STARKNET_SEPOLIA_TESTNET_NETWORK, account1.address, 'get_owner');
expect(callContractStub).to.have.been.calledOnceWith(
STARKNET_SEPOLIA_TESTNET_NETWORK,
account1.address,
'get_owner',
);
});
});

Expand All @@ -297,9 +327,12 @@ describe('Test function: getBalance', function () {
it('should trigger callContract correct', async function () {
const result = await utils.getBalance(account1.address, account1.address, STARKNET_SEPOLIA_TESTNET_NETWORK);
expect(result).to.be.eq(expected);
expect(callContractStub).to.have.been.calledOnceWith(STARKNET_SEPOLIA_TESTNET_NETWORK, account1.address, 'balanceOf', [
num.toBigInt(account1.address).toString(10),
]);
expect(callContractStub).to.have.been.calledOnceWith(
STARKNET_SEPOLIA_TESTNET_NETWORK,
account1.address,
'balanceOf',
[num.toBigInt(account1.address).toString(10)],
);
});
});

Expand Down

0 comments on commit 63e405a

Please sign in to comment.