Closed ailisp closed 3 years ago
Actually it's already doable
let root = init_simulator(...)
root.borrow_runtime_mut().produce_blocks(N)
Practically it doesn't work, for example, simulate produce_blocks(86400), I run it two fimes: First run it stuck for more than an hour, I don't know how many blocks it has produced. The second time, I added a println with in the produce_block, to see current block height. It took several seconds to reach block 5640, then it panicked due to invalid memory reference:
thread 'test_staking_reward' panicked at 'not within a catch_unsafe_unwind scope', /home/bo/.cargo/registry/src/github.com-1ecc6299db9ec823/wasmer-runtime-core-near-0.17.1/src/fault.rs:212:10
stack backtrace:
error: test failed, to rerun pass '-p art --test general'
Caused by:
process didn't exit successfully: `/home/bo/workspace/artificial-coin/art/target/debug/deps/general-b394ce9ac5486239 test_staking_reward --exact --nocapture` (signal: 11, SIGSEGV: invalid memory reference)
And this is quite reproducible. I rerun the test a few times, every time it panicked at block height 5640
I addressed time simulation problem with https://github.com/near/near-sdk-rs/pull/378, for this SIGSEGV: invalid memory reference error I'll open a different issue
In some cases we want to test things happen only after a specific amount of time, for example:
One way of doing this is let near-sdk-sim runtime process N empty blocks. It currently have way of process block but not exposed