Skip to content

Commit

Permalink
✨ Add tests template
Browse files Browse the repository at this point in the history
  • Loading branch information
jaczkal committed Sep 19, 2023
1 parent 9563d8e commit 165e091
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
Empty file added tests/__init__.py
Empty file.
38 changes: 38 additions & 0 deletions tests/test_default.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import time
from woke.testing import *

from pytypes.contracts.Dungeon import Dungeon

'''
Write your exploit here. Always act like in production,
do not alter the chain anyhow.
'''
def exploit(dungeon: Dungeon, hackeer: Account):
pass


def subtitles(tx: TransactionAbc):
for event in tx.events:
if isinstance(event, Dungeon.Subtitles):
print(f"--- {event.subtitles} ---")


def revert_handler(e: TransactionRevertedError):
if e.tx is not None:
print(e.tx.call_trace)
print(e.tx.console_logs)


@default_chain.connect()
@on_revert(revert_handler)
def test_hackee():
default_chain.set_default_accounts(default_chain.accounts[0])
default_chain.tx_callback = subtitles
dungeon_master=default_chain.accounts[1] # do not touch
hackeer=default_chain.accounts[2] # this is you

dungeon = Dungeon.deploy(from_=dungeon_master)

exploit(dungeon, hackeer)

print(f"You managed to gain: {dungeon.evaluate(hackeer)} dungeon tokens.")

0 comments on commit 165e091

Please sign in to comment.