Question to openzeppelin-test-helpers

Hi,

Im just reading through openZeppelin-test-helpers on git:

So going through openzeppelin-test-helpers/src/ balance.js

I read the test in OpenZeppelin/ openzeppelin-test-helpers

So I found the test:

 it('returns correct deltas after get() checkpoint', async function () {
      const tracker = await balance.tracker(receiver);
      await send.ether(sender, receiver, ether('1'));
      await tracker.get();
      await send.ether(sender, receiver, ether('1'));
      expect(await tracker.delta()).to.be.bignumber.equal(ether('1'));
    });

It seems the first await send.ether(sender, receiver, ether('1')); is not needed and my test also fits without it.

So is there any reason for this, or it it just something useless that does not disturb the logic?

So if this line does not take any effect, the next it-test is identical and does not seem to bring up a new test scenario

So the only reason I may think of is a test of concurrency or parallelism, e.g. that the commands are completet right in sequence. So as it is a test for a library it may makes sense. But I don't know

Hope this was the right place to ask,

Stefan

1 Like

Hi Stefan (@blexx),

Apologies, I completely manage to miss this discussion.
I think the #sdk category is fine (I coudn’t come up with a better category :smile:)

My understanding of the steps (my added comments) in the test are:

      // setup tracker
      const tracker = await balance.tracker(receiver);
      // transfer 1 ether (first transfer)
      await send.ether(sender, receiver, ether('1'));
      // checkpoint tracker
      await tracker.get();
      // transfer 1 ether (second transfer)
      await send.ether(sender, receiver, ether('1'));
      // check delta is 1 ether
      expect(await tracker.delta()).to.be.bignumber.equal(ether('1'));

I assume the first transfer is used to ensure there is a difference in balance between when the tracker is setup and the checkpoint. This means the balance is different before and after the checkpoint to better test the checkpoint, which is the purpose of this test.
Though the previous test get() adds a new checkpoint includes the first transfer so I can see an argument that this doesn’t need testing again.

abcoathup,
thank you very much.

Stefan

1 Like