Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added negative tests #55

Merged
merged 2 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions pykwasm/src/pykwasm/call.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from eth_account import Account
from requests.exceptions import ConnectionError
from web3 import Web3
from web3.exceptions import BadFunctionCallOutput, Web3RPCError
from web3.exceptions import BadFunctionCallOutput, ContractLogicError, Web3RPCError
from web3.middleware import SignAndSendRawMiddlewareBuilder

ABI_MAP = {
Expand Down Expand Up @@ -98,11 +98,13 @@ def run_method(w3, contract, sender, eth, method, params):
else:
tx_hash = func.transact({'from': sender.address, 'value': eth})
result_or_receipt = w3.eth.wait_for_transaction_receipt(tx_hash)
except (ConnectionError, BadFunctionCallOutput, Web3RPCError) as e:
except (ConnectionError, ContractLogicError, BadFunctionCallOutput, Web3RPCError) as e:
if isinstance(e, (ConnectionError, ConnectionRefusedError)):
msg = f'Failed to connect to node: {e.message}'
elif isinstance(e, BadFunctionCallOutput):
msg = f'Could not interpret function output: {",".join(e.args)}'
elif isinstance(e, ContractLogicError):
msg = f'Contract logic error: {e.message}'
else:
msg = f'Node RPC encountered an error: {e.message}'
print(msg, file=sys.stderr)
Expand Down
4 changes: 2 additions & 2 deletions pykwasm/src/pykwasm/kdist/wasm-semantics/ulm-wasm.md
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ These rules define various integration points between the ULM and our Wasm inter
</ulmWasm>
...
</generatedTop>
) => #if OutVal ==K NO_OUTPUT #then EVMC_INTERNAL_ERROR #else Status #fi
) => #if Status ==Int EVMC_SUCCESS andBool OutVal ==K NO_OUTPUT #then EVMC_INTERNAL_ERROR #else Status #fi
```

Hooks implementation
Expand Down Expand Up @@ -629,7 +629,7 @@ Handle the actual hook calls.

rule
<instrs>
#fail(ulmBytes(BYTES:Bytes)) => #throwException(EVMC_FAILURE, Bytes2String(BYTES))
#fail(ulmBytes(BYTES:Bytes)) => #throwException(EVMC_REVERT, Bytes2String(BYTES))
...
</instrs>

Expand Down
Loading
Loading