From bed60360fc6731880359b0c64b25ae01a1fb3fc5 Mon Sep 17 00:00:00 2001 From: Afr Schoe <58883403+q9f@users.noreply.github.com> Date: Tue, 2 Jul 2024 17:10:09 +0200 Subject: [PATCH] eth/client: always return hash even if transaction didn't succeed --- lib/eth/abi/decoder.rb | 3 +-- lib/eth/client.rb | 4 ++-- spec/eth/client_spec.rb | 31 ++++++++++++++++++++++++------- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/lib/eth/abi/decoder.rb b/lib/eth/abi/decoder.rb index 35cf6baa..171e2263 100644 --- a/lib/eth/abi/decoder.rb +++ b/lib/eth/abi/decoder.rb @@ -54,19 +54,18 @@ def type(type, arg) elsif type.base_type == "tuple" offset = 0 data = {} + raise DecodingError, "Cannot decode tuples without known components" if type.components.nil? type.components.each do |c| if c.dynamic? pointer = Util.deserialize_big_endian_to_int arg[offset, 32] # Pointer to the size of the array's element data_len = Util.deserialize_big_endian_to_int arg[pointer, 32] # length of the element data[c.name] = type(c, arg[pointer, Util.ceil32(data_len) + 32]) - # puts data offset += 32 else size = c.size data[c.name] = type(c, arg[offset, size]) offset += size - # puts data end end data diff --git a/lib/eth/client.rb b/lib/eth/client.rb index 7b203b5b..edc24d92 100644 --- a/lib/eth/client.rb +++ b/lib/eth/client.rb @@ -315,11 +315,11 @@ def transact(contract, function, *args, **kwargs) # See {#transact} for params and overloads. # # @raise [Client::ContractExecutionError] if the execution fails. - # @return [Object] returns the result of the transaction. + # @return [Object, Boolean] returns the result of the transaction (hash and execution status). def transact_and_wait(contract, function, *args, **kwargs) begin hash = wait_for_tx(transact(contract, function, *args, **kwargs)) - return hash if tx_succeeded? hash + return hash, tx_succeeded?(hash) rescue IOError => e raise ContractExecutionError, e end diff --git a/spec/eth/client_spec.rb b/spec/eth/client_spec.rb index d5fe029d..de6f9d3c 100644 --- a/spec/eth/client_spec.rb +++ b/spec/eth/client_spec.rb @@ -14,6 +14,8 @@ # it expects an $INFURA_TOKEN in environment let(:infura_api) { "https://mainnet.infura.io/v3/#{ENV["INFURA_TOKEN"]}" } subject(:infura_mainnet) { Client.create infura_api } + let(:infura_api_base) { "https://base-mainnet.infura.io/v3/#{ENV["INFURA_TOKEN"]}" } + subject(:infura_base) { Client.create infura_api_base } describe ".create .initialize" do it "creates an ipc client" do @@ -277,7 +279,8 @@ it "transacts with gas limit override" do address = geth_http.deploy_and_wait(test_contract) - txn_hash = geth_http.transact_and_wait(test_contract, "set", 12, 24, address: address, gas_limit: 100_000_000) + txn_hash, txn_status = geth_http.transact_and_wait(test_contract, "set", 12, 24, address: address, gas_limit: 100_000_000) + expect(txn_status).to be_truthy response = geth_http.eth_get_transaction_by_hash(txn_hash) response = geth_http.call(test_contract, "get") expect(response).to eq([12, 24]) @@ -289,6 +292,15 @@ result = geth_http.call(contract, "greet", address: address) expect(result).to eq("Hello!") end + + it "calls a lendingpool contract on base returning tuple abi" do + pending("https://github.com/q9f/eth.rb/issues/273") + adr = Address.new "0xbb505c54d71e9e599cb8435b4f0ceec05fc71cbd" + nam = "LendingPool" + abi = '[{"inputs":[{"internalType":"address","name":"_addressRegistry","type":"address"},{"internalType":"address","name":"_WETH9","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"reserveId","type":"uint256"},{"indexed":true,"internalType":"address","name":"contractAddress","type":"address"},{"indexed":true,"internalType":"address","name":"onBehalfOf","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Borrow","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"reserveId","type":"uint256"},{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"onBehalfOf","type":"address"},{"indexed":false,"internalType":"uint256","name":"reserveAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"eTokenAmount","type":"uint256"},{"indexed":true,"internalType":"uint16","name":"referral","type":"uint16"}],"name":"Deposited","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"vaultId","type":"uint256"},{"indexed":true,"internalType":"address","name":"vaultAddress","type":"address"}],"name":"DisableVaultToBorrow","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"vaultId","type":"uint256"},{"indexed":true,"internalType":"address","name":"vaultAddress","type":"address"}],"name":"EnableVaultToBorrow","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"reserve","type":"address"},{"indexed":true,"internalType":"address","name":"eTokenAddress","type":"address"},{"indexed":false,"internalType":"address","name":"stakingAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"}],"name":"InitReserve","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"reserveId","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"eTokenAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"underlyingTokenAmount","type":"uint256"}],"name":"Redeemed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"reserveId","type":"uint256"},{"indexed":true,"internalType":"address","name":"onBehalfOf","type":"address"},{"indexed":true,"internalType":"address","name":"contractAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Repay","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"reserveId","type":"uint256"}],"name":"ReserveActivated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"reserveId","type":"uint256"}],"name":"ReserveBorrowDisabled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"reserveId","type":"uint256"}],"name":"ReserveBorrowEnabled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"reserveId","type":"uint256"}],"name":"ReserveDeActivated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"reserveId","type":"uint256"}],"name":"ReserveFrozen","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"reserveId","type":"uint256"}],"name":"ReserveUnFreeze","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"vaultId","type":"uint256"},{"indexed":true,"internalType":"address","name":"vaultAddress","type":"address"},{"indexed":true,"internalType":"uint256","name":"reserveId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"credit","type":"uint256"}],"name":"SetCreditsOfVault","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"reserveId","type":"uint256"},{"indexed":false,"internalType":"uint16","name":"utilizationA","type":"uint16"},{"indexed":false,"internalType":"uint16","name":"borrowingRateA","type":"uint16"},{"indexed":false,"internalType":"uint16","name":"utilizationB","type":"uint16"},{"indexed":false,"internalType":"uint16","name":"borrowingRateB","type":"uint16"},{"indexed":false,"internalType":"uint16","name":"maxBorrowingRate","type":"uint16"}],"name":"SetInterestRateConfig","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"reserveId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"cap","type":"uint256"}],"name":"SetReserveCapacity","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"reserveId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"feeRate","type":"uint256"}],"name":"SetReserveFeeRate","type":"event"},{"anonymous":false,"inputs":[],"name":"UnPaused","type":"event"},{"inputs":[],"name":"WETH9","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"reserveId","type":"uint256"}],"name":"activateReserve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"addressRegistry","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"onBehalfOf","type":"address"},{"internalType":"uint256","name":"debtId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"borrow","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"reserveId","type":"uint256"}],"name":"borrowingRateOfReserve","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"borrowingWhiteList","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"credits","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"reserveId","type":"uint256"}],"name":"deActivateReserve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"debtPositions","outputs":[{"internalType":"uint256","name":"reserveId","type":"uint256"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"borrowed","type":"uint256"},{"internalType":"uint256","name":"borrowedIndex","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"reserveId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"onBehalfOf","type":"address"},{"internalType":"uint16","name":"referralCode","type":"uint16"}],"name":"deposit","outputs":[{"internalType":"uint256","name":"eTokenAmount","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"reserveId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"onBehalfOf","type":"address"},{"internalType":"uint16","name":"referralCode","type":"uint16"}],"name":"depositAndStake","outputs":[{"internalType":"uint256","name":"eTokenAmount","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"reserveId","type":"uint256"}],"name":"disableBorrowing","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"vaultId","type":"uint256"}],"name":"disableVaultToBorrow","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"emergencyPauseAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"reserveId","type":"uint256"}],"name":"enableBorrowing","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"vaultId","type":"uint256"}],"name":"enableVaultToBorrow","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"reserveId","type":"uint256"}],"name":"exchangeRateOfReserve","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"reserveId","type":"uint256"}],"name":"freezeReserve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"debtId","type":"uint256"}],"name":"getCurrentDebt","outputs":[{"internalType":"uint256","name":"currentDebt","type":"uint256"},{"internalType":"uint256","name":"latestBorrowingIndex","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"reserveId","type":"uint256"}],"name":"getETokenAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"reserveIdArr","type":"uint256[]"},{"internalType":"address","name":"user","type":"address"}],"name":"getPositionStatus","outputs":[{"components":[{"internalType":"uint256","name":"reserveId","type":"uint256"},{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"eTokenStaked","type":"uint256"},{"internalType":"uint256","name":"eTokenUnStaked","type":"uint256"},{"internalType":"uint256","name":"liquidity","type":"uint256"}],"internalType":"struct ILendingPool.PositionStatus[]","name":"statusArr","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"debtId","type":"uint256"}],"name":"getReserveIdOfDebt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"reserveIdArr","type":"uint256[]"}],"name":"getReserveStatus","outputs":[{"components":[{"internalType":"uint256","name":"reserveId","type":"uint256"},{"internalType":"address","name":"underlyingTokenAddress","type":"address"},{"internalType":"address","name":"eTokenAddress","type":"address"},{"internalType":"address","name":"stakingAddress","type":"address"},{"internalType":"uint256","name":"totalLiquidity","type":"uint256"},{"internalType":"uint256","name":"totalBorrows","type":"uint256"},{"internalType":"uint256","name":"exchangeRate","type":"uint256"},{"internalType":"uint256","name":"borrowingRate","type":"uint256"}],"internalType":"struct ILendingPool.ReserveStatus[]","name":"statusArr","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"reserveId","type":"uint256"}],"name":"getStakingAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"reserveId","type":"uint256"}],"name":"getUnderlyingTokenAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"initReserve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"reserveId","type":"uint256"}],"name":"newDebtPosition","outputs":[{"internalType":"uint256","name":"debtId","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"nextDebtPositionId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nextReserveId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"reserveId","type":"uint256"},{"internalType":"uint256","name":"eTokenAmount","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"bool","name":"receiveNativeETH","type":"bool"}],"name":"redeem","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"onBehalfOf","type":"address"},{"internalType":"uint256","name":"debtId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"repay","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"reserves","outputs":[{"internalType":"uint256","name":"borrowingIndex","type":"uint256"},{"internalType":"uint256","name":"currentBorrowingRate","type":"uint256"},{"internalType":"uint256","name":"totalBorrows","type":"uint256"},{"internalType":"address","name":"underlyingTokenAddress","type":"address"},{"internalType":"address","name":"eTokenAddress","type":"address"},{"internalType":"address","name":"stakingAddress","type":"address"},{"internalType":"uint256","name":"reserveCapacity","type":"uint256"},{"components":[{"internalType":"uint128","name":"utilizationA","type":"uint128"},{"internalType":"uint128","name":"borrowingRateA","type":"uint128"},{"internalType":"uint128","name":"utilizationB","type":"uint128"},{"internalType":"uint128","name":"borrowingRateB","type":"uint128"},{"internalType":"uint128","name":"maxBorrowingRate","type":"uint128"}],"internalType":"struct DataTypes.InterestRateConfig","name":"borrowingRateConfig","type":"tuple"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint128","name":"lastUpdateTimestamp","type":"uint128"},{"internalType":"uint16","name":"reserveFeeRate","type":"uint16"},{"components":[{"internalType":"bool","name":"isActive","type":"bool"},{"internalType":"bool","name":"frozen","type":"bool"},{"internalType":"bool","name":"borrowingEnabled","type":"bool"}],"internalType":"struct DataTypes.Flags","name":"flags","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"reserveId","type":"uint256"},{"internalType":"uint16","name":"utilizationA","type":"uint16"},{"internalType":"uint16","name":"borrowingRateA","type":"uint16"},{"internalType":"uint16","name":"utilizationB","type":"uint16"},{"internalType":"uint16","name":"borrowingRateB","type":"uint16"},{"internalType":"uint16","name":"maxBorrowingRate","type":"uint16"}],"name":"setBorrowingRateConfig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"vaultId","type":"uint256"},{"internalType":"uint256","name":"reserveId","type":"uint256"},{"internalType":"uint256","name":"credit","type":"uint256"}],"name":"setCreditsOfVault","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"reserveId","type":"uint256"},{"internalType":"uint256","name":"cap","type":"uint256"}],"name":"setReserveCapacity","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"reserveId","type":"uint256"},{"internalType":"uint16","name":"_rate","type":"uint16"}],"name":"setReserveFeeRate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"reserveId","type":"uint256"}],"name":"totalBorrowsOfReserve","outputs":[{"internalType":"uint256","name":"totalBorrows","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"reserveId","type":"uint256"}],"name":"totalLiquidityOfReserve","outputs":[{"internalType":"uint256","name":"totalLiquidity","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"reserveId","type":"uint256"}],"name":"unFreezeReserve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unPauseAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"reserveId","type":"uint256"},{"internalType":"uint256","name":"eTokenAmount","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"bool","name":"receiveNativeETH","type":"bool"}],"name":"unStakeAndWithdraw","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"reserveId","type":"uint256"}],"name":"utilizationRateOfReserve","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]' + lending_pool = Contract.from_abi(name: nam, address: adr, abi: abi) + infura_base.call(lending_pool, "getReserveStatus", [64]) + end end describe ".transact .transact_and_wait" do @@ -315,20 +327,23 @@ it "transact the function with key" do geth_http.transfer_and_wait(test_key.address, 1337 * Unit::ETHER) address = geth_http.deploy_and_wait(contract, sender_key: test_key) - response = geth_http.transact_and_wait(contract, "set", 42, sender_key: test_key, address: address) + response, status = geth_http.transact_and_wait(contract, "set", 42, sender_key: test_key, address: address) + expect(status).to be_truthy expect(response).to start_with "0x" end it "transact the function using legacy transactions" do address = geth_http.deploy_and_wait(contract) - response = geth_http.transact_and_wait(contract, "set", 42, legacy: true, address: address) + response, status = geth_http.transact_and_wait(contract, "set", 42, legacy: true, address: address) + expect(status).to be_truthy expect(response).to start_with "0x" end it "transacts the function with constructor params" do contract = Contract.from_file(file: "spec/fixtures/contracts/greeter.sol", contract_index: 0) address = geth_http.deploy_and_wait(contract, "Hello!") - response = geth_http.transact_and_wait(contract, "setGreeting", "How are you?", address: address) + response, status = geth_http.transact_and_wait(contract, "setGreeting", "How are you?", address: address) + expect(status).to be_truthy expect(response).to start_with "0x" end @@ -336,7 +351,8 @@ geth_http.transfer_and_wait(test_key.address, 0.01 * Unit::ETHER) address = geth_http.deploy_and_wait(contract, sender_key: test_key) tx_value = 1 - tx_hash = geth_http.transact_and_wait(contract, "set", 42, sender_key: test_key, address: address, tx_value: tx_value) + tx_hash, tx_status = geth_http.transact_and_wait(contract, "set", 42, sender_key: test_key, address: address, tx_value: tx_value) + expect(tx_status).to be_truthy tx_value_from_server = geth_http.eth_get_transaction_by_hash(tx_hash)["result"]["value"].to_i(16) expect(tx_value_from_server).to eq(tx_value) end @@ -354,11 +370,12 @@ it "raises if a transaction fails" do addr = geth_http.deploy_and_wait(contract) - hash = geth_http.transact_and_wait(contract, "set", 42, address: addr) + hash, status = geth_http.transact_and_wait(contract, "set", 42, address: addr) + expect(status).to be_truthy expect(geth_http.tx_mined? hash).to be_truthy expect(geth_http.tx_succeeded? hash).to be_truthy expect { - hash = geth_http.transact_and_wait(contract, "set", 138, address: addr) + hash, status = geth_http.transact_and_wait(contract, "set", 138, address: addr) }.to raise_error(Client::ContractExecutionError, "execution reverted") end