aleeusgr / potential-robot

minimal dApp testing suite
MIT License
3 stars 0 forks source link

create testing scenarios/cases #117

Open aleeusgr opened 1 year ago

aleeusgr commented 1 year ago

vesting test scenarios:

Rachel for recipient Graham for Granter image

what are possible conditions for an unspendeable utxo?

aleeusgr commented 1 year ago

https://github.com/Hyperion-BT/helios/issues/89

const theNetwork = new NetworkEmulator();
const params = JSON.parse(await fs.readFile('./src/preprod.json', 'utf8'));
const emuParams = theNetwork.initNetworkParams(params)
emuParams.liveSlot;

this might help

const emuParams = theNetwork.initNetworkParams(params) // as
         // NetworkParams & {slotToTimestamp: typeof slotToTimestamp}
emuParams.timeToSlot = function(t) {
    const seconds = BigInt(t / 1000n)
    return seconds
}

//... could become useful(?):

// emuParams.slotToTimestamp = slotToTimestamp
// function slotToTimestamp (s : bigint) {
//     const num = parseInt(  BigInt.asIntN(52, s * 1000n).toString())
//     return new Date(num)
// }

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)
}
aleeusgr commented 1 year ago

One time cliff vesting can certainly be a supported scenario.

It is also common to have a smaller percentage on a cliff, then a continuing fractional vest through a longer period.

25 at one year then the remainder over next 3 years, for instance

aleeusgr commented 1 year ago

https://github.com/dubzzz/fast-check vs Helios fuzzy-test ?

https://www.youtube.com/watch?v=pF8HpKmaQi4

https://www.youtube.com/watch?v=n4IgYrc0pes&t=2157s