diff --git a/package.json b/package.json index 2a18c08f..259dfd16 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ "zod": "^3.21.4" }, "devDependencies": { + "@testcontainers/postgresql": "^10.0.1", "@testing-library/react": "^14.0.0", "@testing-library/user-event": "^14.4.3", "@types/lodash-es": "^4.17.8", @@ -68,7 +69,7 @@ "stylelint-config-css-modules": "^4.3.0", "stylelint-config-html": "^1.1.0", "stylelint-config-standard": "^34.0.0", - "testcontainers": "^9.12.0", + "testcontainers": "^10.0.1", "typescript": "^5.1.6", "vitest": "^0.33.0", "vitest-github-actions-reporter": "^0.10.0" diff --git a/testing/globalSetup.ts b/testing/globalSetup.ts index 98ab6d8e..c5cd4dcb 100644 --- a/testing/globalSetup.ts +++ b/testing/globalSetup.ts @@ -3,6 +3,10 @@ import { ChildProcess, exec, spawn } from 'node:child_process'; import process from 'node:process'; import { GenericContainer, StartedTestContainer, Wait } from 'testcontainers'; +import { + PostgreSqlContainer, + StartedPostgreSqlContainer, +} from '@testcontainers/postgresql'; const env = { MODE: 'test', @@ -19,7 +23,7 @@ const env = { let server: ChildProcess; let blockchainContainer: StartedTestContainer; -let databaseContainer: StartedTestContainer; +let databaseContainer: StartedPostgreSqlContainer; export async function setup() { const WS_PORT = 9944; @@ -44,15 +48,13 @@ export async function setup() { // configure the code to use a local blank database const DB_PORT = 5432; const POSTGRES_PASSWORD = 'postgres'; - databaseContainer = await new GenericContainer('postgres') - .withEnvironment({ POSTGRES_PASSWORD }) + databaseContainer = await new PostgreSqlContainer() + .withPassword(POSTGRES_PASSWORD) .withExposedPorts(DB_PORT) .start(); { - const port = databaseContainer.getMappedPort(DB_PORT); - const host = databaseContainer.getHost(); - const databaseUri = `postgres://postgres:${POSTGRES_PASSWORD}@${host}:${port}/postgres`; + const databaseUri = databaseContainer.getConnectionUri(); env.DATABASE_URI = databaseUri; process.env.DATABASE_URI = databaseUri; } diff --git a/yarn.lock b/yarn.lock index 0c20ec99..e4328019 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1258,6 +1258,13 @@ dependencies: defer-to-connect "^2.0.1" +"@testcontainers/postgresql@^10.0.1": + version "10.0.1" + resolved "https://registry.yarnpkg.com/@testcontainers/postgresql/-/postgresql-10.0.1.tgz#57ad6c9011a6c643925dd8c0e574c73b5ecadbbb" + integrity sha512-nHJBJI2N3NOMQH5kY3r8i5qX6Ta4/fu+oUEIp3QssFTNh/5K25DJrAGiAKDHRHz4ffwlFK82P7dlIBiqNWlskw== + dependencies: + testcontainers "^10.0.1" + "@testing-library/dom@^9.0.0": version "9.2.0" resolved "https://registry.yarnpkg.com/@testing-library/dom/-/dom-9.2.0.tgz#0e1f45e956f2a16f471559c06edd8827c4832f04" @@ -1291,13 +1298,6 @@ resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-2.0.0.tgz#f544a148d3ab35801c1f633a7441fd87c2e484bf" integrity sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A== -"@types/archiver@^5.3.2": - version "5.3.2" - resolved "https://registry.yarnpkg.com/@types/archiver/-/archiver-5.3.2.tgz#a9f0bcb0f0b991400e7766d35f6e19d163bdadcc" - integrity sha512-IctHreBuWE5dvBDz/0WeKtyVKVRs4h75IblxOACL92wU66v+HGAfEYAOyXkOFphvRJMhuXdI9huDXpX0FC6lCw== - dependencies: - "@types/readdir-glob" "*" - "@types/aria-query@^5.0.1": version "5.0.1" resolved "https://registry.yarnpkg.com/@types/aria-query/-/aria-query-5.0.1.tgz#3286741fb8f1e1580ac28784add4c7a1d49bdfbc" @@ -1362,22 +1362,6 @@ dependencies: "@types/ms" "*" -"@types/docker-modem@*": - version "3.0.2" - resolved "https://registry.yarnpkg.com/@types/docker-modem/-/docker-modem-3.0.2.tgz#c49c902e17364fc724e050db5c1d2b298c6379d4" - integrity sha512-qC7prjoEYR2QEe6SmCVfB1x3rfcQtUr1n4x89+3e0wSTMQ/KYCyf+/RAA9n2tllkkNc6//JMUZePdFRiGIWfaQ== - dependencies: - "@types/node" "*" - "@types/ssh2" "*" - -"@types/dockerode@^3.3.19": - version "3.3.19" - resolved "https://registry.yarnpkg.com/@types/dockerode/-/dockerode-3.3.19.tgz#59eb07550a102b397a9504083a6c50d811eed04c" - integrity sha512-7CC5yIpQi+bHXwDK43b/deYXteP3Lem9gdocVVHJPSRJJLMfbiOchQV3rDmAPkMw+n3GIVj7m1six3JW+VcwwA== - dependencies: - "@types/docker-modem" "*" - "@types/node" "*" - "@types/dom-view-transitions@^1.0.1": version "1.0.1" resolved "https://registry.yarnpkg.com/@types/dom-view-transitions/-/dom-view-transitions-1.0.1.tgz#55333c2862c349153b9007ca01011d9379c12c6c" @@ -1446,7 +1430,7 @@ dependencies: "@types/unist" "*" -"@types/node@*", "@types/node@^18.11.18", "@types/node@^18.17.2": +"@types/node@*", "@types/node@^18.17.2": version "18.17.2" resolved "https://registry.yarnpkg.com/@types/node/-/node-18.17.2.tgz#95b4df6c724e146ef932043a1fb6b8f80975e461" integrity sha512-wBo3KqP/PBqje5TI9UTiuL3yWfP6sdPtjtygSOqcYZWT232dfDeDOnkDps5wqZBP9NgGgYrNejinl0faAuE+HQ== @@ -1487,13 +1471,6 @@ "@types/scheduler" "*" csstype "^3.0.2" -"@types/readdir-glob@*": - version "1.1.1" - resolved "https://registry.yarnpkg.com/@types/readdir-glob/-/readdir-glob-1.1.1.tgz#27ac2db283e6aa3d110b14ff9da44fcd1a5c38b1" - integrity sha512-ImM6TmoF8bgOwvehGviEj3tRdRBbQujr1N+0ypaln/GWjaerOB26jb93vsRHmdMtvVQZQebOlqt2HROark87mQ== - dependencies: - "@types/node" "*" - "@types/resolve@^1.17.0": version "1.20.2" resolved "https://registry.yarnpkg.com/@types/resolve/-/resolve-1.20.2.tgz#97d26e00cd4a0423b4af620abecf3e6f442b7975" @@ -1516,13 +1493,6 @@ dependencies: "@types/node" "*" -"@types/ssh2@*": - version "1.11.11" - resolved "https://registry.yarnpkg.com/@types/ssh2/-/ssh2-1.11.11.tgz#02fb707d821890a655fd27c2d842b0c7114078fb" - integrity sha512-LdnE7UBpvHCgUznvn2fwLt2hkaENcKPFqOyXGkvyTLfxCXBN6roc1RmECNYuzzbHePzD3PaAov5rri9hehzx9Q== - dependencies: - "@types/node" "^18.11.18" - "@types/ssh2@^0.5.48": version "0.5.52" resolved "https://registry.yarnpkg.com/@types/ssh2/-/ssh2-0.5.52.tgz#9dbd8084e2a976e551d5e5e70b978ed8b5965741" @@ -2093,6 +2063,11 @@ available-typed-arrays@^1.0.5: resolved "https://registry.yarnpkg.com/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz#92f95616501069d07d10edb2fc37d3e1c65123b7" integrity sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw== +b4a@^1.6.4: + version "1.6.4" + resolved "https://registry.yarnpkg.com/b4a/-/b4a-1.6.4.tgz#ef1c1422cae5ce6535ec191baeed7567443f36c9" + integrity sha512-fpWrvyVHEKyeEvbKZTVOeZF3VSKKWtJxFIxX/jaVPf+cLbGUSitjb49pHLqPV2BUNNZ0LcoeEGfE/YCpyDYHIw== + bail@^2.0.0: version "2.0.2" resolved "https://registry.yarnpkg.com/bail/-/bail-2.0.2.tgz#d26f5cd8fe5d6f832a31517b9f7c356040ba6d5d" @@ -2806,10 +2781,10 @@ dlv@^1.1.3: resolved "https://registry.yarnpkg.com/dlv/-/dlv-1.1.3.tgz#5c198a8a11453596e751494d49874bc7732f2e79" integrity sha512-+HlytyjlPKnIG8XuRG8WvmBP8xs8P71y+SKKS6ZXWoEgLuePxtDoUEiH7WkdePWrQ5JBpE6aoVqfZfJUQkjXwA== -docker-compose@^0.24.1: - version "0.24.1" - resolved "https://registry.yarnpkg.com/docker-compose/-/docker-compose-0.24.1.tgz#09f9a2408395b8adf80feaacf65f6e2a4b119866" - integrity sha512-CVphzCi0Hmw/0CHlAzgiwhLsJjFRqnvpBYMYbf63bz6MON69ElgrfrgQTmgPtEjbifjgaptu3+Gea62vI+9jiA== +docker-compose@^0.24.2: + version "0.24.2" + resolved "https://registry.yarnpkg.com/docker-compose/-/docker-compose-0.24.2.tgz#172027153b6c16239d5457fe48f56c7803f42c9d" + integrity sha512-2/WLvA7UZ6A2LDLQrYW0idKipmNBWhtfvrn2yzjC5PnHDzuFVj1zAZN6MJxVMKP0zZH8uzAK6OwVZYHGuyCmTw== dependencies: yaml "^2.2.2" @@ -3480,6 +3455,11 @@ fast-diff@^1.1.2: resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.3.0.tgz#ece407fa550a64d638536cd727e129c61616e0f0" integrity sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw== +fast-fifo@^1.1.0, fast-fifo@^1.2.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/fast-fifo/-/fast-fifo-1.3.0.tgz#03e381bcbfb29932d7c3afde6e15e83e05ab4d8b" + integrity sha512-IgfweLvEpwyA4WgiQe9Nx6VV2QkML2NkvZnk1oKnIzXgXdWxuhF7zw4DvLTPZJn6PIUneiAXPF24QmoEqHTjyw== + fast-glob@^3.2.11, fast-glob@^3.2.12, fast-glob@^3.2.9, fast-glob@^3.3.0: version "3.3.0" resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.3.0.tgz#7c40cb491e1e2ed5664749e87bfb516dbe8727c0" @@ -6213,6 +6193,11 @@ queue-microtask@^1.2.2: resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243" integrity sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A== +queue-tick@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/queue-tick/-/queue-tick-1.0.1.tgz#f6f07ac82c1fd60f82e098b417a80e52f1f4c142" + integrity sha512-kJt5qhMxoszgU/62PLP1CJytzd2NKetjSRnyuj31fDd3Rlcz3fzlFdFLD1SItunPwyqEOkca6GbV612BWfaBag== + quick-format-unescaped@^4.0.3: version "4.0.4" resolved "https://registry.yarnpkg.com/quick-format-unescaped/-/quick-format-unescaped-4.0.4.tgz#93ef6dd8d3453cbc7970dd614fad4c5954d6b5a7" @@ -6980,6 +6965,14 @@ streamsearch@^1.1.0: resolved "https://registry.yarnpkg.com/streamsearch/-/streamsearch-1.1.0.tgz#404dd1e2247ca94af554e841a8ef0eaa238da764" integrity sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg== +streamx@^2.15.0: + version "2.15.0" + resolved "https://registry.yarnpkg.com/streamx/-/streamx-2.15.0.tgz#f58c92e6f726b5390dcabd6dd9094d29a854d698" + integrity sha512-HcxY6ncGjjklGs1xsP1aR71INYcsXFJet5CU1CHqihQ2J5nOsbd4OjgjHO42w/4QNv9gZb3BueV+Vxok5pLEXg== + dependencies: + fast-fifo "^1.1.0" + queue-tick "^1.0.1" + string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: version "4.2.3" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" @@ -7267,15 +7260,14 @@ tapable@^2.2.0: resolved "https://registry.yarnpkg.com/tapable/-/tapable-2.2.1.tgz#1967a73ef4060a82f12ab96af86d52fdb76eeca0" integrity sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ== -tar-fs@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/tar-fs/-/tar-fs-2.1.1.tgz#489a15ab85f1f0befabb370b7de4f9eb5cbe8784" - integrity sha512-V0r2Y9scmbDRLCNex/+hYzvp/zyYjvFbHPNgVTKfQvVrb6guiE/fxP+XblDNR011utopbkex2nM4dHNV6GDsng== +tar-fs@^3.0.4: + version "3.0.4" + resolved "https://registry.yarnpkg.com/tar-fs/-/tar-fs-3.0.4.tgz#a21dc60a2d5d9f55e0089ccd78124f1d3771dbbf" + integrity sha512-5AFQU8b9qLfZCX9zp2duONhPmZv0hGYiBPJsyUdqMjzq/mqVpy/rEUSeHk1+YitmxugaptgBh5oDGU3VsAJq4w== dependencies: - chownr "^1.1.1" mkdirp-classic "^0.5.2" pump "^3.0.0" - tar-stream "^2.1.4" + tar-stream "^3.1.5" tar-fs@~2.0.1: version "2.0.1" @@ -7287,7 +7279,7 @@ tar-fs@~2.0.1: pump "^3.0.0" tar-stream "^2.0.0" -tar-stream@^2.0.0, tar-stream@^2.1.4, tar-stream@^2.2.0: +tar-stream@^2.0.0, tar-stream@^2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/tar-stream/-/tar-stream-2.2.0.tgz#acad84c284136b060dc3faa64474aa9aebd77287" integrity sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ== @@ -7298,26 +7290,33 @@ tar-stream@^2.0.0, tar-stream@^2.1.4, tar-stream@^2.2.0: inherits "^2.0.3" readable-stream "^3.1.1" -testcontainers@^9.12.0: - version "9.12.0" - resolved "https://registry.yarnpkg.com/testcontainers/-/testcontainers-9.12.0.tgz#f9f2492af4317f649611005b60fa0bbf6fdd7639" - integrity sha512-zmjLTAUqCiDvhDq7TCwcyhI3m/cXXKGnhyLLJ9pgh53VgG9O+P+opX1pIx28aYTUQ7Yu6b5sJf0xoIuxoiclWg== +tar-stream@^3.1.5: + version "3.1.6" + resolved "https://registry.yarnpkg.com/tar-stream/-/tar-stream-3.1.6.tgz#6520607b55a06f4a2e2e04db360ba7d338cc5bab" + integrity sha512-B/UyjYwPpMBv+PaFSWAmtYjwdrlEaZQEhMIBFNC5oEG8lpiW8XjcSdmEaClj28ArfKScKHs2nshz3k2le6crsg== + dependencies: + b4a "^1.6.4" + fast-fifo "^1.2.0" + streamx "^2.15.0" + +testcontainers@^10.0.1: + version "10.0.1" + resolved "https://registry.yarnpkg.com/testcontainers/-/testcontainers-10.0.1.tgz#6ceca4aed7cc3cc9dc0dcb9d7b340e37f7517ea1" + integrity sha512-eS76/xz0mOYL9Go0i8RKJh8CSi0xcFGzS2AS5ieNV9TRsHLKkB+2/isWk8iCy0C17YA17Cd3EHSRYCge/7REhQ== dependencies: "@balena/dockerignore" "^1.0.2" - "@types/archiver" "^5.3.2" - "@types/dockerode" "^3.3.19" archiver "^5.3.1" async-lock "^1.4.0" byline "^5.0.0" debug "^4.3.4" - docker-compose "^0.24.1" + docker-compose "^0.24.2" dockerode "^3.3.5" get-port "^5.1.1" node-fetch "^2.6.12" proper-lockfile "^4.1.2" properties-reader "^2.2.0" ssh-remote-port-forward "^1.0.4" - tar-fs "^2.1.1" + tar-fs "^3.0.4" tmp "^0.2.1" text-table@^0.2.0: