Skip to content

Commit

Permalink
refactor(lockAda): change input parameters for consistency
Browse files Browse the repository at this point in the history
BREAKING CHANGE:
  • Loading branch information
aleeusgr committed Jun 14, 2023
1 parent 492ddd0 commit 66a1029
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/vesting-lock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@ export const lockAda = async (
network: NetworkEmulator,
alice : WalletEmulator,
bob : WalletEmulator,
validatorHash: ValidatorHash,
program: Program,
adaQty : number,
duration : number
) => {

const optimize = false; // isnt there a way to set it globally?
const compiledScript = program.compile(optimize);
const validatorHash = compiledScript.validatorHash;
const validatorAddress = Address.fromValidatorHash(validatorHash);

const benAddr = bob.address;
const networkParamsFile = await fs.readFile('./src/preprod.json', 'utf8');
const networkParams = new NetworkParams(JSON.parse(networkParamsFile.toString()));
Expand Down Expand Up @@ -77,7 +81,6 @@ export const lockAda = async (
)
}`

const optimize = false; //maybe add to test context?
const mintProgram = Program.new(mintScript).compile(optimize);

tx.attachScript(mintProgram);
Expand Down
5 changes: 3 additions & 2 deletions tests/vesting-lock.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ describe("a vesting contract lockAda transaction", async () => {
const validatorHash = compiledProgram.validatorHash;
const validatorAddress = Address.fromValidatorHash(validatorHash);

context.program = program;
context.validatorHash = validatorHash;
context.validatorAddress = Address.fromValidatorHash(validatorHash);
context.programName = program.name;
Expand Down Expand Up @@ -157,10 +158,10 @@ describe("a vesting contract lockAda transaction", async () => {

})

it ("tests lockAda tx import", async ({network, alice, bob, validatorHash}) => {
it ("tests lockAda tx import", async ({network, alice, bob,validatorHash, program}) => {
const adaQty = 10 ;
const duration = 10000000;
await lockAda(network!, alice!, bob!, validatorHash, adaQty, duration)
await lockAda(network!, alice!, bob!, program, adaQty, duration)

const validatorAddress = Address.fromValidatorHash(validatorHash);
expect((await alice.utxos)[0].value.dump().lovelace).toBe('5000000');
Expand Down

0 comments on commit 66a1029

Please sign in to comment.