Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Organize unit tests and add integration tests with hsd #101

Merged
merged 7 commits into from
Nov 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions .github/workflows/test-windows.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test - Windows
name: Test

on:
push:
Expand All @@ -7,7 +7,7 @@ on:
branches: [master]

jobs:
build:
build-windows-latest:
runs-on: windows-latest
defaults:
run:
Expand All @@ -17,6 +17,7 @@ jobs:
- uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
path-type: inherit
update: true
install: git mingw-w64-x86_64-toolchain base-devel mingw-w64-x86_64-unbound autotools

Expand All @@ -26,9 +27,18 @@ jobs:
- uses: actions/checkout@v2

- name: Build
run: ./autogen.sh && ./configure && make
run: ./autogen.sh && ./configure --with-network=regtest && make

- name: Unit Tests
run: ./test_hnsd

# TODO: Install nodejs, intall hsd and test end-to-end integration.
- name: Setup Integration
uses: actions/[email protected]
with:
node-version: 18

- name: Integration Tests
working-directory: ./integration
run: |
npm install
npm run test
13 changes: 11 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,18 @@ jobs:
run: sudo apt-get install -y libunbound-dev

- name: Build
run: ./autogen.sh && ./configure && make
run: ./autogen.sh && ./configure --with-network=regtest && make

- name: Unit Tests
run: ./test_hnsd

# TODO: Install nodejs, intall hsd and test end-to-end integration.
- name: Setup Integration
uses: actions/[email protected]
with:
node-version: 18

- name: Integration Tests
working-directory: ./integration
run: |
npm install
npm run test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,4 @@ m4/ltversion.m4
m4/lt~obsolete.m4
src/stamp-h1
test_hnsd
integration/node_modules/
9 changes: 8 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ hnsd_CPPFLAGS = $(AM_CPPFLAGS)

noinst_PROGRAMS = test_hnsd

test_hnsd_SOURCES = test/hnsd-test.c
test_hnsd_SOURCES = test/hnsd-test.c \
test/base32-test.c \
test/resource-test.c

test_hnsd_LDFLAGS = -static
test_hnsd_CPPFLAGS = $(AM_CPPFLAGS)
Expand All @@ -87,3 +89,8 @@ test_hnsd_LDADD = $(LIB_UNBOUND) \

# pkgconfigdir = $(libdir)/pkgconfig
# pkgconfig_DATA = @[email protected]

.PHONY: e2e
e2e:
npm --prefix ./integration/ install
npm --prefix ./integration/ run test
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -345,10 +345,33 @@ $ hnsd [options]

## Testing

### Unit tests

The `make` command will output two binaries into the root directory: `hnsd`
and `test_hnsd`, which is compiled from unit tests in the `test/` directory.
Run the tests with `./test_hnsd`.

### Integration tests

The `integration/` directory contains a nodejs package that installs hsd and
runs a bmocha test suite. `hnsd` is run using `child_process.spawn()` and tested
by making DNS queries to its open ports.

`hnsd` MUST be built in regtest mode: `./configure --with-network=regtest`

Build and run the integration tests (requires nodejs >= v16):

```
make e2e
```

or:

```
npm --prefix ./integration install
npm --prefix ./integration run test
```

## License

- Copyright (c) 2018, Christopher Jeffrey (MIT License).
Expand Down
Loading