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

make op_div behave like mempool and post soft-fork #113

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 4 additions & 4 deletions clvm/more_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,10 @@ def op_div(args):
cost += (l0 + l1) * DIV_COST_PER_BYTE
q, r = divmod(i0, i1)

# this is to preserve a buggy behavior from the initial implementation
# of this operator.
if q == -1 and r != 0:
q += 1
if i0 < 0:
raise EvalError("div with negative operand", args.to(i0))
if i1 < 0:
raise EvalError("div with negative operand", args.to(i1))

return malloc_cost(cost, args.to(q))

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
]

dev_dependencies = [
"clvm_tools>=0.4.2",
"clvm_tools>=0.4.4",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe the tests rely on the most recent version of clvm_tools now, since we changed the cost reporting

"pytest",
]

Expand Down
3 changes: 1 addition & 2 deletions tests/brun/div-2.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
brun -c '(/ 2 5)' '(-80001 73)'
cost = 1125
-1096
FAIL: div with negative operand 0xfec77f
3 changes: 1 addition & 2 deletions tests/brun/div-3.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
brun -c '(/ 2 5)' '(80001 -73)'
cost = 1125
-1096
FAIL: div with negative operand -73
3 changes: 1 addition & 2 deletions tests/brun/div-7.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
brun -c '(/ (q . -3) (q . 10))'
cost = 1037
()
FAIL: div with negative operand -3
3 changes: 1 addition & 2 deletions tests/brun/div-8.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
brun -c '(/ (q . 3) (q . -10))'
cost = 1037
()
FAIL: div with negative operand -10
3 changes: 1 addition & 2 deletions tests/brun/div-9.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
brun -c '(/ (q . -3) (q . -10))'
cost = 1037
()
FAIL: div with negative operand -3
2 changes: 1 addition & 1 deletion tests/edge-cases/div-07.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
brun '(/ (q . 0xffff) (q . 0xffff))'
1
FAIL: div with negative operand -1
2 changes: 1 addition & 1 deletion tests/edge-cases/div-09.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
brun '(/ (q . -1) (q . -1))'
1
FAIL: div with negative operand -1