Skip to content

Commit

Permalink
update helios to 0.16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
aleeusgr committed Aug 16, 2024
1 parent 9de02cf commit 693239c
Show file tree
Hide file tree
Showing 8 changed files with 294 additions and 326 deletions.
586 changes: 277 additions & 309 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"@hyperionbt/helios": "^0.14.0"
"@hyperionbt/helios": "^0.16.0"
},
"devDependencies": {
"@vitest/ui": "^0.30.1",
Expand Down
2 changes: 1 addition & 1 deletion tests/template.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe("a template", async () => {
// todo
expect(aliceUtxos[1].value.dump().lovelace).toBe('5000000')
// todo
expect(validatorHash.hex).toBe('e7015c6a1424d748f8241fe3a43b3a382b35dc9ca67320e3ee863dc8')
expect(validatorHash.hex).toBe('9f43610b85b6c39eca3cdaa7824d289871e4eb2cdea62ac8eba3c7e1')
})

it ("adds new code", async ({network, alice, validatorHash}) => {
Expand Down
6 changes: 3 additions & 3 deletions tests/time-props-vesting.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ describe("what happens when we add wait interval between lock and cancel?", asyn
expect((await alice.utxos)[1].value.dump().lovelace).toBe('50000000');

// https://www.hyperion-bt.org/helios-book/lang/builtins/validatorhash.html?highlight=valida#validatorhash
expect(validatorHash.hex).toBe('e7015c6a1424d748f8241fe3a43b3a382b35dc9ca67320e3ee863dc8')
expect(validatorHash.hex).toBe('9f43610b85b6c39eca3cdaa7824d289871e4eb2cdea62ac8eba3c7e1')


})
Expand All @@ -79,7 +79,7 @@ describe("what happens when we add wait interval between lock and cancel?", asyn
const duration = 1000000;
await lockAda(network!, alice!, bob!, program, adaQty, duration);
expect((await alice.utxos)[0].value.dump().lovelace).toBe('50000000');
expect((await alice.utxos)[1].value.dump().lovelace).toBe('9755287');
expect((await alice.utxos)[1].value.dump().lovelace).toBe('9756672');

// https://www.hyperion-bt.org/helios-book/api/reference/fuzzytest.html?highlight=fuzz#fuzzytest
network.tick(BigInt(10780));
Expand All @@ -89,7 +89,7 @@ describe("what happens when we add wait interval between lock and cancel?", asyn
const oracle = await alice.utxos;

// think about which is which.
expect(oracle[2].value.dump().lovelace).toBe('9546007');
expect(oracle[2].value.dump().lovelace).toBe('9545698');
expect(oracle[1].value.dump().lovelace).toBe('10000000');//
expect(oracle[0].value.dump().lovelace).toBe('50000000');// collateral?
})
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/mint-nft.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ describe("create a network with two wallets of which one has an nft", async () =
// https://www.hyperion-bt.org/helios-book/api/reference/address.html?highlight=Address#address
expect(alice.address.toHex().length).toBe(58)
expect((await alice.utxos)[0].value.dump().lovelace).toBe('2000000');
expect((await alice.utxos)[1].value.dump().lovelace).toBe('22753044');
expect((await alice.utxos)[1].value.dump().lovelace).toBe('22753661');
expect((await alice.utxos)[0].value.dump().assets[mph][616263]).toBe(amt.toString());
})

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/networkParams.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ describe("run a transaction on newly initialized params", async () => {
const networkParamsJSON = JSON.parse(networkParamsFile.toString());
const networkParams = new NetworkParams(networkParamsJSON);
const newNP = network.initNetworkParams(networkParams)
expect(newNP.slotToTime(BigInt(0))).toBe(1655683200000n);
expect(newNP.slotToTime(BigInt(0))).toBe(0n);
})
})
12 changes: 6 additions & 6 deletions tests/vesting-cancel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe("a vesting contract: Cancel transaction", async () => {
expect((await alice.utxos)[1].value.dump().lovelace).toBe('50000000');

// https://www.hyperion-bt.org/helios-book/lang/builtins/validatorhash.html?highlight=valida#validatorhash
expect(validatorHash.hex).toBe('e7015c6a1424d748f8241fe3a43b3a382b35dc9ca67320e3ee863dc8')
expect(validatorHash.hex).toBe('9f43610b85b6c39eca3cdaa7824d289871e4eb2cdea62ac8eba3c7e1')


})
Expand All @@ -76,14 +76,14 @@ describe("a vesting contract: Cancel transaction", async () => {
const duration = 1000000;
await lockAda(network!, alice!, bob!, program, adaQty, duration);
expect((await alice.utxos)[0].value.dump().lovelace).toBe('50000000');
expect((await alice.utxos)[1].value.dump().lovelace).toBe('9755287');
expect((await alice.utxos)[1].value.dump().lovelace).toBe('9756672');

await cancelVesting(network!, alice!, program );

const oracle = await alice.utxos;

// think about which is which.
expect(oracle[2].value.dump().lovelace).toBe('9546007');
expect(oracle[2].value.dump().lovelace).toBe('9545698');
expect(oracle[1].value.dump().lovelace).toBe('10000000');//
expect(oracle[0].value.dump().lovelace).toBe('50000000');// collateral?
})
Expand All @@ -105,12 +105,12 @@ describe("a vesting contract: Cancel transaction", async () => {
const duration = 1000000;
await lockAda(network!, alice!, bob!, program, adaQty, duration)
expect((await alice.utxos)[0].value.dump().lovelace).toBe('50000000');
expect((await alice.utxos)[1].value.dump().lovelace).toBe('9755287');
expect((await alice.utxos)[1].value.dump().lovelace).toBe('9756672');

const networkParamsFile = await fs.readFile('./src/preprod.json', 'utf8');
const networkParams = new NetworkParams(JSON.parse(networkParamsFile.toString()));

const keyMPH = '702cd6229f16532ca9735f65037092d099b0ff78a741c82db0847bbf'
const keyMPH = '6ecf3e6410cb049736a4d424a439887ad390cf6357ee2f2970a7f235'

const ownerAddress = alice.address;
const ownerUtxos = await alice.utxos;
Expand Down Expand Up @@ -155,7 +155,7 @@ describe("a vesting contract: Cancel transaction", async () => {
const oracle = await alice.utxos;

// think about which is which.
expect(oracle[2].value.dump().lovelace).toBe('9546007');
expect(oracle[2].value.dump().lovelace).toBe('9545698');
expect(oracle[1].value.dump().lovelace).toBe('10000000');//
expect(oracle[0].value.dump().lovelace).toBe('50000000');// collateral?
})
Expand Down
8 changes: 4 additions & 4 deletions tests/vesting-lock.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ describe("a vesting contract lockAda transaction", async () => {
// one utxo is unchanged, second has (10 ADA + txFee) less
expect((await alice.utxos)[0].value.dump().lovelace).toBe('5000000');
expect((await network.getUtxos(await alice.address))[0].value.dump().lovelace).toBe('5000000');
expect((await alice.utxos)[1].value.dump().lovelace).toBe('9755287');
expect((await alice.utxos)[1].value.dump().lovelace).toBe('9756672');

const validatorAddress = Address.fromValidatorHash(validatorHash);
// there exists a utxo that has a specified token locked at a validatorAddress.
expect(Object.keys((await network.getUtxos(validatorAddress))[0].value.dump().assets)[0]).toBe('702cd6229f16532ca9735f65037092d099b0ff78a741c82db0847bbf');
expect(Object.keys((await network.getUtxos(validatorAddress))[0].value.dump().assets)[0]).toBe('6ecf3e6410cb049736a4d424a439887ad390cf6357ee2f2970a7f235');
})
it ("reproduces lockAda tx", async ({network, alice, bob, validatorAddress}) => {
// https://github.com/lley154/helios-examples/blob/704cf0a92cfe252b63ffb9fd36c92ffafc1d91f6/vesting/pages/index.tsx#LL157C1-L280C4
Expand Down Expand Up @@ -160,12 +160,12 @@ describe("a vesting contract lockAda transaction", async () => {

// this should be consistent with previous test.
// alice has only one utxo:
expect((await alice.utxos)[0].value.dump().lovelace).toBe('14749259');
expect((await alice.utxos)[0].value.dump().lovelace).toBe('14750644');
// and the fee is different, compare L67
expect(14749259).not.to.equal(9755287+5000000);
expect((await alice.utxos)[1]).toBeUndefined();
// validator address holds Vesting Key
expect(mintProgram.mintingPolicyHash.hex).toBe('702cd6229f16532ca9735f65037092d099b0ff78a741c82db0847bbf');
expect(mintProgram.mintingPolicyHash.hex).toBe('6ecf3e6410cb049736a4d424a439887ad390cf6357ee2f2970a7f235');
expect(Object.keys((await network.getUtxos(validatorAddress))[0].value.dump().assets)[0]).toEqual(mintProgram.mintingPolicyHash.hex);

})
Expand Down

0 comments on commit 693239c

Please sign in to comment.