Skip to content

Commit

Permalink
✨ update test
Browse files Browse the repository at this point in the history
  • Loading branch information
MeditationDuck committed Oct 1, 2024
1 parent 7744226 commit dfc246f
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 9 deletions.
8 changes: 8 additions & 0 deletions wake/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

.wake
.env
pytypes
__pycache__/
*.py[cod]
.hypothesis/
wake-coverage.cov
Empty file added wake/scripts/__init__.py
Empty file.
8 changes: 8 additions & 0 deletions wake/scripts/deploy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from wake.deployment import *

NODE_URL = "ENTER_NODE_URL_HERE"


@default_chain.connect(NODE_URL)
def main():
default_chain.set_default_accounts(Account.from_alias("deployment"))
21 changes: 12 additions & 9 deletions wake/testing/fuzzing/fuzz_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def run(

snapshots = [chain.snapshot() for chain in chains]


set_sequence_initial_internal_state(
pickle.dumps(
random.getstate()
Expand Down Expand Up @@ -259,6 +260,7 @@ def run(

flow_state[j].before_inv_random_state = pickle.dumps(random.getstate())


if not dry_run:
self.pre_invariants()
for inv in invariants:
Expand All @@ -277,6 +279,8 @@ def run(
chain.revert(snapshot)
except Exception as e:
exception_content = e
print(type(e))
print(e)

## LOGGING EXCEPTION RESULT
# It could log only flow number,
Expand Down Expand Up @@ -357,15 +361,12 @@ def __init__(self):
exception = False # since it is not test exception
except Exception as e:
exception = True
# print("exception in ", j)
for snapshot, chain in zip(snapshots, chains):
chain.revert(snapshot)

def compare_exceptions(e1, e2):
print(type(e1))
print(type(e2))
if type(e1) != type(e2):
print("type not equal")
# print("type not equal")
return False

if type(e1) == Error and type(e2) == Error:
Expand Down Expand Up @@ -393,10 +394,11 @@ def compare_exceptions(e1, e2):
):
break

print(frame1)
print(frame2)
# print(frame1)
# print(frame2)
if frame1 is None or frame2 is None:
print("frame is none!!!!!!!!!!!!!!")
# return False
if frame1 is not None and frame2 is not None and (frame1.filename != frame2.filename
or frame1.lineno != frame2.lineno
or frame1.name != frame2.name
Expand All @@ -405,18 +407,19 @@ def compare_exceptions(e1, e2):
return True

# Check exception type and exception lines in the testing file.
ignore_flows = True

if self._flow_num == error_flow_num and compare_exceptions(e, exception_content):
if (ignore_flows or self._flow_num == error_flow_num) and compare_exceptions(e, exception_content):

# the removed flow is not required to reproduce same error. @ try remove next flow
print("remove worked!!, ", curr)
print("remove worked!!")
assert flow_state[curr].required == False
else:
print(e)
# the removing flow caused different error . @this flow should not removed restore current flow and remove next flow
flow_state[curr].required = True

print("remove failed!!, ", curr)
print("remove failed!!")

if exception == False:
for snapshot, chain in zip(snapshots, chains):
Expand Down
Empty file added wake/tests/__init__.py
Empty file.
11 changes: 11 additions & 0 deletions wake/tests/test_default.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from wake.testing import *

# Print failing tx call trace
# def revert_handler(e: TransactionRevertedError):
# if e.tx is not None:
# print(e.tx.call_trace)

@default_chain.connect()
# @on_revert(revert_handler)
def test_default():
pass
20 changes: 20 additions & 0 deletions wake/wake.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[compiler.solc]
exclude_paths = ["node_modules", "venv", ".venv", "lib", "script", "test"]
include_paths = ["node_modules"]

[detectors]
exclude = []
ignore_paths = ["venv", ".venv", "test"]
exclude_paths = ["node_modules", "lib", "script"]

[testing]
cmd = "anvil"

[testing.anvil]
cmd_args = "--prune-history 100 --transaction-block-keeper 10 --steps-tracing --silent"

[testing.ganache]
cmd_args = "-k istanbul -q"

[testing.hardhat]
cmd_args = ""

0 comments on commit dfc246f

Please sign in to comment.