diff --git a/.env.example b/.env.example index 19445a1..5bd7534 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,8 @@ -# Private key for the account that will deploy the contracts -# IMPORTANT: Never commit your actual .env file with real private keys to version control! -# Format: 0x followed by 64 hexadecimal characters -PRIVATE_KEY=0x0000000000000000000000000000000000000000000000000000000000000000 +# Rayls Devnet +RPC_URL=https://devnet-rpc.rayls.com +CHAIN_ID=123123 + +# Wallets (NUNCA commitar chaves reais; use apenas no .env local) +PRIVATE_KEY_OWNER=PASTE_OWNER_PRIVATE_KEY_HERE +PRIVATE_KEY_USER_A=PASTE_USER_A_PRIVATE_KEY_HERE +PRIVATE_KEY_USER_B=PASTE_USER_B_PRIVATE_KEY_HERE diff --git a/entrega/ENTREGA.md b/entrega/ENTREGA.md new file mode 100644 index 0000000..bb0384c --- /dev/null +++ b/entrega/ENTREGA.md @@ -0,0 +1,74 @@ +# QA Engineering Challenge — Entrega + +Repositório: https://github.com/clebergrunge87/qa-engineering-challenge-rayls + +## Pré-requisitos +- Node.js 20+ +- npm + +## Setup (rodar na raiz do projeto) + +### 1) Instalar dependências +```bash +npm install +``` + +2) Configurar variáveis de ambiente (NÃO commitar .env) + +O repositório possui o template .env.example. + +Crie o .env localmente (ele já está no .gitignore) e preencha com os valores solicitados sem commitar chaves. + +Exemplo (Windows PowerShell): + +``` +Copy-Item .env.example .env -Force +notepad .env +``` + +Preencher no .env local: + +RPC_URL=https://devnet-rpc.rayls.com + +CHAIN_ID=123123 + +PRIVATE_KEY_OWNER= + +PRIVATE_KEY_USER_A= + +PRIVATE_KEY_USER_B= + +3) Rodar testes localmente (Hardhat local) + +``` +npx hardhat test +``` + +4) Rodar testes na Rayls Devnet + +``` +npx hardhat test --network rayls_devnet +``` + +Observação — instabilidade do RPC (devnet) + +Ao executar na devnet, podem ocorrer falhas intermitentes do endpoint RPC (ex.: 521/522), +resultando em erros como: + +HH110: Invalid JSON-RPC response... + +Evidências: + +notas/RPC_ISSUE.md + +notas/RPC_ISSUE_522.md + +Arquivos principais + +Contrato: contracts/RaylsToken.sol + +Testes: test/RaylsToken.test.ts + +Config: hardhat.config.ts + +Template env: .env.example diff --git a/hardhat.config.ts b/hardhat.config.ts index f0fd1b0..2ed802f 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -1,49 +1,29 @@ import { HardhatUserConfig } from "hardhat/config"; import "@nomicfoundation/hardhat-toolbox"; -import * as dotenv from "dotenv"; +import "dotenv/config"; -dotenv.config(); +const RPC_URL = process.env.RPC_URL || ""; +const CHAIN_ID = process.env.CHAIN_ID ? Number(process.env.CHAIN_ID) : 0; + +// NUNCA commitar chaves. Elas ficam só no .env local (que já está no .gitignore). +const PRIVATE_KEY_OWNER = process.env.PRIVATE_KEY_OWNER || ""; +const PRIVATE_KEY_USER_A = process.env.PRIVATE_KEY_USER_A || ""; +const PRIVATE_KEY_USER_B = process.env.PRIVATE_KEY_USER_B || ""; + +// Hardhat costuma exigir private key como 0x + 64 hex +const with0x = (k: string) => (k.startsWith("0x") ? k : `0x${k}`); +const accounts = [PRIVATE_KEY_OWNER, PRIVATE_KEY_USER_A, PRIVATE_KEY_USER_B] + .filter(Boolean) + .map(with0x); const config: HardhatUserConfig = { - solidity: { - version: "0.8.20", - settings: { - optimizer: { - enabled: true, - runs: 200, - }, - }, - }, + solidity: "0.8.28", networks: { - rayls: { - url: "https://devnet-rpc.rayls.com", - accounts: process.env.PRIVATE_KEY ? [process.env.PRIVATE_KEY] : [], - chainId: 123123, // Update this if you know the actual chain ID + rayls_devnet: { + url: RPC_URL, + chainId: CHAIN_ID, + accounts, }, - localhost: { - url: "http://127.0.0.1:8545", - }, - }, - etherscan: { - apiKey: { - rayls: "no-api-key-needed", - }, - customChains: [ - { - network: "rayls", - chainId: 123123, - urls: { - apiURL: "https://devnet-explorer.rayls.com/api", - browserURL: "https://devnet-explorer.rayls.com" - } - } - ] - }, - paths: { - sources: "./contracts", - tests: "./test", - cache: "./cache", - artifacts: "./artifacts", }, }; diff --git a/notas/COMANDOS_QUANDO_LIBERAR.txt b/notas/COMANDOS_QUANDO_LIBERAR.txt new file mode 100644 index 0000000..065dc24 --- /dev/null +++ b/notas/COMANDOS_QUANDO_LIBERAR.txt @@ -0,0 +1,9 @@ +# Quando liberarem acesso ao Azure DevOps: + +cd C:\qa-challenge + +git clone https://dev.azure.com/parfin/PS/_git/vault-contract-poc + +cd vault-contract-poc + +npm install diff --git a/notas/README_NOTAS.txt b/notas/README_NOTAS.txt new file mode 100644 index 0000000..205a1af --- /dev/null +++ b/notas/README_NOTAS.txt @@ -0,0 +1,33 @@ +QA Engineering Challenge - Notas (Cleber) + +1) Repositório: +- URL: https://dev.azure.com/parfin/PS/_git/vault-contract-poc +- Status acesso: aguardando liberação + +2) Rede (Rayls Devnet): +- RPC_URL: https://devnet-rpc.rayls.com +- CHAIN_ID: 123123 +- Explorer: https://devnet-explorer.rayls.com/ +- MetaMask: erro ao validar RPC (remove https / não obtém chainId). Resolver depois. + +3) Contas exigidas (3): +- OWNER/DEPLOYER: 0x416679D111Db8c02C658321D27cdFFaCdD3B8F19 +- USER_A: 0xD07c86AB9Ebb23cB58B616bF1cc3e96A2E433f5A +- USER_B: 0x15b22844743481B5a7eA4eba8e861Bb8351c4280 + +“Private key do OWNER veio por e-mail e será usada no .env como PRIVATE_KEY_OWNER (não commitar).” +Obs: não registrar private keys aqui. Somente lembrar de criar/guardar em .env local. + +4) Cenários obrigatórios do teste (E2E): +- Deployment & Ownership (owner = deployer) +- Access control mint (owner minta; userB não pode) +- Allowance (approve + transferFrom + validar saldos/allowance) +- Burn (userB burn e totalSupply reduz) + +5) Checklist quando liberar o repo: +- [ ] git clone +- [ ] npm install +- [ ] criar .env +- [ ] configurar hardhat.config.ts para rayls_devnet +- [ ] rodar testes: npx hardhat test --network rayls_devnet +- [ ] PR com instruções e evidências diff --git a/notas/RPC_ISSUE.md b/notas/RPC_ISSUE.md new file mode 100644 index 0000000..47fc0f1 --- /dev/null +++ b/notas/RPC_ISSUE.md @@ -0,0 +1,38 @@ +\# RPC issue (rayls\_devnet) + + + +Data/Hora: 01/02/2026 + +Projeto: qa-engineering-challenge-rayls + + + +\## Comando + +npx hardhat console --network rayls\_devnet + + + +\## Ação + +await ethers.provider.getBlockNumber() + + + +\## Resultado + +HH110: Invalid JSON-RPC response received: error code: 521 + + + +Observação: + +O projeto compila e o console inicia, mas a chamada ao RPC falha com 521 (instabilidade do endpoint). + +RPC configurado: https://devnet-rpc.rayls.com + +CHAIN\_ID: 123123 + + + diff --git a/notas/RPC_ISSUE_522.md b/notas/RPC_ISSUE_522.md new file mode 100644 index 0000000..d6c4d16 --- /dev/null +++ b/notas/RPC_ISSUE_522.md @@ -0,0 +1,48 @@ +\# RPC issue (rayls\_devnet) — error 522 + + + +Data/Hora: 01/02/2026 + +Projeto: qa-engineering-challenge-rayls + + + +\## Comando + +npx hardhat test --network rayls\_devnet + + + +\## Resultado + +HH110: Invalid JSON-RPC response received: error code: 522 + + + +Observação: + +Localmente (Hardhat network) os testes passam: `npx hardhat test` -> 14 passing. + +O erro ocorre somente ao apontar para o RPC da devnet. + + + +# RPC Issue (Rayls Devnet) — Error 522 / HH110 + +Data/Hora: 2026-02-01 (America/Sao_Paulo) + +Comando executado: +```powershell +npx hardhat test --network rayls_devnet +``` + + +Resultado: +HardhatError: HH110: Invalid JSON-RPC response received: error code: 522 + +Observação: + +Os testes locais (hardhat network) rodam com sucesso: npx hardhat test + +A falha ocorre antes do deploy/testes iniciarem (hook before each), devido à instabilidade do endpoint RPC. diff --git a/test/RaylsToken.test.ts b/test/RaylsToken.test.ts index 81bd0f1..88e0835 100644 --- a/test/RaylsToken.test.ts +++ b/test/RaylsToken.test.ts @@ -19,8 +19,8 @@ describe("RaylsToken", function () { describe("Deployment", function () { it("Should set the right name and symbol", async function () { - expect(await token.name()).to.equal("Rayls Token"); - expect(await token.symbol()).to.equal("RAYLS"); + expect(await token.name()).to.equal("Rayls Test Token"); + expect(await token.symbol()).to.equal("RYLSTEST"); }); it("Should set the right decimals", async function () {