Import of OpenZeppelin test helpers added automatically using buidler

Hey, I’m using the open zeppelin test helpers, and I’ve repeatedly noticed a very strange behavior, which is that my test file seems to magically add a require statement at the top of my file if I type some special things. Specifically, I’ve seen that I typed latestBlock and then ran my tests, and boom! The top of my file then contained const { latestBlock } = require('@openzeppelin/test-helpers/src/time'); . I 100% absolutely no questions asked did not add this import. I’ve also seen this happen with web3 as well. I can’t replicate every time, but I can confirm this has happened multiple times. ie. I remove the import, run my tests, and the import statement comes back.

Anyone run into this or know what’s going on? It almost seems like some pre-processor (perhaps from Buidler or Truffle) is running that looks for keywords from my test files and automatically adds imports if it can. Which if so, is insane, and I at least want to know it’s happening, and probably turn it off somehow.

:computer: Environment

I’m using OpenZeppelin test helpers 0.5.6, Open Zeppelin contracts 3.1.0, Buidler 1.4.3. Also buidler-truffle5 of 1.3.4, and truffle-contract 4.2.1. When I run my tests, I use npx buidler test --show-stack-traces , through npm test. This is all just on my local Macbook Pro, on Catalina 10.15.6


:1234: Code to reproduce

1 Like

Hi @blakewest,

Welcome to the community :wave:

That does sound really weird. Do you have a public repository with this in so I could reproduce to try to track it down?

Hi @blakewest,

I tried to recreate this issue but haven’t been able to reproduce.

Where are you typing latestBlock?

I used the setup from on WSL2.

If you have a repository that you could share or any other information that could help me reproduce, that would be great.

Hey @abcoathup, thanks for looking into this. I tried to get this to replicate but I couldn’t. If no one else is reporting it, I’m fine to chalk this up to solar flares. If it happens again, I’ll definitely let you know!

1 Like

Hi @blakewest,

Glad it has happened again. Let me know if you see anything weird and I can try to reproduce. Pesky solar flares.