Closed woodser closed 2 weeks ago
@mainnet-pat Hoping you can help fix this? It doesn't like the import axios
statement for some reason. I'd like to fix the root problem within monero-ts and not require any changes to downstream consumers, if possible.
How can I reproduce this locally?
My other projects never showed these erorrs
How can I reproduce this locally?
By running any of the tests in the haveno-ts project: https://github.com/haveno-dex/haveno-ts?tab=readme-ov-file#run-tests
My other projects never showed these erorrs
Yeah I didn't see it in any of the sample apps. It was my mistake to not test it in haveno-ts prior to release.
According to the stackoverflow, the issue might resolve by updating to the latest version of jest, but that introduces its own build issue (ReferenceError: proto is not defined
).
Cant look too deep into this. Packing the bags for a weekend trip.
It seemed to help me to install the following (latest versions):
npm i --save-dev jest @types/jest ts-jest ts-jest-resolver
remove your config from package.json and add a jest.config.cjs from my other project:
module.exports = {
rootDir: "./",
preset: "ts-jest/presets/default-esm",
resolver: "ts-jest-resolver",
collectCoverage: true,
collectCoverageFrom: [
"**/*.{js,jsx,ts}",
"!**/node_modules/**",
],
coveragePathIgnorePatterns: [
".*/src/.*\\.d\\.ts",
".*/src/.*\\.test\\.{ts,js}",
".*/src/.*\\.test\\.headless\\.js",
],
roots: [
"<rootDir>/src",
],
testMatch: [
"**/__tests__/**/*.+(ts|tsx|js)",
"**/?(*.)+(spec|test).+(ts|tsx|js)",
],
transform: {
"^.+\\.tsx?$": [
"ts-jest",
{
useESM: true,
},
],
},
testEnvironment: "node",
verbose: true,
maxConcurrency: 1,
testTimeout: 180000,
testPathIgnorePatterns: [
"/node_modules/",
"/dist/",
],
globals: {
window: {}
},
};
remove your config from package.json and add a jest.config.cjs from my other project:
Doing so leads to errors like these:
FAIL src/HavenoClient.test.ts
● Test suite failed to run
src/HavenoClient.test.ts:94:3 - error TS2564: Property 'havenod' has no initializer and is not definitely assigned in the constructor.
94 havenod: HavenoClient;
~~~~~~~
src/HavenoClient.test.ts:95:3 - error TS2564: Property 'wallet' has no initializer and is not definitely assigned in the constructor.
95 wallet: moneroTs.MoneroWallet;
~~~~~~
src/HavenoClient.test.ts:96:3 - error TS2564: Property 'trade' has no initializer and is not definitely assigned in the constructor.
96 trade: TradeInfo;
Looks like linter stuff, so should be fixable
for example like this:
class PeerContext {
havenod!: HavenoClient;
wallet!: moneroTs.MoneroWallet;
trade!: TradeInfo;
....
Fixing the lint errors gets closer, but now getting: XMLHttpRequest is not defined
.
it is not defined for node
Got further by changing testEnvironment: "node"
to testEnvironment: "jsdom"
, but now getting cors errors because requests originate from "http://localhost" instead of "http://localhost:8080".
Adding "testURL": "http://localhost:8080" changes the error to: 401 Unauthorized: <html><head><title>Unauthorized Access</title></head><body><h1>401 Unauthorized</h1></body></html>
As of now I'm still not able to use the new monero-ts update in the haveno-ts library.
Adding "testURL": "http://localhost:8080/" changes the error to: 401 Unauthorized:
Unauthorized Access 401 Unauthorized
I'm wondering if it's failing on the digest authentication challenge in this environment.
This seems like the response from the daemon, why would jest render this?
I can not compile the protobuf stuff atm. so can not test exactly your code
Built haveno and protobuf but fail with TypeError: Jest: a transform must export a
processfunction.
I run out of time, will be back on Monday
Here is the error in the CI tests if it helps: https://github.com/haveno-dex/haveno-ts/actions/runs/10564898796/job/29268294819
I've spent 3 more hours on this, I still can not set up the haveno envronment locally, it is simply too complex. If monero-ts returns you actual 401 response with some body, this means that axios http client works, so it must be something with your wallet-rpc service. I think fixing haveno-ts for you is beyond the scope of my involvement here unless you will offer me a bounty for this
I have tried monero-ts in other projects using up-to-date jest for tests, and new http client adaptor based on axios works for me there.
I can offer a bounty of 2 additional XMR to fix using the library in haveno-ts. As it is, I'm stuck. I'd be happy to DM to help set up the haveno-ts environment so we don't lose time there.
Okay, I take this bounty offer and will take another look at haveno-ts.
My main problem is that your docker setup is using host networking which does not work in my macOS environment. Firstly I want to migrate the docker compose setup to use docker internal networking, then it will be better portable and testable
your docker setup is using host networking
Ah! I was just playing with this yesterday, and realized that on macOS, it will not work if you include --network host
in the command to start envoy.
So this needs removed and it should work as is.
this would not be enough, proper ports shall be exposed and services linked by name like --daemon-address=node1:28081
instead of by ip like --daemon-address=127.0.0.1:28081
I'd highly recommend getting the project running as is before updating things (which would be great). Again, happy to help get that first step working over DM or here or whatever.
the best I can do to make it run as is is to test on some linux vps (I assume you run linux, at least github actions are linux based)
I'm running macOS, and all tests pass for me on that environment.
It also requires an old version of Docker.
well, idk about downgrading my docker, but if you mean it, I will do
Yes it will definitely not work with the latest version of docker. I lost the better part of yesterday wrestling with this. Downgrading back to Docker 4.26.1 worked like a charm.
This issue is resolved in the 0.10.3 release.
Since the Axios update in v0.10.1, I'm hitting an error using monero-ts in haveno-ts: