Skip to content

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

@rjharmon

Description

@rjharmon

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)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions