Skip to content

Commit

Permalink
Using sendTxWithCheck for setFeePerKB
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy-then committed Oct 30, 2024
1 parent 102700b commit f39a419
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ const DEFAULT_RSK_ADDRESS_FUNDING_IN_BTC = 0.5;
const FEE_PER_KB_CHANGER_PRIVATE_KEY = '6a4b49312b91e203ddfb9bc2d900ebbd46fbede46a7462e770bedcb11ad405e9';
const FEE_PER_KB_CHANGER_ADDRESS = '53f8f6dabd612b6137215ddd7758bb5cdd638922';

const FEE_PER_KB_RESPONSE_CODES = {
SUCCESSFUL_VOTE: 1,
};

module.exports = {
KEY_TYPE_BTC,
KEY_TYPE_RSK,
Expand Down Expand Up @@ -148,4 +152,5 @@ module.exports = {
PEGOUT_REJECTION_REASONS,
FEE_PER_KB_CHANGER_PRIVATE_KEY,
FEE_PER_KB_CHANGER_ADDRESS,
FEE_PER_KB_RESPONSE_CODES,
};
5 changes: 4 additions & 1 deletion lib/rsk-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const {
PEGOUT_EVENTS,
FEE_PER_KB_CHANGER_PRIVATE_KEY,
FEE_PER_KB_CHANGER_ADDRESS,
FEE_PER_KB_RESPONSE_CODES,
} = require('./constants');
const BtcTransactionHelper = require('btc-transaction-helper/btc-transaction-helper');

Expand Down Expand Up @@ -519,7 +520,9 @@ const setFeePerKb = async (rskTxHelper, feePerKbInSatoshis) => {
await rskTxHelper.getClient().eth.personal.unlockAccount(FEE_PER_KB_CHANGER_ADDRESS, '');
const bridge = getBridge(rskTxHelper.getClient());

await sendTransaction(rskTxHelper, bridge.methods.voteFeePerKbChange(feePerKbInSatoshis), FEE_PER_KB_CHANGER_ADDRESS);
await sendTxWithCheck(rskTxHelper, bridge.methods.voteFeePerKbChange(feePerKbInSatoshis), FEE_PER_KB_CHANGER_ADDRESS, (result) => {
expect(Number(result)).to.equal(FEE_PER_KB_RESPONSE_CODES.SUCCESSFUL_VOTE);
});

const finalFeePerKb = await bridge.methods.getFeePerKb().call();
expect(Number(finalFeePerKb)).to.equal(Number(feePerKbInSatoshis));
Expand Down

0 comments on commit f39a419

Please sign in to comment.