Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yarn test issues - does not connect to uniswap - gettingtimeouts #2

Closed
mjsmorgan opened this issue Feb 24, 2021 · 5 comments · Fixed by #3
Closed

yarn test issues - does not connect to uniswap - gettingtimeouts #2

mjsmorgan opened this issue Feb 24, 2021 · 5 comments · Fixed by #3

Comments

@mjsmorgan
Copy link

I am having an issue when I run yarn test. It looks like it is not connecting and receives a timeout:

yarn test
yarn run v1.22.5
$ mocha --file './tests/setup.js' 'tests/**/*.test.js' --recursive

logging || Winston Test
[winston] Attempt to write logs with no transports {"level":"info","message":"🚨 This is a test"}
✓ should send Slack message

network/webthree/uniswap || Pair Test
1) should retrieve name
2) should retrieve decimals
3) should retrieve token0
4) should retrieve token1
5) should retrieve reserves
6) should compute amount received

1 passing (12s)
6 failing

  1. network/webthree/uniswap || Pair Test
    should retrieve name:
    Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/opt/Cafe-Chi/tests/network/webthree/uniswap/pair.test.js)
    at listOnTimeout (internal/timers.js:549:17)
    at processTimers (internal/timers.js:492:7)

  2. network/webthree/uniswap || Pair Test
    should retrieve decimals:
    Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/opt/Cafe-Chi/tests/network/webthree/uniswap/pair.test.js)
    at listOnTimeout (internal/timers.js:549:17)
    at processTimers (internal/timers.js:492:7)

  3. network/webthree/uniswap || Pair Test
    should retrieve token0:
    Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/opt/Cafe-Chi/tests/network/webthree/uniswap/pair.test.js)
    at listOnTimeout (internal/timers.js:549:17)
    at processTimers (internal/timers.js:492:7)

  4. network/webthree/uniswap || Pair Test
    should retrieve token1:
    Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/opt/Cafe-Chi/tests/network/webthree/uniswap/pair.test.js)
    at listOnTimeout (internal/timers.js:549:17)
    at processTimers (internal/timers.js:492:7)

  5. network/webthree/uniswap || Pair Test
    should retrieve reserves:
    Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/opt/Cafe-Chi/tests/network/webthree/uniswap/pair.test.js)
    at listOnTimeout (internal/timers.js:549:17)
    at processTimers (internal/timers.js:492:7)

  6. network/webthree/uniswap || Pair Test
    should compute amount received:
    Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/opt/Cafe-Chi/tests/network/webthree/uniswap/pair.test.js)
    at listOnTimeout (internal/timers.js:549:17)
    at processTimers (internal/timers.js:492:7)

^C

@haydenshively
Copy link
Owner

Hi @mjsmorgan, thanks for your interest in Cafe-Chi.

When I wrote the tests I was focused on my local machine, on which I could connect to Geth via IPC. It's probably timing out for you because it takes longer to communicate with Infura/Alchemy APIs than it does to communicate over IPC. I'll try to push a fix this weekend, but in the mean time you should be able to fix this by adding .timeout(10000) after each failing test.

Example:

it("should retrieve name", async () => {
  return Pair.chi_eth
    .name()(web3.ganache)
    .then(x => assert(x === "Uniswap V2"));
}).timeout(10000);

See this thread for other options. You may be able to just update the test command in package.json with the flag --timeout 10000, though I haven't tried that method myself.

@martinsteldinger
Copy link

@haydenshively thanks for your work.
i hit the same problem. increasing timeout does not bring anything. thnks for pointing out using local geth. I'm using infura but also tried alchemy. I can see there are informations requested on the servers of infura (and alchemy) by tcpdump, but it seems to fail since no requests are counted in the dashboard of infura.

@mjsmorgan
Copy link
Author

@martinsteldinger I noticed the same thing using iftop.....it is connecting, but the connection is rejected for some reason

@haydenshively
Copy link
Owner

haydenshively commented Feb 27, 2021

I was only able to replicate these results after uninstalling/reinstalling dependencies, so I assume some package was updated and broke compatibility. Looking into it now

This only happened once, so I don't think it's the root cause

@haydenshively
Copy link
Owner

haydenshively commented Feb 28, 2021

In tests/setup.js can you all take a look at the following lines?

const infura = {
  type: "WS_Infura",
  envKeyID: "PROVIDER_INFURA_ID" // This is the name of the env variable storing the ID, NOT THE ID ITSELF
};
const alchemy = {
  type: "WS_Alchemy",
  envKeyKey: "PROVIDER_ALCHEMY_KEY" // This is the name of the env variable storing the key, NOT THE KEY ITSELF
};
web3.mainnet = new MultiSendProvider("mainnet", [infura, alchemy]);

Feel free to delete either the infura or alchemy entry; you only need one. But Do make sure that envKeyID and envKeyKey point to the name of the environment variable not ID/key itself. The idea here is that your private info will never be plain-text in the code. Getting this wrong would cause Infura and Alchemy to timeout, since the code would see an undefined ID/key.

If the issue remains after checking this, feel free to reopen this issue. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants