From 1952a98f80a84ef3aa4ad1146762322fb264c193 Mon Sep 17 00:00:00 2001 From: Kevin Ingersoll Date: Mon, 26 Jun 2023 16:37:54 +0100 Subject: [PATCH] wip anvil test --- packages/block-events-stream/package.json | 1 + .../src/createBlockEventsStream.test.ts | 28 ++++++++++ pnpm-lock.yaml | 54 ++++++++++++++++--- 3 files changed, 76 insertions(+), 7 deletions(-) create mode 100644 packages/block-events-stream/src/createBlockEventsStream.test.ts diff --git a/packages/block-events-stream/package.json b/packages/block-events-stream/package.json index 1ae4581be5..4cb77520dc 100644 --- a/packages/block-events-stream/package.json +++ b/packages/block-events-stream/package.json @@ -34,6 +34,7 @@ }, "devDependencies": { "@types/debug": "^4.1.7", + "@viem/anvil": "^0.0.6", "tsup": "^6.7.0", "vitest": "0.31.4" }, diff --git a/packages/block-events-stream/src/createBlockEventsStream.test.ts b/packages/block-events-stream/src/createBlockEventsStream.test.ts new file mode 100644 index 0000000000..a1ed8367c4 --- /dev/null +++ b/packages/block-events-stream/src/createBlockEventsStream.test.ts @@ -0,0 +1,28 @@ +import { describe, expect, it } from "vitest"; +import { createBlockEventsStream } from "./createBlockEventsStream"; +import { createPublicClient, createTestClient, http } from "viem"; +import { foundry } from "viem/chains"; +import { storeEventsAbi } from "@latticexyz/store"; +import { createAnvil } from "@viem/anvil"; + +describe("createBlockEventsStream", () => { + it("streams events grouped by block", async () => { + const anvil = createAnvil(); + await anvil.start(); + + const publicClient = createPublicClient({ + chain: foundry, + transport: http(), + }); + + const testClient = createTestClient({ + chain: foundry, + mode: "anvil", + transport: http(), + }); + + const block$ = await createBlockEventsStream({ publicClient, events: storeEventsAbi }); + + await anvil.stop(); + }); +}); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 42053798e5..8d8f67fdd1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -75,6 +75,9 @@ importers: '@types/debug': specifier: ^4.1.7 version: 4.1.7 + '@viem/anvil': + specifier: ^0.0.6 + version: 0.0.6(debug@4.3.4) tsup: specifier: ^6.7.0 version: 6.7.0(postcss@8.4.23)(typescript@5.0.4) @@ -4019,6 +4022,19 @@ packages: '@use-gesture/core': 10.2.9 dev: false + /@viem/anvil@0.0.6(debug@4.3.4): + resolution: {integrity: sha512-OjKR/+FVwzuygXYFqP8MBal1SXG8bT2gbZwqqB0XuLw81LNBBvmE/Repm6+5kkBh4IUj0PhYdrqOsnayS14Gtg==} + dependencies: + execa: 7.1.1 + get-port: 6.1.2 + http-proxy: 1.18.1(debug@4.3.4) + ws: 8.13.0 + transitivePeerDependencies: + - bufferutil + - debug + - utf-8-validate + dev: true + /@vitejs/plugin-react@4.0.0(vite@4.3.6): resolution: {integrity: sha512-HX0XzMjL3hhOYm+0s95pb0Z7F8O81G7joUHgfDd/9J/ZZf5k4xX6QAMFkKsHFxaHlf6X7GD7+XuaZ66ULiJuhQ==} engines: {node: ^14.18.0 || >=16.0.0} @@ -6621,6 +6637,21 @@ packages: strip-final-newline: 3.0.0 dev: false + /execa@7.1.1: + resolution: {integrity: sha512-wH0eMf/UXckdUYnO21+HDztteVv05rq2GXksxT4fCGeHkBhw1DROXh40wcjMcRqDOWE7iPJ4n3M7e2+YFP+76Q==} + engines: {node: ^14.18.0 || ^16.14.0 || >=18.0.0} + dependencies: + cross-spawn: 7.0.3 + get-stream: 6.0.1 + human-signals: 4.3.1 + is-stream: 3.0.0 + merge-stream: 2.0.0 + npm-run-path: 5.1.0 + onetime: 6.0.0 + signal-exit: 3.0.7 + strip-final-newline: 3.0.0 + dev: true + /execcli@5.0.6: resolution: {integrity: sha512-du+uy/Ew2P90PKjSHI89u/XuqVaBDzvaJ6ePn40JaOy7owFQNsYDbd5AoR5A559HEAb1i5HO22rJxtgVonf5Bg==} engines: {node: '>=8', npm: '>=4'} @@ -7052,6 +7083,11 @@ packages: engines: {node: '>=8'} dev: true + /get-port@6.1.2: + resolution: {integrity: sha512-BrGGraKm2uPqurfGVj/z97/zv8dPleC6x9JBNRTrDNtCkkRF4rPwrQXFgL7+I+q8QSdU4ntLQX2D7KIxSy8nGw==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + dev: true + /get-stream@5.2.0: resolution: {integrity: sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==} engines: {node: '>=8'} @@ -7516,6 +7552,17 @@ packages: - supports-color dev: true + /http-proxy@1.18.1(debug@4.3.4): + resolution: {integrity: sha512-7mz/721AbnJwIVbnaSv1Cz3Am0ZLT/UBwkC92VlxhXv/k/BBQfM2fXElQNC27BVGr0uwUpplYPQM9LnaBMR5NQ==} + engines: {node: '>=8.0.0'} + dependencies: + eventemitter3: 4.0.7 + follow-redirects: 1.15.2(debug@4.3.4) + requires-port: 1.0.0 + transitivePeerDependencies: + - debug + dev: true + /https-proxy-agent@5.0.1: resolution: {integrity: sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==} engines: {node: '>= 6'} @@ -7538,7 +7585,6 @@ packages: /human-signals@4.3.1: resolution: {integrity: sha512-nZXjEF2nbo7lIw3mgYjItAfgQXog3OjJogSbKa2CQIIvSGWcKgeJnQlNXip6NglNzYH45nSRiEVimMvYL8DDqQ==} engines: {node: '>=14.18.0'} - dev: false /humanize-ms@1.2.1: resolution: {integrity: sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ==} @@ -8015,7 +8061,6 @@ packages: /is-stream@3.0.0: resolution: {integrity: sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - dev: false /is-string@1.0.7: resolution: {integrity: sha512-tE2UXzivje6ofPW7l23cjDOMa09gb7xlAqG6jG5ej6uPV32TlWP3NKPigtaGeHNu9fohccRYvIiZMfOOnOYUtg==} @@ -9518,7 +9563,6 @@ packages: /mimic-fn@4.0.0: resolution: {integrity: sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==} engines: {node: '>=12'} - dev: false /min-indent@1.0.1: resolution: {integrity: sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==} @@ -10142,7 +10186,6 @@ packages: engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} dependencies: path-key: 4.0.0 - dev: false /npmlog@6.0.2: resolution: {integrity: sha512-/vBvz5Jfr9dT/aFWd0FIRf+T/Q2WBsLENygUaFUqstqsycmZAP/t5BvFJTK0viFmSUxiUKTUplWy5vt+rvKIxg==} @@ -10351,7 +10394,6 @@ packages: engines: {node: '>=12'} dependencies: mimic-fn: 4.0.0 - dev: false /open@8.4.2: resolution: {integrity: sha512-7x81NCL719oNbsq/3mh+hVrAWmFuEYUqrq/Iw3kUzH8ReypT9QQ0BLoJS7/G9k6N81XjW4qHWtjWwe/9eLy1EQ==} @@ -10687,7 +10729,6 @@ packages: /path-key@4.0.0: resolution: {integrity: sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ==} engines: {node: '>=12'} - dev: false /path-parse@1.0.7: resolution: {integrity: sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==} @@ -12138,7 +12179,6 @@ packages: /strip-final-newline@3.0.0: resolution: {integrity: sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==} engines: {node: '>=12'} - dev: false /strip-hex-prefix@1.0.0: resolution: {integrity: sha512-q8d4ue7JGEiVcypji1bALTos+0pWtyGlivAWyPuTkHzuTCJqrK9sWxYQZUq6Nq3cuyv3bm734IhHvHtGGURU6A==}