Skip to content

Commit

Permalink
fix: assertion for broadcast tx
Browse files Browse the repository at this point in the history
  • Loading branch information
DhananjayPurohit committed Jul 3, 2024
1 parent b6aaa74 commit 18cd851
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions clients/apps/nodejs/test_basic_workflow2.js
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ async function transferSendAtCoinExpiry(clientConfig, wallet_1_name, wallet_2_na

console.log("coin: ", coin);

const electrumClient = await mercurynodejslib.getElectrumClient(clientConfig);
const electrumClient = await getElectrumClient(clientConfig);

const blockHeader = await electrumClient.request('blockchain.headers.subscribe'); // request(promise)
const currentBlockheight = blockHeader.height;
Expand Down Expand Up @@ -974,7 +974,7 @@ async function transferReceiveAtCoinExpiry(clientConfig, wallet_1_name, wallet_2

coin = await mercurynodejslib.transferSend(clientConfig, wallet_1_name, coin.statechain_id, transfer_address.transfer_receive);

const electrumClient = await mercurynodejslib.getElectrumClient(clientConfig);
const electrumClient = await getElectrumClient(clientConfig);

const blockHeader = await electrumClient.request('blockchain.headers.subscribe'); // request(promise)
const currentBlockheight = blockHeader.height;
Expand Down Expand Up @@ -1041,7 +1041,7 @@ async function transferSendCoinExpiryBySending(clientConfig, wallet_1_name, wall

console.log("coin: ", coin);

const electrumClient = await mercurynodejslib.getElectrumClient(clientConfig);
const electrumClient = await getElectrumClient(clientConfig);

const blockHeader = await electrumClient.request('blockchain.headers.subscribe'); // request(promise)
const currentBlockheight = blockHeader.height;
Expand Down Expand Up @@ -1154,7 +1154,7 @@ async function transferSendCoinExpiryBySending(clientConfig, wallet_1_name, wall
assert.fail("Expected error when sending backup tx before expiry, but no error was thrown");
} catch (error) {
console.log("Expected error received: ", error.message);
assert(error.message.includes("The coin is expired."),
assert(error.message.includes("The coin is not expired yet."),
`Unexpected error message: ${error.message}`);
}
console.log("Completed test for send backup tx before expiry");
Expand Down
4 changes: 2 additions & 2 deletions clients/libs/nodejs/broadcast_backup_tx.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ const execute = async (clientConfig, electrumClient, db, walletName, statechainI
const blockHeader = await electrumClient.request('blockchain.headers.subscribe'); // request(promise)
const currentBlockheight = blockHeader.height;

if (currentBlockheight > coin.locktime) {
throw new Error(`The coin is expired. Coin locktime is ${coin.locktime} and current blockheight is ${currentBlockheight}`);
if (currentBlockheight <= coin.locktime) {
throw new Error(`The coin is not expired yet. Coin locktime is ${coin.locktime} and current blockheight is ${currentBlockheight}`);
}

const backupTx = mercury_wasm.latestBackuptxPaysToUserpubkey(backupTxs, coin, wallet.network);
Expand Down

0 comments on commit 18cd851

Please sign in to comment.