Skip to content

Commit

Permalink
feat: update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvkelawala committed Sep 5, 2022
1 parent 8e935eb commit 1af16f4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
7 changes: 2 additions & 5 deletions __tests__/account.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,8 @@ describe('deploy and test Wallet', () => {
});

test('execute with custom nonce', async () => {
const { result } = await account.callContract({
contractAddress: account.address,
entrypoint: 'get_nonce',
});
const nonce = toBN(result[0]).toNumber();
const result = await account.getNonce();
const nonce = toBN(result).toNumber();
const { transaction_hash } = await account.execute(
{
contractAddress: erc20Address,
Expand Down
1 change: 0 additions & 1 deletion __tests__/contract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ describe('class Contract {}', () => {
expect(res).toHaveProperty('contractAddress');
expect(res).toHaveProperty('entrypoint');
expect(res).toHaveProperty('calldata');
expect(res).toHaveProperty('signature');
});

test('estimate gas fee for `mint` should fail when connected to the provider', async () => {
Expand Down
15 changes: 7 additions & 8 deletions __tests__/utils/ellipticalCurve.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import { StarknetChainId } from '../../src/constants';
import { ec, getKeyPair, getStarkKey, sign, verify } from '../../src/utils/ellipticCurve';
import { removeHexPrefix } from '../../src/utils/encode';
import {
calculcateTransactionHash,
calculateTransactionHash,
computeHashOnElements,
getSelectorFromName,
pedersen,
transactionVersion,
} from '../../src/utils/hash';
Expand Down Expand Up @@ -57,25 +56,25 @@ test('hashMessage()', () => {
const maxFee = '0';
const calldata = fromCallsToExecuteCalldataWithNonce(transactions, nonce);

const hashMsg = calculcateTransactionHash(
const hashMsg = calculateTransactionHash(
account,
transactionVersion,
getSelectorFromName('__execute__'),
calldata,
maxFee,
StarknetChainId.TESTNET
StarknetChainId.TESTNET,
nonce
);

expect(hashMsg).toMatchInlineSnapshot(
`"0x4c337c6bf32b2cf2b8ae54064e4b982c214660e8d0423b431a3fde10b9b9c02"`
`"0x6d1706bd3d1ba7c517be2a2a335996f63d4738e2f182144d078a1dd9997062e"`
);
const keyPair = getKeyPair(privateKey);
const [r, s] = sign(keyPair, removeHexPrefix(hashMsg));
expect(r.toString()).toMatchInlineSnapshot(
`"1944132633844378384908742523072599391732300777648030785844673145513474741467"`
`"1427981024487605678086498726488552139932400435436186597196374630267616399345"`
);
expect(s.toString()).toMatchInlineSnapshot(
`"1067771353159635307522498807851959257107695451405842425488451092336556917559"`
`"1853664302719670721837677288395394946745467311923401353018029119631574115563"`
);
});

Expand Down

0 comments on commit 1af16f4

Please sign in to comment.