Number can only safely store up to 53 bits

Sure thing, you mean creating a separate post in the Showcase topic or a different topic?

I'll also pushed the code to my GitHub. The test is here:

And the contract is here:

You may also need the token contract:

The whole test run fails before running any of the listed tests. It reads the describe('MyCrowdsale', function () { ... } and fails before completing the beforeEach hook.

2 Likes

Hi @Jshanks21,

The issue is caused by the addition:

this.openingTime:     1584460088
this.openingTime + 1: 15844600881

The OpenZeppelin Contract tests are great to see how to use OpenZeppelin Test Helpers

You could make the following change to your tests:

    this.openingTime = (await time.latest()).add(time.duration.weeks(1));
    this.closingTime = this.openingTime.add(time.duration.weeks(1));
1 Like

Thank you @abcoathup! The error makes sense when reading the test above. I’ll try running it this way when I have time today and let you know if it resolves the issue.

1 Like

I just tested it after updating it and the previous error was resolved. I see how concatenating these values could cause it to exceed the acceptable limit.

I’ll definitely be reading through these tests more closely to make mine more effective. Thanks again @abcoathup!

1 Like

I have one more question about some of the math in these tests: The syntax for .add .sub and .pow are very similar to the math functions from the SafeMath library.

Are these being called from the test-helpers file or are they already integrated as part of the test-environment? As far as I know, these aren’t native to JS so I’m just curious where we pulled them from, then I can take a closer look.

1 Like

Hi @Jshanks21,

OpenZeppelin Test Helpers uses BN.js.

BN.js has arithmetic functions add, sub, mul etc.

We can see a BN object being returned from latest in Test Helpers.

1 Like