AdChain / AdChainRegistry

adChain registry smart contracts
Apache License 2.0
30 stars 10 forks source link

commitPeriodActive() always true #3

Closed miguelmota closed 7 years ago

miguelmota commented 7 years ago

block timestamp remains the same when calling constant functions such as revealPeriodActive(). When there's an active commit period and then afterwards when the commit period should be over, the revealPeriodActive() is always false when it should be true (commitPeriodActive() is always true because of block.timestamp) and user can't reveal. Need some sort "update()" method like in Registry.sol to mine a new block. Calling "updateStatus()" in Registry.sol throws an error during this phase.

skmgoldin commented 7 years ago

Ah. This is a testRPC issue, not a contract issue. TestRPC mines a block per-transaction, and not otherwise. Two possible solutions:

  1. Run testrpc with the -b <seconds> flag to make it mine blocks every arbitrary number of seconds.

  2. Use the testRPC special evm_mine RPC command. Here's an example of it being used in a slightly complex function that calls itself recursively to mine a specified number of blocks: https://github.com/skmgoldin/simple-token-sale/blob/master/test/sale.js#L120-L135

General documentation: https://github.com/ethereumjs/testrpc

miguelmota commented 7 years ago

evm_mime did the trick. Thanks!