hyperledger-web3j / web3j-unit

Smart contract testing framework via integrated EVM and various Ethereum clients
https://www.web3labs.com/epirus
Apache License 2.0
24 stars 23 forks source link

TransactionException with empty revert reason #55

Open jdreddaway opened 2 years ago

jdreddaway commented 2 years ago

TransactionException with empty revert reason

Steps To Reproduce

Here's my test:

package bounty_hunter_gradle

import kotlin.test.assertFailsWith
import com.google.common.truth.Truth.assertThat
import java.math.BigInteger
import java.time.Duration
import java.time.Instant
import org.junit.jupiter.api.Test
import org.web3j.EVMTest
import org.web3j.NodeType
import org.web3j.protocol.Web3j
import org.web3j.protocol.core.methods.response.TransactionReceipt
import org.web3j.protocol.exceptions.TransactionException
import org.web3j.tx.TransactionManager
import org.web3j.tx.gas.ContractGasProvider
import bounty_hunter_gradle.web3j.Bounties

@EVMTest(type = NodeType.EMBEDDED)
class AppTest {

  @Test
  fun shouldAnswerWithTrue(
    web3j: Web3j, transactionManager: TransactionManager, gasProvider: ContractGasProvider,
  ) {
    val bounties: Bounties = Bounties.deploy(web3j, transactionManager, gasProvider).send()
    val deadline: BigInteger = BigInteger.valueOf(Instant.now().plus(Duration.ofHours(1)).getEpochSecond())
    val send: TransactionReceipt  = bounties.issueBounty("test_bounty", deadline, BigInteger.valueOf(1000)).send()
    assertThat(send.getStatus()).isEqualTo("ok")
  }
}

Here's the contract: Bounties.sol.txt

Here's the test run details: index.html.txt

Expected behavior

The error message for TransactionException contains the reason the transaction failed.

Actual behavior

Here's the test output:

org.web3j.protocol.exceptions.TransactionException: Transaction 0x0d91b6a3ab8c18cfb2788d6bc3f67e3d7f59d46be96f4aa06dc4a83bb29b5697 has failed with status: 0x0. Gas used: 36782. Revert reason: ''.
    at app//org.web3j.tx.Contract.executeTransaction(Contract.java:419)
    at app//org.web3j.tx.Contract.executeTransaction(Contract.java:358)
    at app//org.web3j.tx.Contract.executeTransaction(Contract.java:352)
    at app//org.web3j.tx.Contract.lambda$executeRemoteCallTransaction$4(Contract.java:457)
    at app//org.web3j.protocol.core.RemoteCall.send(RemoteCall.java:42)
    at app//bounty_hunter_gradle.AppTest.shouldAnswerWithTrue(AppTest.kt:30)
...

Environment

JUnit test with the embedded EVM

_

Additional context

none

Julius278 commented 1 week ago

same issue here with web3j-core 4.12.2 web3j-unit 4.12.2 web3j-maven-plugin 4.12.1

image