dtr-org / unit-e

A digital currency for a new era of decentralized trust
https://unit-e.io
MIT License
45 stars 15 forks source link

proposer_stakable_balance.py is floating #940

Closed AM5800 closed 5 years ago

AM5800 commented 5 years ago

Flaked on travis in #908 but does not seem to be connected to the branch contents:

2019-04-11 07:50:12.622000 TestFramework (INFO): Waiting for nodes to have started up...
2019-04-11 07:50:12.622000 TestFramework (INFO): Checking that no node is proposing as no node has a peer right now
2019-04-11 07:50:12.633000 TestFramework (INFO): Connecting nodes
2019-04-11 07:50:13.868000 TestFramework (INFO): Waiting for nodes to be connected (should read NOT_PROPOSING_NOT_ENOUGH_BALANCE then)
2019-04-11 07:50:14.194000 TestFramework (INFO): The nodes with funds should advance to IS_PROPOSING
2019-04-11 07:50:14.217000 TestFramework (INFO): The others should stay in NOT_ENOUGH_BALANCE
2019-04-11 07:50:14.228000 TestFramework (ERROR): Assertion failed
Traceback (most recent call last):
  File "/home/travis/build/dtr-org/unit-e/build/unit-e-i686-pc-linux-gnu/test/functional/test_framework/test_framework.py", line 156, in main
    self.run_test()
  File "/home/travis/build/dtr-org/unit-e/build/unit-e-i686-pc-linux-gnu/test/functional/proposer_stakeable_balance.py", line 83, in run_test
    assert_equal(wallet['stakeable_balance'], Decimal('10000.00000000'))
  File "/home/travis/build/dtr-org/unit-e/build/unit-e-i686-pc-linux-gnu/test/functional/test_framework/util.py", line 41, in assert_equal
    raise AssertionError("not(%s)" % " == ".join(str(arg) for arg in (thing1, thing2) + args))
AssertionError: not(0E-8 == 10000.00000000)

full log

Nizametdinov commented 5 years ago

That's how it happened.

  1. After importing keys the nodes started proposing.
  2. One of the nodes actually proposed a block.
  3. Call to proposerstatus happened at the moment when the active chain had been updated with the newly proposed block but the wallet hadn't been updated. At that moment wallet contained only one coin which had been spent as a stake by the newly created block.
  4. wallet->GetBalance() returned 10000 UTE, wallet_extension.GetStakeableBalance() returned 0 UTE because pcoinsTip->HaveCoin returned false for the only coin in the wallet.
scravy commented 5 years ago

Doesn't https://github.com/dtr-org/unit-e/pull/953 help?

Nizametdinov commented 5 years ago

@scravy I think it doesn't. I will soon open a PR.