Skip to content

Commit

Permalink
chore: improve bitcoind definition (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
fuxingloh authored May 24, 2024
1 parent 4fb3aad commit 9fbf1d0
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,7 @@ describe('bitcoind', () => {
bitcoind = testcontainers.getContainer('bitcoind');
});

it('should get rpc port', async () => {
const port = bitcoind.getHostPort('rpc');
expect(port).toStrictEqual(expect.any(Number));
});

it('should rpc getblockchaininfo', async () => {
it('should rpc(getblockchaininfo)', async () => {
const response = await bitcoind.rpc({
method: 'getblockchaininfo',
});
Expand All @@ -41,7 +36,7 @@ describe('bitcoind', () => {
});
});

it('should rpc getblockcount', async () => {
it('should rpc(getblockcount)', async () => {
const response = await bitcoind.rpc({
method: 'getblockcount',
});
Expand All @@ -53,7 +48,7 @@ describe('bitcoind', () => {
});
});

it('should rpc getblock', async () => {
it('should rpc(getblock)', async () => {
const response = await bitcoind.rpc({
method: 'getblock',
params: ['000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f', 2],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"bitcoind": {
"image": "docker.io/kylemanna/bitcoind@sha256:1492fa0306cb7eb5de8d50ba60367cff8d29b00b516e45e93e05f8b54fa2970e",
"source": "https://github.com/kylemanna/docker-bitcoind",
"command": ["btc_oneshot", "-fallbackfee=0.00000200", "-rpcbind=:8332", "-rpcallowip=0.0.0.0/0"],
"endpoints": {
"p2p": {
"port": 18445
Expand Down Expand Up @@ -58,6 +59,7 @@
},
"environment": {
"REGTEST": "1",
"DISABLEWALLET": "0",
"RPCUSER": {
"key": "RPC_USER"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@ describe('bitcoind', () => {
bitcoind = testcontainers.getContainer('bitcoind');
});

it('should get rpc port', async () => {
const port = bitcoind.getHostPort('rpc');
expect(port).toStrictEqual(expect.any(Number));
});

it('should rpc getblockchaininfo', async () => {
it('should rpc(getblockchaininfo)', async () => {
const response = await bitcoind.rpc({
method: 'getblockchaininfo',
});
Expand All @@ -41,7 +36,7 @@ describe('bitcoind', () => {
});
});

it('should rpc getblockcount', async () => {
it('should rpc(getblockcount)', async () => {
const response = await bitcoind.rpc({
method: 'getblockcount',
});
Expand All @@ -53,7 +48,7 @@ describe('bitcoind', () => {
});
});

it('should rpc getblock', async () => {
it('should rpc(getblock)', async () => {
const response = await bitcoind.rpc({
method: 'getblock',
params: ['0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206', 2],
Expand Down Expand Up @@ -115,4 +110,34 @@ describe('bitcoind', () => {
},
});
});

it('should rpc(sendtoaddress)', async () => {
const createwallet: any = await bitcoind
.rpc({ method: 'createwallet', params: ['test'] })
.then((res) => res.json());
expect(createwallet).toMatchObject({ error: null });

const getnewaddress: any = await bitcoind.rpc({ method: 'getnewaddress' }).then((res) => res.json());
expect(getnewaddress).toMatchObject({ error: null, result: expect.any(String) });

// Wait for coinbase maturity
const generatetoaddress = await bitcoind
.rpc({
method: 'generatetoaddress',
params: [101, getnewaddress.result],
})
.then((res) => res.json());
expect(generatetoaddress).toMatchObject({ error: null });

const sendtoaddress: any = await bitcoind
.rpc({
method: 'sendtoaddress',
params: ['bcrt1q4u4nsgk6ug0sqz7r3rj9tykjxrsl0yy4d0wwte', 1.23456789],
})
.then((res) => res.json());

expect(sendtoaddress).toMatchObject({
error: null,
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('defid', () => {
defid = testcontainers.getContainer('defid');
});

it('should rpc getblockchaininfo', async () => {
it('should rpc(getblockchaininfo)', async () => {
const response = await defid.rpc({
method: 'getblockchaininfo',
});
Expand All @@ -36,7 +36,7 @@ describe('defid', () => {
});
});

it('should rpc getblockcount', async () => {
it('should rpc(getblockcount)', async () => {
const response = await defid.rpc({
method: 'getblockcount',
});
Expand All @@ -48,7 +48,7 @@ describe('defid', () => {
});
});

it('should rpc getblock', async () => {
it('should rpc(getblock)', async () => {
const response = await defid.rpc({
method: 'getblock',
params: ['279b1a87aedc7b9471d4ad4e5f12967ab6259926cd097ade188dfcf22ebfe72a', 2],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { afterAll, beforeAll, describe, expect, it } from '@jest/globals';
import { KarfiaAgentContainer, KarfiaContainer, KarfiaTestcontainers } from 'karfia-testcontainers';
import { KarfiaContainer, KarfiaTestcontainers } from 'karfia-testcontainers';

import definition from './defid-jellyfish.json';

Expand Down Expand Up @@ -57,27 +57,3 @@ describe('defid + whale', () => {
});
});
});

describe('karfia-agent', () => {
let agent: KarfiaAgentContainer;

beforeAll(() => {
agent = testcontainers.getKarfiaAgent();
});

it('should Probe.Readiness', async () => {
const response = await agent.probe('Readiness');
expect(response.status).toStrictEqual(200);
expect(await response.json()).toMatchObject({
containers: {
defid: {
ok: true,
},
whale: {
ok: true,
},
},
ok: true,
});
});
});

0 comments on commit 9fbf1d0

Please sign in to comment.