Skip to content
This repository has been archived by the owner on Mar 11, 2024. It is now read-only.

Use promise to avoid race condition #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

adamdossa
Copy link

There is a small issue in the "should call a function that depends on a linked library" test, which means that:

assert.equal(metaCoinEthBalance, 2 * metaCoinBalance, "Library function returned unexpected function, linkage may be broken");

may be called before metaCoinEthBalance is set and fail. I see this fail sporadically, but the issue can be replicated by replacing:

metaCoinEthBalance = outCoinBalanceEth.toNumber();

with:

setTimeout(function() {metaCoinEthBalance = outCoinBalanceEth.toNumber();}, 1000);

Failure is then:

  1) Contract: MetaCoin should call a function that depends on a linked library:
     AssertionError: Library function returned unexpeced function, linkage may be broken: expected undefined to equal 20000
      at test/metacoin.js:25:14
      at process._tickCallback (internal/process/next_tick.js:103:7)

Issue is corrected by returning from inside the then statement and forcing the promise to chain correctly.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant