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 1 commit
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
5 changes: 4 additions & 1 deletion 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 @@ -107,6 +107,9 @@ def run_method(w3, contract, sender, eth, method, params):
msg = f'Node RPC encountered an error: {e.message}'
print(msg, file=sys.stderr)
sys.exit(1)
except ContractLogicError as e:
print(f'Contract logic error: {e.message}', file=sys.stderr)
sys.exit(1)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the right logic, but I have a slight preference to put it in the if/then/else statement above since it shares the same logic by:

  1. adding the ContractLogicError to the tuple of caught errors and;
  2. adding a new case to the if/then/else statement for printing its message


return (view_like, result_or_receipt)

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