Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test harness / network emulator can't waitUntil a target time #89

Open
rjharmon opened this issue Jun 3, 2023 · 2 comments
Open

Test harness / network emulator can't waitUntil a target time #89

rjharmon opened this issue Jun 3, 2023 · 2 comments

Comments

@rjharmon
Copy link

rjharmon commented Jun 3, 2023

Tried to implement a waitUntil() for test environment:

function waitUntil(time: Date, network, params) {
    const targetSlot = params.timeToSlot(BigInt(time.getTime()))
    const current = params.liveSlot

    const slotsToWait = targetSlot - current;
    if (slotsToWait < 1) {
        throw new Error(`the indicated time is not in the future`)
    }
    // console.warn(`waiting ${slotsToWait} until ${time}`);

    network.tick(slotsToWait)
}

timeToSlot() fails on params.#raw (it's undefined).

Perhaps the network emulator should genesis at current time as of the call to network.initNetworkParams() (and require that it's still at slot 0)?

@christianschmitz
Copy link
Contributor

This is probably a good idea, the latestTip in the NetworkParams can be updated to current time.

@rjharmon
Copy link
Author

we've been letting slot 0 be epoch-time 0, and then timeToSlot uses timeMs / 1000

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

No branches or pull requests

2 participants