TransactionException with empty revert reason
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
_
- Web3j version: 4.9.4
- Java or Android version: openjdk version "17.0.4.1" 2022-08-12 LTS
- Operating System: Ubuntu
Additional context
none
same issue here with web3j-core 4.12.2 web3j-unit 4.12.2 web3j-maven-plugin 4.12.1
The failing cause is because your smart contract it is using Strings.sol file from openzepelin which is using a solidity version higher than 0.8.19. The versions after this one are asking for a PUSH0 (0x5F) opcode comes with Shanghai fork.
At the moment @EvmTest spins one container which is able to run one network with PoA clique or PoW consensus that can run on only one node. In order to be able to support solidity versions > than 0.8.19 will need to run PoS consensus which can't be achieved with only one node in a container.
Looking forward to extend this behaviour in future. That's why I will keep this issue open.