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

220
Views
No se pueden comparar los valores de ETH en una prueba de trufa

Estoy probando una función de pago de un contrato inteligente en Truffle, pero no puedo comparar los valores ETH:

Contrato inteligente

 uint256 public price; uint256 payment; constructor( uint256 _price, ) public payable { require( _price > 0, "The price has to be greater than 0." ); price = _price; } // The caller of the method should provide the correct amount of ETH as required. function pay() public payable { require( msg.value == price, "Incorrect price." ); payment = msg.value; }

Pruebas

 contract('Payment Test', (accounts) => { let contract, priceInput; beforeEach(async function () { priceInput = web3.utils.toWei("1", "ether"); contract = await MyContract.deployed(priceInput, { from: accounts[0] }); }); it("Successfully make a payment", async () => { try { // Using the same amount used in the constructor here "priceInput" await contract.pay({ from: accounts[1], value: priceInput }); } catch (e) { console.log(e) } // assertions }); })

Recibo el error de reversión:

'RuntimeError: Excepción de máquina virtual al procesar la transacción: revertir precio incorrecto.\n'

Probé literales numéricos como 100 , en lugar de web3.utils.toWei("1", "ether") , como el valor a pasar, pero obtuve el mismo resultado.

about 4 years ago · Juan Pablo Isaza
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!