Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Add execute state test
- Loading branch information
1 parent
08fa43a
commit 0b9bff1
Showing
2 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,5 @@ z3-solver>=4.5 | |
py-flags | ||
coverage | ||
pytest | ||
mock | ||
pytest_mock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import mock | ||
import pytest | ||
from pytest_mock import mocker | ||
from laser.ethereum.taint_analysis import * | ||
from laser.ethereum.svm import GlobalState | ||
|
||
|
||
def test_execute_state(mocker): | ||
record = TaintRecord() | ||
record.stack_record = { | ||
0: True, | ||
1: False, | ||
2: True | ||
} | ||
|
||
state = GlobalState | ||
mocker.patch.object(state, 'get_current_instruction') | ||
state.get_current_instruction.return_value = {"opcode": "ADD"} | ||
|
||
# Act | ||
TaintRunner.execute_state(record, state) | ||
|
||
# Assert | ||
assert list(record.stack_record.items()) == [(0, True), (1, True)] | ||
|
||
|