The test scripts have been updated to use the correct path to the contract artifacts. The original path was incorrect as it was looking for the artifacts in the wrong location.
Before running the tests, ensure you have:
- A running local blockchain node (Hardhat or Ganache)
- Deployed the VyaaparAI smart contract to the local node
- Set up environment variables in
.envfile in the backend directory:
BLOCKCHAIN_RPC_URL=http://localhost:8545
CONTRACT_ADDRESS=0xYourContractAddressHere
PRIVATE_KEY=0xYourPrivateKeyHere
API_URL=http://localhost:5000/api
cd backend
npm run test-blockchainFor testing minting functionality:
npm run test-blockchain -- --mintcd backend
npm run test-workflow-
Contract artifact not found
- Ensure the smart contract has been compiled and deployed with Hardhat
- Verify the path to the artifacts is correct (now fixed in the scripts)
-
Missing dependencies
- The workflow test requires axios:
npm install axios
- The workflow test requires axios:
-
Environment variables
- Double-check that your
.envfile contains all required variables - Ensure the
CONTRACT_ADDRESSmatches your deployed contract
- Double-check that your
-
Contract not deployed
- Run
npx hardhat run scripts/deploy.js --network localhostin the smart-contracts directory
- Run
For reference, here's the correct directory structure for the blockchain-related files:
vyaapar-ai/
├── backend/
│ ├── scripts/
│ │ ├── test-blockchain.js
│ │ └── test-workflow.js
│ └── .env # Backend environment variables
│
├── smart-contracts/
│ ├── artifacts/
│ │ └── contracts/
│ │ └── VyaaparAI.sol/
│ │ └── VyaaparAI.json
│ ├── contracts/
│ │ └── VyaaparAI.sol
│ └── scripts/
│ └── deploy.js
│
└── frontend/
├── src/
│ ├── contracts/
│ │ └── VyaaparAI.json # Copy from smart-contracts/artifacts
│ └── components/
│ └── Blockchain/
│ └── BlockchainDebugPanel.js
└── .env # Frontend environment variables
After fixing these issues, you should be able to run the tests successfully. Remember to:
- Have the local blockchain node running
- Have the contract deployed
- Set up all environment variables correctly
For any additional issues, check the console output for specific error messages and refer to this guide for solutions.