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

Test Failures (Int.ts) - rangeCheckHelper #174

Closed
MartinMinkov opened this issue May 23, 2022 · 0 comments · Fixed by #307
Closed

Test Failures (Int.ts) - rangeCheckHelper #174

MartinMinkov opened this issue May 23, 2022 · 0 comments · Fixed by #307
Assignees
Labels
bug Something isn't working

Comments

@MartinMinkov
Copy link
Contributor

MartinMinkov commented May 23, 2022

This issue is a tracker for all the test cases in int.test.ts that throws the rangeCheckHelper. Every test case that runs into this error has been replicated in this PR to make it easier to debug the different places rangeCheckHelper is throwing.

These bugs are surfaced from #164

UInt64

assertLt

// rangeCheckHelper: Expected 28948022309329048855892746252171976963363056481941560715954676764349967630336 to fit in 64 bits
it.skip("1<2=true", () => {
  expect(() => {
    Circuit.runAndCheck(() => {
      const x = Circuit.witness(UInt64, () => new UInt64(Field.one));
      const y = Circuit.witness(UInt64, () => new UInt64(Field(2)));
      x.assertLt(y);
    });
  }).not.toThrow();
});

// rangeCheckHelper: Expected 28948022309329048855892746252171976963363056481941560715954676764349967531337 to fit in 64 bits
it.skip("1000<100000=true", () => {
  expect(() => {
    Circuit.runAndCheck(() => {
      const x = Circuit.witness(UInt64, () => new UInt64(Field(1000)));
      const y = Circuit.witness(UInt64, () => new UInt64(Field(100000)));
      x.assertLt(y);
    });
  }).not.toThrow();
});

assertGt

it.skip("2>1=true", () => {
  expect(() => {
    Circuit.runAndCheck(() => {
      const x = Circuit.witness(UInt64, () => new UInt64(Field(2)));
      const y = Circuit.witness(UInt64, () => new UInt64(Field.one));
      x.assertGt(y);
    });
  }).not.toThrow();
});

lt

// rangeCheckHelper: Expected 28948022309329048855892746252171976963363056481941560715954676764349967630336 to fit in 64 bits
it.skip("1<2=true", () => {
  expect(new UInt64(Field.one).lt(new UInt64(Field(2)))).toEqual(Bool(true));
});

// rangeCheckHelper: Expected 28948022309329048855892746252171976963363056481941560715954676764349967531337 to fit in 64 bits
it.skip("1000<100000=true", () => {
  expect(new UInt64(Field(1000)).lt(new UInt64(Field(100000)))).toEqual(
    Bool(true)
  );
});

lte

it.skip("1000<=100000=true", () => {
  expect(new UInt64(Field(1000)).lte(new UInt64(Field(100000)))).toEqual(
    Bool(true)
  );
});

gt

// rangeCheckHelper: Expected 28948022309329048855892746252171976963363056481941560715954676764349967630336 to fit in 64 bits
        it.skip('2>1=true', () => {
          expect(new UInt64(Field(2)).gt(new UInt64(Field.one))).toEqual(
            Bool(true)
          );
        });
        
// rangeCheckHelper: Expected 28948022309329048855892746252171976963363056481941560715954676764349967630336 to fit in 64 bits
        it.skip('1>2=false', () => {
          expect(new UInt64(Field.one).lt(new UInt64(Field(2)))).toEqual(
            Bool(false)
          );
        });
        
// rangeCheckHelper: Expected 28948022309329048855892746252171976963363056481941560715954676764349967531337 to fit in 64 bits
        it.skip('100000>1000=true', () => {
          expect(new UInt64(Field(100000)).gt(new UInt64(Field(1000)))).toEqual(
            Bool(true)
          );
        });
        
// rangeCheckHelper: Expected 28948022309329048855892746252171976963363056481941560715954676764349967531337 to fit in 64 bits
        it('100000>1000=true', () => {
          expect(
            new UInt64(Field(100000)).assertGt(new UInt64(Field(1000)))
          ).not.toThrow();
        });

UInt32

assertLt

// rangeCheckHelper: Expected 28948022309329048855892746252171976963363056481941560715954676764349967531337 to fit in 64 bits
        it.skip('1000<100000=true', () => {
          expect(() => {
            Circuit.runAndCheck(() => {
              const x = Circuit.witness(UInt32, () => new UInt32(Field(1000)));
              const y = Circuit.witness(
                UInt32,
                () => new UInt32(Field(100000))
              );
              x.assertLt(y);
            });
          }).not.toThrow();

assertGt

// rangeCheckHelper: Expected 28948022309329048855892746252171976963363056481941560715954676764349967630336 to fit in 64 bits
it.skip("2>1=true", () => {
  expect(() => {
    Circuit.runAndCheck(() => {
      const x = Circuit.witness(UInt32, () => new UInt32(Field(2)));
      const y = Circuit.witness(UInt32, () => new UInt32(Field.one));
      x.assertGt(y);
    });
  }).not.toThrow();
});

// rangeCheckHelper: Expected 28948022309329048855892746252171976963363056481941560715954676764349967630336 to fit in 64 bits
it.skip("100000>1000=true", () => {
  expect(() => {
    Circuit.runAndCheck(() => {
      const x = Circuit.witness(UInt32, () => new UInt32(Field(100000)));
      const y = Circuit.witness(UInt32, () => new UInt32(Field(1000)));
      x.assertGt(y);
    });
  }).not.toThrow();
});

lt

// rangeCheckHelper: Expected 28948022309329048855892746252171976963363056481941560715954676764349967630336 to fit in 64 bits
it.skip("1<2=true", () => {
  expect(new UInt32(Field.one).lt(new UInt32(Field(2)))).toEqual(Bool(true));
});

// rangeCheckHelper: Expected 28948022309329048855892746252171976963363056481941560715954676764349967531337 to fit in 64 bits
it.skip("1000<100000=true", () => {
  expect(new UInt32(Field(1000)).lt(new UInt32(Field(100000)))).toEqual(
    Bool(true)
  );
});

lte

// rangeCheckHelper: Expected 28948022309329048855892746252171976963363056481941560715954676764349967531337 to fit in 64 bits
it.skip("1000<=100000=true", () => {
  expect(new UInt32(Field(1000)).lte(new UInt32(Field(100000)))).toEqual(
    Bool(true)
  );
});

gt

// rangeCheckHelper: Expected 28948022309329048855892746252171976963363056481941560715954676764349967630336 to fit in 64 bits
it.skip("2>1=true", () => {
  expect(new UInt32(Field(2)).gt(new UInt32(Field.one))).toEqual(Bool(true));
});

// rangeCheckHelper: Expected 28948022309329048855892746252171976963363056481941560715954676764349967630336 to fit in 64 bits
it.skip("1>2=false", () => {
  expect(new UInt32(Field.one).lt(new UInt32(Field(2)))).toEqual(Bool(false));
});

// rangeCheckHelper: Expected 28948022309329048855892746252171976963363056481941560715954676764349967531337 to fit in 64 bits
it.skip("100000>1000=true", () => {
  expect(new UInt32(Field(100000)).gt(new UInt32(Field(1000)))).toEqual(
    Bool(true)
  );
});

assertGt

// rangeCheckHelper: Expected 28948022309329048855892746252171976963363056481941560715954676764349967630336 to fit in 64 bits
it("2>1=true", () => {
  expect(new UInt32(Field(2)).assertGt(new UInt32(Field.one))).not.toThrow();
});

// rangeCheckHelper: Expected 28948022309329048855892746252171976963363056481941560715954676764349967531337 to fit in 64 bits
it("100000>1000=true", () => {
  expect(
    new UInt32(Field(100000)).assertGt(new UInt32(Field(1000)))
  ).not.toThrow();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants