Skip to content

Commit

Permalink
Merge pull request #6 from argentlabs/fix/test-snapshots
Browse files Browse the repository at this point in the history
fix: test snapshots and add pr flow
  • Loading branch information
bluecco authored Mar 6, 2024
2 parents 96dab1c + 4ef40bb commit 1b3d5c6
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 44 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Unit tests
on:
push:
branches:
- develop
pull_request:

jobs:
test-unit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false

- uses: oven-sh/setup-bun@v1

- uses: actions/setup-node@v3
with:
node-version: 18

- run: bun install
- run: bun run build
- run: bun run test
env:
TEST_RPC_PROVIDER: ${{ vars.TEST_RPC_PROVIDER }}
24 changes: 4 additions & 20 deletions src/contractBatch/__snapshots__/integration.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -36,32 +36,16 @@ exports[`ContractBatchProvider one call fails in a batch 1`] = `
exports[`ContractBatchProvider two call fails in a batch 1`] = `
[
{
"status": "fulfilled",
"value": [
"0x0",
"0x0",
],
"status": "rejected",
},
{
"status": "fulfilled",
"value": [
"0x0",
"0x0",
],
"status": "rejected",
},
{
"status": "fulfilled",
"value": [
"0x0",
"0x0",
],
"status": "rejected",
},
{
"status": "fulfilled",
"value": [
"0x0",
"0x0",
],
"status": "rejected",
},
]
`;
26 changes: 2 additions & 24 deletions src/rpc/integration.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Mock, afterEach, beforeAll, describe, expect, mock, spyOn, test } from "bun:test";
import { RpcBatchProvider } from "./RpcBatchProvider";
import { Mock, afterEach, beforeAll, describe, expect, mock, test } from "bun:test";
import { filterError } from "../utils.test";
import { Call, CallContractResponse, RpcProvider } from "starknet";
import { RpcBatchProvider } from "./RpcBatchProvider";

function getBatchProvider() {
if (!process.env.TEST_RPC_PROVIDER) {
Expand All @@ -16,27 +15,6 @@ function getBatchProvider() {
});
}

interface MinimalMockProviderInterface {
callContract: Mock<(call: Call) => Promise<CallContractResponse>>;
}

function getIntegrationProvider(): MinimalMockProviderInterface {
const provider = new RpcProvider({
nodeUrl: process.env.TEST_RPC_PROVIDER,
});
return {
callContract: mock(async (call) => {
const { contractAddress, entrypoint, calldata = [] } = call;
const result = await provider.callContract({
contractAddress,
entrypoint,
calldata,
});
return result;
}),
};
}

describe("RpcBatchProvider", () => {
let globalFetchMock: Mock<typeof fetch>;
beforeAll(() => {
Expand Down

0 comments on commit 1b3d5c6

Please sign in to comment.