Skip to content

Commit

Permalink
fix: cetLocktime must be before refundlocktime test
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewjablack committed Mar 14, 2024
1 parent c74967d commit 82ed846
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions tests/integration/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,9 @@ async function importAddresses(chain: Chain): Promise<void> {
return chain.client.getMethod('importAddresses')();
}

async function mineBlock(): Promise<void> {
async function mineBlock(numBlocks = 1): Promise<void> {
try {
await chains.bitcoinWithNode.client.chain.generateBlock(1);
await chains.bitcoinWithNode.client.chain.generateBlock(numBlocks);
} catch (e) {
if (!(e instanceof errors.UnimplementedMethodError)) throw e;
console.log(
Expand Down
11 changes: 6 additions & 5 deletions tests/integration/dlc/custom-oracle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
buildRoundingIntervalsFromIntervals,
DualFundingTxFinalizer,
LinearPayout,
PolynomialPayoutCurve,
} from '@node-dlc/core';
import {
ContractDescriptorV1,
Expand Down Expand Up @@ -38,7 +37,7 @@ import {
SignDlcAcceptResponse,
} from '../../../packages/bitcoin-dlc-provider';
import { BatchSignDlcAcceptResponse } from '../../../packages/bitcoin-dlc-provider/lib';
import { chains, getInput } from '../common';
import { chains, getInput, mineBlock } from '../common';
import Oracle from '../models/Oracle';
import {
EnginePayout,
Expand Down Expand Up @@ -556,7 +555,7 @@ describe('Custom Strategy Oracle POC numdigits=21', () => {
event.oracleNonces = oliviaInfo.rValues.map((rValue) =>
Buffer.from(rValue, 'hex'),
);
event.eventMaturityEpoch = 1617170572;
event.eventMaturityEpoch = Math.floor(new Date().getTime() / 1000);
event.eventDescriptor = eventDescriptor;
event.eventId = eventId;

Expand Down Expand Up @@ -593,8 +592,8 @@ describe('Custom Strategy Oracle POC numdigits=21', () => {
BitcoinNetworks.bitcoin_regtest,
);

const cetLocktime = 1617170572;
const refundLocktime = 1617170573;
const cetLocktime = Math.floor(new Date().getTime() / 1000);
const refundLocktime = Math.floor(new Date().getTime() / 1000) + 1;

const tempDlcOffer = await alice.dlc.createDlcOffer(
offer.contractInfo,
Expand Down Expand Up @@ -732,6 +731,8 @@ describe('Custom Strategy Oracle POC numdigits=21', () => {
eventId,
);

await mineBlock(6);

const cet = await bob.dlc.execute(
dlcOffer,
dlcAccept,
Expand Down

0 comments on commit 82ed846

Please sign in to comment.