Skip to content

Commit

Permalink
test: add test for estimatesmartfee
Browse files Browse the repository at this point in the history
  • Loading branch information
emjshrx committed Jun 25, 2023
1 parent 890302a commit c7d70f8
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions test/node-rpc-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const nclient = new NodeClient({
timeout: 15000
});

describe('RPC', function() {
describe('RPC', function () {
this.timeout(15000);

before(async () => {
Expand Down Expand Up @@ -159,7 +159,7 @@ describe('RPC', function() {
only: [`127.0.0.1:${ports.p2p}`]
});

after(async() => {
after(async () => {
if (peer.opened)
await peer.close();
});
Expand Down Expand Up @@ -411,7 +411,7 @@ describe('RPC', function() {
});

it('should return confirmations (main chain)', async () => {
const {genesis} = node.network;
const { genesis } = node.network;
const hash = genesis.hash.reverse().toString('hex');

const info = await nclient.execute('getblock', [hash]);
Expand All @@ -422,10 +422,10 @@ describe('RPC', function() {
it('should return confirmations (orphan)', async () => {
// Get the chain entry associated with
// the genesis block.
const {genesis} = node.network;
const { genesis } = node.network;
let entry = await node.chain.getEntry(genesis.hash.reverse());

// Get current chain tip and chain height
// Get current chain tip and chain height
const chainHeight = node.chain.tip.height + 1;
const chainTip = util.revHex(node.chain.tip.hash);

Expand Down Expand Up @@ -488,7 +488,7 @@ describe('RPC', function() {
});
});

describe('verifymessage', function() {
describe('verifymessage', function () {
const message = 'This is just a test message';
const address = 'mpLQjfK79b7CCV4VMJWEWAj5Mpx8Up5zxB';
const signature = 'INbVnW4e6PeRmsv2Qgu8NuopvrVjkcxob+sX8OcZG0SALh'
Expand Down Expand Up @@ -541,17 +541,26 @@ describe('RPC', function() {
});
});

describe('utilities', function() {
// 0-in, 2-out
const rawTX1 =
'0100000000024e61bc00000000001976a914fbdd46898a6d70a682cbd34420cc' +
'f0b6bb64493788acf67e4929010000001976a9141b002b6fc0f457bf8d092722' +
'510fce9f37f0423b88ac00000000';

describe('utilities', function () {

it('should decoderawtransaction', async () => {
// 0-in, 2-out
const rawTX1 =
'0100000000024e61bc00000000001976a914fbdd46898a6d70a682cbd34420cc' +
'f0b6bb64493788acf67e4929010000001976a9141b002b6fc0f457bf8d092722' +
'510fce9f37f0423b88ac00000000';
const result = await nclient.execute('decoderawtransaction', [rawTX1]);
assert.strictEqual(result.vin.length, 0);
assert.strictEqual(result.vout.length, 2);
});

it('should estimate fee rate', async () => {
const result = await nclient.execute('estimatesmartfee', [6]);
assert.deepStrictEqual(result, {
blocks: 6,
feerate: -1,
});
});

});
});

0 comments on commit c7d70f8

Please sign in to comment.