Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

155
Views
Pruebas unitarias Solidity JS

Quiero probar estos 3 requisitos diferentes en mi función de menta con Javascript.

 function mint(uint256 _mintAmount) public payable { require(_mintAmount > 0, "need to mint at least 1 NFT"); require(_mintAmount <= maxMintAmount, "max mint amount per session exceeded"); require(supply + _mintAmount <= maxSupply, "max NFT limit exceeded");

Soy realmente nuevo en las pruebas, así que probé algo como esto. obviamente está mal, pero ¿cómo puedo probar que _mintAmount <= maxMintAmount en una función como esta?

 it('mint amount', async () =>{ _mintAmount > 0; _mintAmount <= maxMintAmount; supply + _mintAmount <= maxSupply; })
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

terminó haciendo esto,

ya que todos los cheques ya estaban en mi funcion mint. mint (0) devolvería "necesita acuñar al menos 1 NFT", así que usé assert.equal () para eso. Al usar try/catch para obtener el mensaje de error de reversión, verifico el resultado esperado para cualquier entrada que desee.

 it('mint amount', async function () { try { await NFT.mint.sendTransaction(0); } catch (err) { assert.equal("need to mint at least 1 NFT", err.reason); } }); it('mint amount2', async function () { try { await NFT.mint.sendTransaction(1); } catch (err) { assert.equal("max mint amount per session exceeded", err.reason); } }); it('mint amount3', async function () { try { await NFT.mint.sendTransaction(2); } catch (err) { assert.equal("max NFT limit exceeded", err.reason); } });
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!