Skip to main content

Woke is a Python-based development and testing framework for Solidity.

Project description

Woke

Woke is a Python-based development and testing framework for Solidity.

Features:

  • Testing framework - a testing framework for Solidity smart contracts with Python-native equivalents of Solidity types and blazing fast execution.

  • Fuzzer - a property-based fuzzer for Solidity smart contracts that allows testers to write their fuzz tests in Python.

  • Vulnerability detectors

  • LSP server

Dependencies

  • Python (version 3.7 or higher)

:warning: Python 3.11 is not supported yet.

Installation

via pip

pip3 install woke

Features

Testing framework

See examples and documentation for more information.

Writing tests is as simple as:

from woke.testing import *
from pytypes.contracts.Counter import Counter

@default_chain.connect()
def test_counter():
    default_chain.default_tx_account = default_chain.accounts[0]

    counter = Counter.deploy()
    assert counter.count() == 0

    counter.increment()
    assert counter.count() == 1

Fuzzer

Fuzzer builds on top of the testing framework and allows efficient fuzz testing of Solidity smart contracts.

from woke.testing import *
from woke.testing.fuzzing import *
from pytypes.contracts.Counter import Counter

class CounterTest(FuzzTest):
    def pre_sequence(self) -> None:
        self.counter = Counter.deploy()
        self.count = 0

    @flow()
    def increment(self) -> None:
        self.counter.increment()
        self.count += 1

    @flow()
    def decrement(self) -> None:
        with may_revert(Panic(PanicCodeEnum.UNDERFLOW_OVERFLOW)) as e:
            self.counter.decrement()

        if e.value is not None:
            assert self.count == 0
        else:
            self.count -= 1

    @invariant(period=10)
    def count(self) -> None:
        assert self.counter.count() == self.count

@default_chain.connect()
def test_counter():
    default_chain.default_tx_account = default_chain.accounts[0]
    CounterTest().run(sequences_count=30, flows_count=100)

Vulnerability detectors

Vulnerability detectors can be run using:

woke detect

LSP server

Woke implements an LSP server for Solidity. The only currently supported communication channel is TCP.

Woke LSP server can be run using:

woke lsp

Or with an optional --port argument:

woke lsp --port 1234

All LSP server features can be found in the documentation.

Documentation & Contribution

Woke documentation can be found here.

There you can also find a section on contributing.

License

This project is licensed under the ISC license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

woke-2.0.0rc2.tar.gz (248.5 kB view details)

Uploaded Source

Built Distribution

woke-2.0.0rc2-py3-none-any.whl (352.8 kB view details)

Uploaded Python 3

File details

Details for the file woke-2.0.0rc2.tar.gz.

File metadata

  • Download URL: woke-2.0.0rc2.tar.gz
  • Upload date:
  • Size: 248.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.7.12 Linux/6.1.9-1-MANJARO

File hashes

Hashes for woke-2.0.0rc2.tar.gz
Algorithm Hash digest
SHA256 14af5b69f0958e346eb022abbe7a4b62a19835aafe0a017e528d969b20ce87ae
MD5 e3e91b1afedd48186899f544f44f1962
BLAKE2b-256 5ef1d8fe3a1ca0cc00a66440bb6acbd1cf8953895db67e51e6e0fea09762d67b

See more details on using hashes here.

File details

Details for the file woke-2.0.0rc2-py3-none-any.whl.

File metadata

  • Download URL: woke-2.0.0rc2-py3-none-any.whl
  • Upload date:
  • Size: 352.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.7.12 Linux/6.1.9-1-MANJARO

File hashes

Hashes for woke-2.0.0rc2-py3-none-any.whl
Algorithm Hash digest
SHA256 0013a20182bdbf71ba5750428773107d19d5116ece39051932a76e898947050b
MD5 695fc49f2fde38520c6783ccd4f6fd21
BLAKE2b-256 d6b8c699cbe8487e537cfc12654da4626b312a4b887039f3059a64542e8570f8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page