Skip to content

Commit

Permalink
Fix broken test
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsc2 committed Sep 28, 2023
1 parent 0aaf96e commit e6f8acc
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
9 changes: 3 additions & 6 deletions pkg/hints/bigint_hint.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package hints

import (
"errors"
"fmt"
"math/big"

. "github.com/lambdaclass/cairo-vm.go/pkg/hints/hint_utils"
Expand Down Expand Up @@ -64,7 +63,7 @@ func NondetBigInt3(vm VirtualMachine, execScopes ExecutionScopes, idsData IdsMan
/// ids.flag = 1 if k > 0 else 0
/// ```

func SafeDivBigint(vm VirtualMachine, execScopes ExecutionScopes, idsData IdsManager) error {
func SafeDivBigint(vm *VirtualMachine, execScopes *ExecutionScopes, idsData IdsManager) error {
resUncast, err := execScopes.Get("res")
if err != nil {
return err
Expand Down Expand Up @@ -104,9 +103,7 @@ func SafeDivBigint(vm VirtualMachine, execScopes ExecutionScopes, idsData IdsMan
param_x := new(big.Int).Mul(&res, &y)
param_x.Sub(param_x, &x)

fmt.Println("param x: ",param_x)
k, err := SafeDivBig(param_x, &p)
fmt.Println("k", k)
if err != nil {
return err
}
Expand All @@ -123,11 +120,11 @@ func SafeDivBigint(vm VirtualMachine, execScopes ExecutionScopes, idsData IdsMan
flag = lambdaworks.FeltFromUint(0)
}

execScopes.AssignOrUpdateVariable("k", k)
execScopes.AssignOrUpdateVariable("k", *k)
execScopes.AssignOrUpdateVariable("value", value)

val := memory.NewMaybeRelocatableFelt(flag)
idsData.Insert("flag", val, &vm)
idsData.Insert("flag", val, vm)

return nil
}
1 change: 0 additions & 1 deletion pkg/hints/bigint_hint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ func TestSafeDivBigInt(t *testing.T) {
if err != nil {
t.Errorf("%s", err)
}

value, _ := valUncast.(big.Int)

if expectedK.Cmp(&k) != 0 {
Expand Down
2 changes: 1 addition & 1 deletion pkg/hints/hint_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func (p *CairoVmHintProcessor) ExecuteHint(vm *vm.VirtualMachine, hintData *any,
case FAST_EC_ADD_ASSIGN_NEW_Y:
return fastEcAddAssignNewY(execScopes)
case BIGINT_SAFE_DIV:
return SafeDivBigint(*vm, *execScopes, data.Ids)
return SafeDivBigint(vm, execScopes, data.Ids)
default:
return errors.Errorf("Unknown Hint: %s", data.Code)
}
Expand Down

0 comments on commit e6f8acc

Please sign in to comment.