This folder contains tests to make sure that the different parts of the Unlock Protocol play nicely together (i.e. contracts, subgraph, server, ui, etc...).
For subgraph test
yarn test
First start a fully provisioned ETH node (with the Unlock contracts deployed and set correctly) and a subgraph indexing correctly.
yarn start:infra
then you nneed to export the subgraph URL, rebuild the networks package and run the test
export SUBGRAPH_URL=http://localhost:8000/subgraphs/name/testgraph
# add localhost to networks package
yarn test:prepare
# run actual test against local eth/subgraph nodes
yarn test --network localhost-
Run The Unlock protocol on your machine (see the Development section above)
-
Create a file in the
/testfolder with your logic.
- The tests are run using hardhat and uses mocha syntax.
- You can access the Unlock contract by using the
unlockobject from hardhat -- created by importing[hardhat plugin](../packages/hardhat-plugin/). - Example:
import { unlock } from 'hardhat'
describe('Unlock', function () {
it('creates a simple lock', function () {
const { lock } = await unlock.createLock({ ...lockParams })
expect(await lock.name()).to.equals(lockParams.name)
})
})- Run all tests using
yarn testor a single file usingyarn test test/<yourfile>.ts. All files added to thetestfolder will run on CI once uploaded to Github.