Compare commits
4 Commits
cff0c10
...
fd4c16d090
Author | SHA1 | Date | |
---|---|---|---|
fd4c16d090 | |||
47ad96e2b6 | |||
a5093c4aa3 | |||
aae086cc65 |
@ -62,7 +62,7 @@ jobs:
|
||||
- run: &apt_install
|
||||
apt-get update &&
|
||||
DEBIAN_FRONTEND=noninteractive
|
||||
apt-get install -y --no-install-recommends
|
||||
apt-get install -y
|
||||
ca-certificates
|
||||
clang
|
||||
cmake
|
||||
@ -141,9 +141,7 @@ jobs:
|
||||
- run: *apt_install
|
||||
- run:
|
||||
apt-get install -y --no-install-recommends
|
||||
ca-certificates
|
||||
python3-pip
|
||||
cpplint
|
||||
- checkout
|
||||
- run: git submodule update --init --recursive
|
||||
- run: pip install cpplint
|
||||
- run: other/analysis/run-cpplint
|
@ -7,13 +7,14 @@ bazel-opt_task:
|
||||
configure_script:
|
||||
- git submodule update --init --recursive
|
||||
- /src/workspace/tools/inject-repo c-toxcore
|
||||
- sed -i -e 's/build --config=remote/#&/' /src/workspace/.bazelrc.local
|
||||
test_all_script:
|
||||
- cd /src/workspace && bazel test -k
|
||||
--build_tag_filters=-haskell
|
||||
--test_tag_filters=-haskell
|
||||
--
|
||||
//c-toxcore/...
|
||||
-//c-toxcore/auto_tests:tcp_relay_test # TODO(robinlinden): Why does this pass locally but not in Cirrus?
|
||||
-//c-toxcore/auto_tests:tcp_relay_test # Cirrus doesn't allow external network connections.
|
||||
|
||||
bazel-dbg_task:
|
||||
container:
|
||||
@ -27,9 +28,10 @@ bazel-dbg_task:
|
||||
- cd /src/workspace && bazel test -k
|
||||
--build_tag_filters=-haskell
|
||||
--test_tag_filters=-haskell
|
||||
--remote_http_cache=http://$CIRRUS_HTTP_CACHE_HOST
|
||||
--
|
||||
//c-toxcore/...
|
||||
-//c-toxcore/auto_tests:tcp_relay_test # TODO(robinlinden): Why does this pass locally but not in Cirrus?
|
||||
-//c-toxcore/auto_tests:tcp_relay_test # Cirrus doesn't allow external network connections.
|
||||
|
||||
cimple_task:
|
||||
container:
|
||||
@ -39,6 +41,7 @@ cimple_task:
|
||||
configure_script:
|
||||
- git submodule update --init --recursive
|
||||
- /src/workspace/tools/inject-repo c-toxcore
|
||||
- sed -i -e 's/build --config=remote/#&/' /src/workspace/.bazelrc.local
|
||||
test_all_script:
|
||||
- cd /src/workspace && bazel test -k
|
||||
--build_tag_filters=haskell
|
||||
@ -47,13 +50,30 @@ cimple_task:
|
||||
//c-toxcore/...
|
||||
|
||||
freebsd_task:
|
||||
container:
|
||||
image: toxchat/freebsd:latest
|
||||
cpu: 2
|
||||
memory: 4G
|
||||
kvm: true
|
||||
freebsd_instance:
|
||||
image_family: freebsd-14-0
|
||||
configure_script:
|
||||
- PAGER=cat ASSUME_ALWAYS_YES=YES pkg install
|
||||
cmake
|
||||
git
|
||||
gmake
|
||||
googletest
|
||||
libconfig
|
||||
libsodium
|
||||
libvpx
|
||||
opus
|
||||
pkgconf
|
||||
- git submodule update --init --recursive
|
||||
- cd .. && mv cirrus-ci-build /work/c-toxcore && mkdir cirrus-ci-build
|
||||
test_all_script:
|
||||
- cd /work/c-toxcore && .github/scripts/cmake-freebsd
|
||||
- |
|
||||
# TODO(iphydf): Investigate FreeBSD failures on these tests.
|
||||
sed -Ei -e '/\(dht_getnodes_api\)/s/^/#/' auto_tests/CMakeLists.txt
|
||||
cmake . \
|
||||
-DMIN_LOGGER_LEVEL=TRACE \
|
||||
-DMUST_BUILD_TOXAV=ON \
|
||||
-DNON_HERMETIC_TESTS=OFF \
|
||||
-DTEST_TIMEOUT_SECONDS=50 \
|
||||
-DUSE_IPV6=OFF \
|
||||
-DAUTOTEST=ON
|
||||
cmake --build . --target install
|
||||
ctest -j50 --output-on-failure --rerun-failed --repeat until-pass:6
|
@ -21,7 +21,7 @@ CheckOptions:
|
||||
- key: readability-identifier-naming.MacroDefinitionCase
|
||||
value: UPPER_CASE
|
||||
- key: readability-identifier-naming.MacroDefinitionIgnoredRegexp
|
||||
value: "^_.*|nullable|non_null|nullptr|static_assert|ck_.*"
|
||||
value: "^_.*|bitwise|force|nullable|non_null|nullptr|static_assert|ck_.*"
|
||||
- key: readability-identifier-naming.ParameterCase
|
||||
value: lower_case
|
||||
- key: readability-identifier-naming.StructCase
|
||||
@ -36,12 +36,14 @@ CheckOptions:
|
||||
value: lower_case
|
||||
|
||||
- key: llvmlibc-restrict-system-libc-headers.Includes
|
||||
value: "arpa/inet.h,assert.h,ctype.h,errno.h,fcntl.h,getopt.h,libconfig.h,limits.h,linux/if.h,math.h,netdb.h,netinet/in.h,opus.h,pthread.h,signal.h,sodium/crypto_scalarmult_curve25519.h,sodium.h,sodium/randombytes.h,stdarg.h,stdbool.h,stddef.h,stdint.h,stdio.h,stdlib.h,string.h,sys/ioctl.h,syslog.h,sys/resource.h,sys/socket.h,sys/stat.h,sys/time.h,sys/types.h,time.h,unistd.h,vpx/vp8cx.h,vpx/vp8dx.h,vpx/vpx_decoder.h,vpx/vpx_encoder.h,vpx/vpx_image.h"
|
||||
value: "alloca.h,arpa/inet.h,assert.h,ctype.h,errno.h,fcntl.h,getopt.h,libconfig.h,limits.h,linux/if.h,math.h,netdb.h,netinet/in.h,opus.h,pthread.h,signal.h,sodium/crypto_scalarmult_curve25519.h,sodium.h,sodium/randombytes.h,stdarg.h,stdbool.h,stddef.h,stdint.h,stdio.h,stdlib.h,string.h,sys/ioctl.h,syslog.h,sys/resource.h,sys/socket.h,sys/stat.h,sys/time.h,sys/types.h,time.h,unistd.h,vpx/vp8cx.h,vpx/vp8dx.h,vpx/vpx_decoder.h,vpx/vpx_encoder.h,vpx/vpx_image.h"
|
||||
- key: hicpp-signed-bitwise.IgnorePositiveIntegerLiterals
|
||||
value: true
|
||||
- key: concurrency-mt-unsafe.FunctionSet
|
||||
value: posix
|
||||
- key: misc-include-cleaner.IgnoreHeaders
|
||||
value: "pthread.h;stdbool.h;stddef.h;stdint.;stdint.h;stdint...;cstdint;sodium.*;sys/.*;unistd.h;opus.*;vpx.*;attributes.h;tox_struct.h"
|
||||
- key: readability-function-cognitive-complexity.Threshold
|
||||
value: 153 # TODO(iphydf): Decrease. tox_new is the highest at the moment.
|
||||
- key: cppcoreguidelines-avoid-do-while.IgnoreMacros
|
||||
value: true
|
||||
- key: readability-simplify-boolean-expr.SimplifyDeMorgan
|
||||
value: false
|
1
.github/FUNDING.yml
vendored
1
.github/FUNDING.yml
vendored
@ -1 +0,0 @@
|
||||
github: Green-Sky
|
@ -10,7 +10,7 @@ ABI=${1:-"armeabi-v7a"}
|
||||
case $ABI in
|
||||
armeabi-v7a)
|
||||
TARGET=armv7a-linux-androideabi
|
||||
NDK_API=19
|
||||
NDK_API=21
|
||||
;;
|
||||
arm64-v8a)
|
||||
TARGET=aarch64-linux-android
|
||||
@ -18,7 +18,7 @@ case $ABI in
|
||||
;;
|
||||
x86)
|
||||
TARGET=i686-linux-android
|
||||
NDK_API=19
|
||||
NDK_API=21
|
||||
;;
|
||||
x86_64)
|
||||
TARGET=x86_64-linux-android
|
@ -18,7 +18,7 @@ docker run \
|
||||
-e ENABLE_ARCH_i686="$i686" \
|
||||
-e ENABLE_ARCH_x86_64="$x86_64" \
|
||||
-e ENABLE_TEST=true \
|
||||
-e EXTRA_CMAKE_FLAGS="-DBOOTSTRAP_DAEMON=OFF -DMIN_LOGGER_LEVEL=DEBUG -DTEST_TIMEOUT_SECONDS=90 -DAUTOTEST=ON" \
|
||||
-e EXTRA_CMAKE_FLAGS="-DBOOTSTRAP_DAEMON=OFF -DMIN_LOGGER_LEVEL=DEBUG -DTEST_TIMEOUT_SECONDS=90 -DAUTOTEST=ON -DUSE_IPV6=OFF" \
|
||||
-e CMAKE_C_FLAGS="$C_FLAGS" \
|
||||
-e CMAKE_CXX_FLAGS="$CXX_FLAGS" \
|
||||
-e CMAKE_EXE_LINKER_FLAGS="$LD_FLAGS" \
|
||||
@ -26,4 +26,6 @@ docker run \
|
||||
-v "$PWD:/toxcore" \
|
||||
-v "$PWD/result:/prefix" \
|
||||
--rm \
|
||||
-t \
|
||||
--pull never \
|
||||
"toxchat/windows:$WINDOWS_ARCH"
|
@ -39,12 +39,17 @@ add_flag -Wno-reserved-id-macro
|
||||
# TODO(iphydf): Clean these up. They are likely not bugs, but still
|
||||
# potential issues and probably confusing.
|
||||
add_flag -Wno-sign-compare
|
||||
# We don't want to have default cases, we want to explicitly define all cases
|
||||
add_flag -Wno-switch-default
|
||||
# __attribute__((nonnull)) causes this warning on defensive null checks.
|
||||
add_flag -Wno-tautological-pointer-compare
|
||||
# Our use of mutexes results in a false positive, see 1bbe446.
|
||||
add_flag -Wno-thread-safety-analysis
|
||||
# File transfer code has this.
|
||||
add_flag -Wno-type-limits
|
||||
# Generates false positives in toxcore similar to
|
||||
# https://github.com/llvm/llvm-project/issues/64646
|
||||
add_flag -Wno-unsafe-buffer-usage
|
||||
# Callbacks often don't use all their parameters.
|
||||
add_flag -Wno-unused-parameter
|
||||
# cimple does this better
|
@ -3,10 +3,11 @@
|
||||
set -exu -o pipefail
|
||||
|
||||
LOCAL="${1:-}"
|
||||
CHECK="${2:-}"
|
||||
|
||||
readarray -t FILES <<<"$(git ls-files)"
|
||||
|
||||
if ! tar c "${FILES[@]}" | docker build -f other/bootstrap_daemon/docker/Dockerfile -t toxchat/bootstrap-node - 2>&1 | tee docker-build.log; then
|
||||
if ! tar c "${FILES[@]}" | docker build --build-arg="CHECK=$CHECK" -f other/bootstrap_daemon/docker/Dockerfile -t toxchat/bootstrap-node - 2>&1 | tee docker-build.log; then
|
||||
grep -o "::error.*::[a-f0-9]* /usr/local/bin/tox-bootstrapd" docker-build.log
|
||||
false
|
||||
fi
|
228
.github/workflows/cd.yml
vendored
228
.github/workflows/cd.yml
vendored
@ -1,228 +0,0 @@
|
||||
name: ContinuousDelivery
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
|
||||
env:
|
||||
BUILD_TYPE: Release
|
||||
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
|
||||
|
||||
jobs:
|
||||
linux-ubuntu:
|
||||
timeout-minutes: 10
|
||||
|
||||
runs-on: ubuntu-20.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Install Dependencies
|
||||
run: sudo apt update && sudo apt -y install libsodium-dev
|
||||
|
||||
- name: Configure CMake
|
||||
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
||||
|
||||
- name: Build
|
||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
|
||||
|
||||
- name: temp test
|
||||
run: ${{github.workspace}}/build/bin/mono_time_test
|
||||
|
||||
- name: Determine tag name
|
||||
id: tag
|
||||
shell: bash
|
||||
# taken from llama.cpp
|
||||
run: |
|
||||
SHORT_HASH="$(git rev-parse --short=7 HEAD)"
|
||||
if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
|
||||
echo "name=${SHORT_HASH}" >> $GITHUB_OUTPUT
|
||||
else
|
||||
SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
|
||||
echo "name=${SAFE_NAME}-${SHORT_HASH}" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Compress artifacts
|
||||
shell: bash
|
||||
run: |
|
||||
tar -czvf ${{ github.event.repository.name }}-${{ steps.tag.outputs.name }}-${{ runner.os }}-ubuntu20.04-x86_64.tar.gz -C ${{github.workspace}}/build/bin/ .
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
# TODO: simpler name?
|
||||
name: ${{ github.event.repository.name }}-${{ steps.tag.outputs.name }}-${{ runner.os }}-ubuntu20.04-x86_64
|
||||
# TODO: do propper packing
|
||||
path: |
|
||||
${{github.workspace}}/${{ github.event.repository.name }}-${{ steps.tag.outputs.name }}-${{ runner.os }}-ubuntu20.04-x86_64.tar.gz
|
||||
|
||||
|
||||
windows:
|
||||
timeout-minutes: 15
|
||||
|
||||
runs-on: windows-2019
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Install Dependencies
|
||||
run: vcpkg install libsodium:x64-windows-static pthreads:x64-windows-static
|
||||
|
||||
# setup vs env
|
||||
- uses: ilammy/msvc-dev-cmd@v1
|
||||
with:
|
||||
arch: amd64
|
||||
|
||||
- name: Configure CMake
|
||||
run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static
|
||||
|
||||
- name: Build
|
||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
|
||||
|
||||
- name: temp test
|
||||
run: ${{github.workspace}}/build/bin/mono_time_test.exe
|
||||
|
||||
- name: Determine tag name
|
||||
id: tag
|
||||
shell: bash
|
||||
# taken from llama.cpp
|
||||
run: |
|
||||
SHORT_HASH="$(git rev-parse --short=7 HEAD)"
|
||||
if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
|
||||
echo "name=${SHORT_HASH}" >> $GITHUB_OUTPUT
|
||||
else
|
||||
SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
|
||||
echo "name=${SAFE_NAME}-${SHORT_HASH}" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Compress artifacts
|
||||
shell: powershell
|
||||
run: |
|
||||
Compress-Archive -Path ${{github.workspace}}/build/bin/* -Destination ${{ github.event.repository.name }}-${{ steps.tag.outputs.name }}-${{ runner.os }}-msvc-x86_64.zip
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
# TODO: simpler name?
|
||||
name: ${{ github.event.repository.name }}-${{ steps.tag.outputs.name }}-${{ runner.os }}-msvc-x86_64
|
||||
# TODO: do propper packing
|
||||
path: |
|
||||
${{github.workspace}}/${{ github.event.repository.name }}-${{ steps.tag.outputs.name }}-${{ runner.os }}-msvc-x86_64.zip
|
||||
|
||||
|
||||
windows-asan:
|
||||
timeout-minutes: 15
|
||||
|
||||
runs-on: windows-2019
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Install Dependencies
|
||||
run: vcpkg install libsodium:x64-windows-static pthreads:x64-windows-static
|
||||
|
||||
# setup vs env
|
||||
- uses: ilammy/msvc-dev-cmd@v1
|
||||
with:
|
||||
arch: amd64
|
||||
|
||||
- name: Configure CMake
|
||||
run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static -DTOMATO_ASAN=ON -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded
|
||||
|
||||
- name: Build
|
||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
|
||||
|
||||
- name: temp test
|
||||
run: ${{github.workspace}}/build/bin/mono_time_test.exe
|
||||
|
||||
- name: Determine tag name
|
||||
id: tag
|
||||
shell: bash
|
||||
# taken from llama.cpp
|
||||
run: |
|
||||
SHORT_HASH="$(git rev-parse --short=7 HEAD)"
|
||||
if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
|
||||
echo "name=${SHORT_HASH}" >> $GITHUB_OUTPUT
|
||||
else
|
||||
SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
|
||||
echo "name=${SAFE_NAME}-${SHORT_HASH}" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Compress artifacts
|
||||
shell: powershell
|
||||
run: |
|
||||
Compress-Archive -Path ${{github.workspace}}/build/bin/* -Destination ${{ github.event.repository.name }}-${{ steps.tag.outputs.name }}-${{ runner.os }}-msvc-asan-x86_64.zip
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
# TODO: simpler name?
|
||||
name: ${{ github.event.repository.name }}-${{ steps.tag.outputs.name }}-${{ runner.os }}-msvc-asan-x86_64
|
||||
# TODO: do propper packing
|
||||
path: |
|
||||
${{github.workspace}}/${{ github.event.repository.name }}-${{ steps.tag.outputs.name }}-${{ runner.os }}-msvc-asan-x86_64.zip
|
||||
|
||||
release:
|
||||
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) }}
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
needs:
|
||||
- linux-ubuntu
|
||||
- windows
|
||||
- windows-asan
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Determine tag name
|
||||
id: tag
|
||||
shell: bash
|
||||
# taken from llama.cpp
|
||||
run: |
|
||||
SHORT_HASH="$(git rev-parse --short=7 HEAD)"
|
||||
if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
|
||||
echo "name=${SHORT_HASH}" >> $GITHUB_OUTPUT
|
||||
else
|
||||
SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
|
||||
echo "name=${SAFE_NAME}-${SHORT_HASH}" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Download artifacts
|
||||
id: download-artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: ./artifacts/
|
||||
|
||||
- name: Create release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
tag: ${{ steps.tag.outputs.name }}
|
||||
shell: bash
|
||||
run: |
|
||||
gh release create "$tag" \
|
||||
--repo="$GITHUB_REPOSITORY" \
|
||||
--title="nightly ${tag#v}" \
|
||||
--notes="nightly build" \
|
||||
--prerelease
|
||||
|
||||
- name: Upload artifacts
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
tag: ${{ steps.tag.outputs.name }}
|
||||
shell: bash
|
||||
run: |
|
||||
ls -laR ./artifacts
|
||||
gh release upload "$tag" ./artifacts/*/* \
|
||||
--repo="$GITHUB_REPOSITORY"
|
||||
|
234
.github/workflows/ci.yml
vendored
234
.github/workflows/ci.yml
vendored
@ -1,80 +1,200 @@
|
||||
name: ContinuousIntegration
|
||||
name: ci
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
branches: [master]
|
||||
|
||||
env:
|
||||
BUILD_TYPE: Debug
|
||||
# Cancel old PR builds when pushing new commits.
|
||||
concurrency:
|
||||
group: build-${{ github.event.pull_request.number || github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
linux:
|
||||
timeout-minutes: 10
|
||||
common:
|
||||
uses: TokTok/ci-tools/.github/workflows/common-ci.yml@master
|
||||
|
||||
analysis:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
tool: [autotools, clang-tidy, compcert, cppcheck, doxygen, goblint, infer, freebsd, misra, modules, pkgsrc, rpm, slimcc, sparse, tcc, tokstyle]
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
with:
|
||||
driver: docker
|
||||
- name: Build toxchat/c-toxcore:sources
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
file: other/docker/sources/sources.Dockerfile
|
||||
tags: toxchat/c-toxcore:sources
|
||||
- name: Docker Build
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
file: other/docker/${{ matrix.tool }}/${{ matrix.tool }}.Dockerfile
|
||||
|
||||
- name: Install Dependencies
|
||||
run: sudo apt update && sudo apt -y install libsodium-dev
|
||||
coverage-linux:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Build, test, and upload coverage
|
||||
run: other/docker/coverage/run
|
||||
|
||||
- name: Configure CMake
|
||||
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
||||
generate-events:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Run generate_event_c
|
||||
run: |
|
||||
other/event_tooling/run
|
||||
git diff --exit-code
|
||||
|
||||
- name: Build
|
||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
|
||||
cimplefmt:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Run cimplefmt
|
||||
run: other/docker/cimplefmt/run -u $(find tox* -name "*.[ch]")
|
||||
|
||||
- name: temp test
|
||||
run: ${{github.workspace}}/build/bin/mono_time_test
|
||||
|
||||
macos:
|
||||
timeout-minutes: 10
|
||||
build-android:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
- run: .github/scripts/cmake-android armeabi-v7a
|
||||
- run: .github/scripts/cmake-android arm64-v8a
|
||||
- run: .github/scripts/cmake-android x86
|
||||
- run: .github/scripts/cmake-android x86_64
|
||||
|
||||
build-macos:
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Install Dependencies
|
||||
run: brew install libsodium
|
||||
|
||||
- name: Configure CMake
|
||||
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
||||
|
||||
- name: Build
|
||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
|
||||
|
||||
windows:
|
||||
timeout-minutes: 10
|
||||
|
||||
runs-on: windows-latest
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Build and test
|
||||
run: .github/scripts/cmake-osx
|
||||
|
||||
build-windows-msvc:
|
||||
strategy:
|
||||
matrix:
|
||||
version: [2019, 2022]
|
||||
runs-on: windows-${{ matrix.version }}
|
||||
env:
|
||||
VCPKG_ROOT: "C:/vcpkg"
|
||||
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Export GitHub Actions cache environment variables
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
|
||||
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
|
||||
- name: Configure CMake
|
||||
run: cmake --preset windows-default
|
||||
- name: Build
|
||||
run: cmake --build _build -j $([int]$env:NUMBER_OF_PROCESSORS+2)
|
||||
- name: Test
|
||||
run: |
|
||||
cd _build
|
||||
ctest -j50 --output-on-failure --rerun-failed --repeat until-pass:6 --build-config Debug
|
||||
|
||||
- name: Install Dependencies
|
||||
run: vcpkg install libsodium:x64-windows-static pthreads:x64-windows-static
|
||||
build-netbsd:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Test in NetBSD
|
||||
id: test
|
||||
uses: vmactions/netbsd-vm@v1
|
||||
with:
|
||||
usesh: true
|
||||
copyback: false
|
||||
prepare:
|
||||
/usr/sbin/pkg_add
|
||||
cmake
|
||||
googletest
|
||||
libconfig
|
||||
libopus
|
||||
libsodium
|
||||
libvpx
|
||||
pkg-config
|
||||
|
||||
# setup vs env
|
||||
- uses: ilammy/msvc-dev-cmd@v1
|
||||
with:
|
||||
arch: amd64
|
||||
run: |
|
||||
# TODO(iphydf): Investigate NetBSD failures on these tests.
|
||||
sed -Ei -e '/\((TCP|dht_getnodes_api)\)/s/^/#/' auto_tests/CMakeLists.txt
|
||||
cmake . \
|
||||
-DMIN_LOGGER_LEVEL=TRACE \
|
||||
-DMUST_BUILD_TOXAV=ON \
|
||||
-DNON_HERMETIC_TESTS=ON \
|
||||
-DTEST_TIMEOUT_SECONDS=90 \
|
||||
-DUSE_IPV6=OFF \
|
||||
-DAUTOTEST=ON
|
||||
cmake --build . --target install
|
||||
ctest -j50 --output-on-failure --rerun-failed --repeat until-pass:6
|
||||
|
||||
- name: Configure CMake
|
||||
run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static
|
||||
build-freebsd:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Test in FreeBSD
|
||||
id: test
|
||||
uses: vmactions/freebsd-vm@v1
|
||||
with:
|
||||
usesh: true
|
||||
copyback: false
|
||||
prepare:
|
||||
PAGER=cat ASSUME_ALWAYS_YES=YES pkg install
|
||||
cmake
|
||||
git
|
||||
gmake
|
||||
googletest
|
||||
libconfig
|
||||
libsodium
|
||||
libvpx
|
||||
opus
|
||||
pkgconf
|
||||
|
||||
- name: Build
|
||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
|
||||
|
||||
- name: temp test
|
||||
run: ${{github.workspace}}/build/bin/mono_time_test.exe
|
||||
run: |
|
||||
# TODO(iphydf): Investigate FreeBSD failures on these tests.
|
||||
sed -Ei -e '/\(dht_getnodes_api\)/s/^/#/' auto_tests/CMakeLists.txt
|
||||
cmake . \
|
||||
-DMIN_LOGGER_LEVEL=TRACE \
|
||||
-DMUST_BUILD_TOXAV=ON \
|
||||
-DNON_HERMETIC_TESTS=ON \
|
||||
-DTEST_TIMEOUT_SECONDS=50 \
|
||||
-DUSE_IPV6=OFF \
|
||||
-DAUTOTEST=ON
|
||||
cmake --build . --target install
|
||||
ctest -j50 --output-on-failure --rerun-failed --repeat until-pass:6
|
||||
|
||||
mypy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Set up Python 3.9
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: 3.9
|
||||
- name: Install mypy
|
||||
run: pip install mypy
|
||||
- name: Run mypy
|
||||
run: |
|
||||
(find . -name "*.py" -and -not -name "conanfile.py"; grep -lR '^#!.*python') \
|
||||
| xargs -n1 -P8 mypy --strict
|
||||
|
@ -8,7 +8,7 @@ jobs:
|
||||
latest:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Install libraries
|
@ -25,7 +25,9 @@ jobs:
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Docker Build
|
||||
run: .github/scripts/tox-bootstrapd-docker local
|
||||
run: .github/scripts/tox-bootstrapd-docker local "$CHECK"
|
||||
env:
|
||||
CHECK: "${{ contains(github.event.pull_request.title, 'chore: Release ') && 'sha256sum' || 'echo' }}"
|
||||
- name: Push latest image to DockerHub
|
||||
if: ${{ github.event_name == 'push' }}
|
||||
run: docker push toxchat/bootstrap-node:latest
|
||||
@ -46,7 +48,7 @@ jobs:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v4
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: "{{defaultContext}}:other/bootstrap_daemon/websocket"
|
||||
push: ${{ github.event_name == 'push' }}
|
||||
@ -67,7 +69,7 @@ jobs:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v4
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: "."
|
||||
file: .clusterfuzzlite/Dockerfile
|
||||
@ -88,7 +90,7 @@ jobs:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v4
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
file: testing/Dockerfile
|
||||
push: ${{ github.event_name == 'push' }}
|
||||
@ -108,7 +110,7 @@ jobs:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v4
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
file: other/emscripten/Dockerfile
|
||||
push: ${{ github.event_name == 'push' }}
|
||||
@ -121,21 +123,14 @@ jobs:
|
||||
steps:
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
with:
|
||||
driver: docker
|
||||
- name: Login to DockerHub
|
||||
if: ${{ github.event_name == 'push' }}
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
- name: Build toxchat/c-toxcore:sources
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
file: other/docker/sources/Dockerfile
|
||||
tags: toxchat/c-toxcore:sources
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v4
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
file: other/docker/esp32/Dockerfile
|
||||
push: ${{ github.event_name == 'push' }}
|
||||
@ -143,9 +138,15 @@ jobs:
|
||||
cache-from: type=registry,ref=toxchat/c-toxcore:esp32
|
||||
cache-to: type=inline
|
||||
|
||||
docker-win32:
|
||||
docker-windows-mingw:
|
||||
strategy:
|
||||
matrix:
|
||||
bits: [32, 64]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
- name: Login to DockerHub
|
||||
@ -154,39 +155,27 @@ jobs:
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v4
|
||||
- name: Build and store to local Docker daemon
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: "{{defaultContext}}:other/docker/windows"
|
||||
push: ${{ github.event_name == 'push' }}
|
||||
tags: toxchat/windows:win32
|
||||
cache-from: type=registry,ref=toxchat/windows:win32
|
||||
cache-to: type=inline
|
||||
context: other/docker/windows
|
||||
load: true
|
||||
tags: toxchat/windows:win${{ matrix.bits }}
|
||||
cache-from: type=registry,ref=toxchat/windows:win${{ matrix.bits }}
|
||||
build-args: |
|
||||
SUPPORT_ARCH_i686=true
|
||||
SUPPORT_ARCH_x86_64=false
|
||||
SUPPORT_ARCH_i686=${{ matrix.bits == '32' }}
|
||||
SUPPORT_ARCH_x86_64=${{ matrix.bits == '64' }}
|
||||
SUPPORT_TEST=true
|
||||
|
||||
docker-win64:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
- name: Login to DockerHub
|
||||
- name: Push the stored image to Dockerhub
|
||||
if: ${{ github.event_name == 'push' }}
|
||||
uses: docker/login-action@v3
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: "{{defaultContext}}:other/docker/windows"
|
||||
context: other/docker/windows
|
||||
push: ${{ github.event_name == 'push' }}
|
||||
tags: toxchat/windows:win64
|
||||
cache-from: type=registry,ref=toxchat/windows:win64
|
||||
cache-to: type=inline
|
||||
tags: toxchat/windows:win${{ matrix.bits }}
|
||||
build-args: |
|
||||
SUPPORT_ARCH_i686=false
|
||||
SUPPORT_ARCH_x86_64=true
|
||||
SUPPORT_ARCH_i686=${{ matrix.bits == '32' }}
|
||||
SUPPORT_ARCH_x86_64=${{ matrix.bits == '64' }}
|
||||
SUPPORT_TEST=true
|
||||
- name: Cross-compile
|
||||
run: .github/scripts/cmake-win${{ matrix.bits }} script
|
@ -11,7 +11,7 @@ jobs:
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
- name: Docker Build
|
||||
uses: docker/build-push-action@v4
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
file: other/docker/alpine-s390x/Dockerfile
|
||||
|
||||
@ -29,14 +29,14 @@ jobs:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
- name: Build toxchat/c-toxcore:sources
|
||||
uses: docker/build-push-action@v4
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
file: other/docker/sources/Dockerfile
|
||||
file: other/docker/sources/sources.Dockerfile
|
||||
tags: toxchat/c-toxcore:sources
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v4
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
file: other/docker/coverage/Dockerfile
|
||||
file: other/docker/coverage/coverage.Dockerfile
|
||||
push: ${{ github.event_name == 'push' }}
|
||||
tags: toxchat/c-toxcore:coverage
|
||||
cache-from: type=registry,ref=toxchat/c-toxcore:coverage
|
119
.gitignore
vendored
119
.gitignore
vendored
@ -1,26 +1,101 @@
|
||||
.vs/
|
||||
*.o
|
||||
*.swp
|
||||
~*
|
||||
*~
|
||||
.idea/
|
||||
cmake-build-debug/
|
||||
cmake-build-debugandtest/
|
||||
cmake-build-release/
|
||||
*.stackdump
|
||||
*.coredump
|
||||
compile_commands.json
|
||||
/build*
|
||||
/result*
|
||||
.clangd
|
||||
.cache
|
||||
|
||||
# OS files
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
.DS_Store?
|
||||
._*
|
||||
.mypy_cache
|
||||
.Spotlight-V100
|
||||
.Trash*
|
||||
Icon?
|
||||
ethumbs.db
|
||||
Thumbs.db
|
||||
*.tmp
|
||||
|
||||
CMakeLists.txt.user*
|
||||
# Make
|
||||
/_build
|
||||
/_install
|
||||
/tox-0.0.0*
|
||||
/.vs
|
||||
/CppProperties.json
|
||||
CMakeCache.txt
|
||||
CMakeFiles
|
||||
Makefile
|
||||
!/other/rpm/Makefile
|
||||
cmake_install.cmake
|
||||
install_manifest.txt
|
||||
tags
|
||||
Makefile.in
|
||||
CMakeLists.txt.user
|
||||
DartConfiguration.tcl
|
||||
CTestTestfile.cmake
|
||||
*.pc
|
||||
|
||||
*.tox
|
||||
imgui.ini
|
||||
# Testing
|
||||
/amalgamation.*
|
||||
testing/data
|
||||
*~
|
||||
|
||||
# Vim
|
||||
*.swp
|
||||
|
||||
# Object files
|
||||
*.o
|
||||
*.lo
|
||||
*.a
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
*.la
|
||||
|
||||
# Libraries
|
||||
*.so
|
||||
|
||||
# Misc (?)
|
||||
m4/*
|
||||
configure
|
||||
configure_aux
|
||||
!m4/pkg.m4
|
||||
aclocal.m4
|
||||
config.h*
|
||||
config.log
|
||||
config.status
|
||||
stamp-h1
|
||||
autom4te.cache
|
||||
libtool
|
||||
.deps
|
||||
.libs
|
||||
.dirstamp
|
||||
build/
|
||||
*.nvim*
|
||||
*.vim*
|
||||
|
||||
# kdevelop
|
||||
.kdev/
|
||||
*.kdev*
|
||||
|
||||
# VScode
|
||||
.vscode/
|
||||
|
||||
# Netbeans
|
||||
nbproject
|
||||
|
||||
# astyle
|
||||
*.orig
|
||||
|
||||
# Android buildscript
|
||||
android-toolchain-*
|
||||
toxcore-android-*
|
||||
|
||||
# cscope files list
|
||||
cscope.files
|
||||
|
||||
# rpm
|
||||
tox.spec
|
||||
|
||||
# clangd
|
||||
.cache/
|
||||
compile_commands.json
|
||||
|
||||
/infer
|
||||
.idea/
|
||||
|
25
.gitmodules
vendored
25
.gitmodules
vendored
@ -1,22 +1,3 @@
|
||||
[submodule "external/toxcore/c-toxcore/third_party/cmp"]
|
||||
path = external/toxcore/c-toxcore/third_party/cmp
|
||||
url = https://github.com/camgunz/cmp.git
|
||||
shallow = true
|
||||
[submodule "external/solanaceae_toxcore"]
|
||||
path = external/solanaceae_toxcore
|
||||
url = https://github.com/Green-Sky/solanaceae_toxcore.git
|
||||
[submodule "external/solanaceae_util"]
|
||||
path = external/solanaceae_util
|
||||
url = https://github.com/Green-Sky/solanaceae_util.git
|
||||
[submodule "external/solanaceae_contact"]
|
||||
path = external/solanaceae_contact
|
||||
url = https://github.com/Green-Sky/solanaceae_contact.git
|
||||
[submodule "external/solanaceae_message3"]
|
||||
path = external/solanaceae_message3
|
||||
url = https://github.com/Green-Sky/solanaceae_message3.git
|
||||
[submodule "external/solanaceae_tox"]
|
||||
path = external/solanaceae_tox
|
||||
url = https://github.com/Green-Sky/solanaceae_tox.git
|
||||
[submodule "external/solanaceae_plugin"]
|
||||
path = external/solanaceae_plugin
|
||||
url = https://github.com/Green-Sky/solanaceae_plugin.git
|
||||
[submodule "third_party/cmp"]
|
||||
path = third_party/cmp
|
||||
url = https://github.com/camgunz/cmp
|
||||
|
@ -1,20 +1,25 @@
|
||||
---
|
||||
exclude:
|
||||
- "**/*.api.h"
|
||||
# shfmt doesn't support this file
|
||||
# shfmt doesn't support this file.
|
||||
- "other/analysis/run-clang-tidy"
|
||||
# Generated file.
|
||||
- "CHANGELOG.md"
|
||||
|
||||
restylers:
|
||||
- astyle:
|
||||
image: restyled/restyler-astyle:d7967bcb8b622a98524b7df1da1b02652114cf9a
|
||||
arguments: ["--options=other/astyle/astylerc"]
|
||||
include:
|
||||
- "!**/*.cc"
|
||||
- "**/*.c"
|
||||
- "**/*.h"
|
||||
- autopep8
|
||||
- black
|
||||
- clang-format:
|
||||
image: restyled/restyler-clang-format:13.0.1
|
||||
image: restyled/restyler-clang-format:v16.0.6
|
||||
include:
|
||||
- "**/*.cc"
|
||||
- "**/*.hh"
|
||||
- prettier-markdown
|
||||
- prettier-yaml
|
||||
- reorder-python-imports
|
||||
- shellharden
|
@ -1,9 +1,274 @@
|
||||
|
||||
|
||||
## v0.2.19
|
||||
|
||||
### Merged PRs:
|
||||
|
||||
- [#2744](https://github.com/TokTok/c-toxcore/pull/2744) docs: Document that group topic lock is default on.
|
||||
- [#2743](https://github.com/TokTok/c-toxcore/pull/2743) docs: Add missing param docs for callbacks.
|
||||
- [#2742](https://github.com/TokTok/c-toxcore/pull/2742) chore: Add cmake flag to disable unit tests.
|
||||
- [#2741](https://github.com/TokTok/c-toxcore/pull/2741) refactor: Don't expose Tox_System in the public API
|
||||
- [#2736](https://github.com/TokTok/c-toxcore/pull/2736) cleanup: A more descriptive error for group invite accept function
|
||||
- [#2735](https://github.com/TokTok/c-toxcore/pull/2735) chore: Small API doc fixes
|
||||
- [#2732](https://github.com/TokTok/c-toxcore/pull/2732) cleanup: event length naming inconsistencies
|
||||
- [#2731](https://github.com/TokTok/c-toxcore/pull/2731) cleanup: align group send err enum order
|
||||
- [#2729](https://github.com/TokTok/c-toxcore/pull/2729) cleanup: use typedef for private message ID's in callback
|
||||
- [#2728](https://github.com/TokTok/c-toxcore/pull/2728) refactor: Observers/ignored peers can now send and receive custom packets
|
||||
- [#2727](https://github.com/TokTok/c-toxcore/pull/2727) feat: add message IDs to private group messages
|
||||
- [#2726](https://github.com/TokTok/c-toxcore/pull/2726) refactor: Rename `out` parameters to `out_$something`.
|
||||
- [#2718](https://github.com/TokTok/c-toxcore/pull/2718) chore: Use a specific non-broken slimcc version.
|
||||
- [#2713](https://github.com/TokTok/c-toxcore/pull/2713) feat: Update and improve the Windows cross-compilation
|
||||
- [#2712](https://github.com/TokTok/c-toxcore/pull/2712) chore: Update github actions.
|
||||
- [#2710](https://github.com/TokTok/c-toxcore/pull/2710) docs: Update the list of CMake options
|
||||
- [#2709](https://github.com/TokTok/c-toxcore/pull/2709) refactor: Remove "mod" and "founder" from group API naming scheme
|
||||
- [#2708](https://github.com/TokTok/c-toxcore/pull/2708) docs: add the experimental api build option to INSTALL.md
|
||||
- [#2705](https://github.com/TokTok/c-toxcore/pull/2705) refactor: Rename Queries to Query to align with other enums.
|
||||
- [#2704](https://github.com/TokTok/c-toxcore/pull/2704) fix: Correct type for conference offline peer numbers.
|
||||
- [#2700](https://github.com/TokTok/c-toxcore/pull/2700) test: Add FreeBSD VM action on GitHub.
|
||||
- [#2699](https://github.com/TokTok/c-toxcore/pull/2699) test: Add pkgsrc build.
|
||||
- [#2698](https://github.com/TokTok/c-toxcore/pull/2698) chore: Only install tox_private.h on request.
|
||||
- [#2697](https://github.com/TokTok/c-toxcore/pull/2697) test: Build toxcore on NetBSD (VM).
|
||||
- [#2696](https://github.com/TokTok/c-toxcore/pull/2696) fix: save_compatibility_test failing on big-endian systems
|
||||
- [#2695](https://github.com/TokTok/c-toxcore/pull/2695) fix: Don't serve files from websockify.
|
||||
- [#2689](https://github.com/TokTok/c-toxcore/pull/2689) fix: Correctly pass extended public keys to group moderation code.
|
||||
- [#2686](https://github.com/TokTok/c-toxcore/pull/2686) chore: Compile libsodium reference implementation with compcert.
|
||||
- [#2685](https://github.com/TokTok/c-toxcore/pull/2685) cleanup: correct a few nullable annotations
|
||||
- [#2684](https://github.com/TokTok/c-toxcore/pull/2684) cleanup: Don't use `memcpy` to cast arbitrary `struct`s to `uint8_t[]`.
|
||||
- [#2683](https://github.com/TokTok/c-toxcore/pull/2683) fix: Pass array, not array pointer, to `memcmp`.
|
||||
- [#2682](https://github.com/TokTok/c-toxcore/pull/2682) cleanup: Never pass `void*` directly to `memcpy`.
|
||||
- [#2678](https://github.com/TokTok/c-toxcore/pull/2678) chore: Disable NGC saving by default, enable through Tox_Options.
|
||||
- [#2675](https://github.com/TokTok/c-toxcore/pull/2675) cleanup: Replace pointer arithmetic with explicit `&arr[i]`.
|
||||
- [#2672](https://github.com/TokTok/c-toxcore/pull/2672) refactor: Use `structs` for extended public/secret keys.
|
||||
- [#2671](https://github.com/TokTok/c-toxcore/pull/2671) refactor: Use tox rng to seed the keypair generation.
|
||||
- [#2666](https://github.com/TokTok/c-toxcore/pull/2666) cleanup: Small improvements found by PVS Studio.
|
||||
- [#2664](https://github.com/TokTok/c-toxcore/pull/2664) docs: Run prettier-markdown on markdown files.
|
||||
- [#2662](https://github.com/TokTok/c-toxcore/pull/2662) fix: Correct a few potential null derefs in bootstrap daemon.
|
||||
- [#2661](https://github.com/TokTok/c-toxcore/pull/2661) fix: Zero out stack-allocated secret key before return.
|
||||
- [#2660](https://github.com/TokTok/c-toxcore/pull/2660) fix: Add missing memunlock of local variable when it goes out of scope.
|
||||
- [#2659](https://github.com/TokTok/c-toxcore/pull/2659) cleanup: Simplify custom packet length check in NGC.
|
||||
- [#2658](https://github.com/TokTok/c-toxcore/pull/2658) refactor: Make prune_gc_sanctions_list more obviously correct.
|
||||
- [#2657](https://github.com/TokTok/c-toxcore/pull/2657) fix: Fix some false positive from PVS Studio.
|
||||
- [#2656](https://github.com/TokTok/c-toxcore/pull/2656) docs: Add static analysis tool list to README.
|
||||
- [#2655](https://github.com/TokTok/c-toxcore/pull/2655) cleanup: Check that WINXP macro exists before comparing it.
|
||||
- [#2652](https://github.com/TokTok/c-toxcore/pull/2652) refactor: Make tox mutex non-recursive.
|
||||
- [#2648](https://github.com/TokTok/c-toxcore/pull/2648) docs: Add more documentation to crypto_core.
|
||||
- [#2647](https://github.com/TokTok/c-toxcore/pull/2647) docs: Fix up doxyfile.
|
||||
- [#2645](https://github.com/TokTok/c-toxcore/pull/2645) refactor: Remove `Tox *` from `tox_dispatch`.
|
||||
- [#2644](https://github.com/TokTok/c-toxcore/pull/2644) refactor: Don't rely on tox_dispatch passing tox in tests.
|
||||
- [#2643](https://github.com/TokTok/c-toxcore/pull/2643) refactor: Use strong typedef for NGC peer id.
|
||||
- [#2642](https://github.com/TokTok/c-toxcore/pull/2642) chore: Use C++ mode for clang-tidy.
|
||||
- [#2640](https://github.com/TokTok/c-toxcore/pull/2640) refactor: Use strong `typedef` instead of `struct` for `Socket`.
|
||||
- [#2637](https://github.com/TokTok/c-toxcore/pull/2637) chore: Check that both gtest and gmock exist for tests.
|
||||
- [#2634](https://github.com/TokTok/c-toxcore/pull/2634) chore: Add some comments to the astyle config.
|
||||
- [#2629](https://github.com/TokTok/c-toxcore/pull/2629) chore: Reformat sources with astyle.
|
||||
- [#2626](https://github.com/TokTok/c-toxcore/pull/2626) chore: Rename C++ headers to .hh suffixes.
|
||||
- [#2624](https://github.com/TokTok/c-toxcore/pull/2624) test: Add slimcc compiler compatibility test.
|
||||
- [#2622](https://github.com/TokTok/c-toxcore/pull/2622) cleanup: Add more `const` where possible.
|
||||
- [#2621](https://github.com/TokTok/c-toxcore/pull/2621) cleanup: Remove implicit bool conversions.
|
||||
- [#2620](https://github.com/TokTok/c-toxcore/pull/2620) chore: Only check the bootstrap daemon checksum on release.
|
||||
- [#2617](https://github.com/TokTok/c-toxcore/pull/2617) cleanup: Further `#include` cleanups.
|
||||
- [#2614](https://github.com/TokTok/c-toxcore/pull/2614) cleanup: Use Bazel modules to enforce proper `#include` hygiene.
|
||||
- [#2612](https://github.com/TokTok/c-toxcore/pull/2612) refactor: Move pack/unpack `IP_Port` from DHT into network module.
|
||||
- [#2611](https://github.com/TokTok/c-toxcore/pull/2611) chore: Really fix coverage docker image build.
|
||||
- [#2610](https://github.com/TokTok/c-toxcore/pull/2610) chore: Fix post-submit coverage image.
|
||||
- [#2609](https://github.com/TokTok/c-toxcore/pull/2609) fix: partially fix a bug that prevented group part messages from sending
|
||||
- [#2605](https://github.com/TokTok/c-toxcore/pull/2605) fix: Don't use `memcmp` to compare `IP_Port`s.
|
||||
- [#2604](https://github.com/TokTok/c-toxcore/pull/2604) chore: Fix rpm build; add a CI check for it.
|
||||
- [#2603](https://github.com/TokTok/c-toxcore/pull/2603) chore: Speed up docker builds a bit by reducing layer count.
|
||||
- [#2602](https://github.com/TokTok/c-toxcore/pull/2602) cleanup: Add `const` where possible in auto tests.
|
||||
- [#2601](https://github.com/TokTok/c-toxcore/pull/2601) fix: a few off by one errors in group autotests
|
||||
- [#2598](https://github.com/TokTok/c-toxcore/pull/2598) refactor: Rename `system_{memory,...}` to `os_{memory,...}`.
|
||||
- [#2597](https://github.com/TokTok/c-toxcore/pull/2597) test: Add goblint static analyser.
|
||||
- [#2594](https://github.com/TokTok/c-toxcore/pull/2594) cleanup: Use `memzero(x, s)` instead of `memset(x, 0, s)`.
|
||||
- [#2593](https://github.com/TokTok/c-toxcore/pull/2593) cleanup: Use explicit 0 instead of `PACKET_ID_PADDING`.
|
||||
- [#2592](https://github.com/TokTok/c-toxcore/pull/2592) cleanup: Remove all uses of `SIZEOF_VLA`.
|
||||
- [#2591](https://github.com/TokTok/c-toxcore/pull/2591) cleanup: Expand the `Tox_Options` accessor macros.
|
||||
- [#2590](https://github.com/TokTok/c-toxcore/pull/2590) test: Add a simple new/delete test for Tox.
|
||||
- [#2588](https://github.com/TokTok/c-toxcore/pull/2588) cleanup: Remove plan9 support.
|
||||
- [#2587](https://github.com/TokTok/c-toxcore/pull/2587) cleanup: Add comment after every `#endif`.
|
||||
- [#2583](https://github.com/TokTok/c-toxcore/pull/2583) test: Fix comment I broke in the events test PR.
|
||||
- [#2582](https://github.com/TokTok/c-toxcore/pull/2582) cleanup: Rename group to conference in groupav documentation.
|
||||
- [#2581](https://github.com/TokTok/c-toxcore/pull/2581) cleanup: Ensure handler params are named after callback params.
|
||||
- [#2580](https://github.com/TokTok/c-toxcore/pull/2580) cleanup: Minor cleanup of event unpack code.
|
||||
- [#2578](https://github.com/TokTok/c-toxcore/pull/2578) refactor: Allow NULL pointers for byte arrays in events.
|
||||
- [#2577](https://github.com/TokTok/c-toxcore/pull/2577) refactor: Add common msgpack array packer with callback.
|
||||
- [#2576](https://github.com/TokTok/c-toxcore/pull/2576) cleanup: make some improvements to group moderation test
|
||||
- [#2575](https://github.com/TokTok/c-toxcore/pull/2575) refactor: Pass `this` pointer as first param to s11n callbacks.
|
||||
- [#2573](https://github.com/TokTok/c-toxcore/pull/2573) cleanup: skip a do_gc iteration before removing peers marked for deletion
|
||||
- [#2572](https://github.com/TokTok/c-toxcore/pull/2572) cleanup: Remove `bin_pack_{new,free}`.
|
||||
- [#2568](https://github.com/TokTok/c-toxcore/pull/2568) feat: Add dht_get_nodes_response event to the events system.
|
||||
- [#2567](https://github.com/TokTok/c-toxcore/pull/2567) refactor: Use enum-specific pack functions for enum values.
|
||||
- [#2566](https://github.com/TokTok/c-toxcore/pull/2566) cleanup: Remove empty test doing nothing.
|
||||
- [#2565](https://github.com/TokTok/c-toxcore/pull/2565) refactor: Factor out union pack switch from event packer.
|
||||
- [#2564](https://github.com/TokTok/c-toxcore/pull/2564) cleanup: Move the 2-element array pack out of individual events.
|
||||
- [#2563](https://github.com/TokTok/c-toxcore/pull/2563) test: Add printf log statement to group_moderation_test.
|
||||
- [#2562](https://github.com/TokTok/c-toxcore/pull/2562) chore: add clangd files to .gitignore
|
||||
- [#2561](https://github.com/TokTok/c-toxcore/pull/2561) refactor: Move file streaming test to its own file.
|
||||
- [#2560](https://github.com/TokTok/c-toxcore/pull/2560) fix(ci): window builds now build in parallel
|
||||
- [#2559](https://github.com/TokTok/c-toxcore/pull/2559) refactor: Migrate auto_tests to new events API.
|
||||
- [#2557](https://github.com/TokTok/c-toxcore/pull/2557) test: Add C++ classes wrapping system interfaces.
|
||||
- [#2555](https://github.com/TokTok/c-toxcore/pull/2555) fix: Remove fatal error for non-erroneous case
|
||||
- [#2554](https://github.com/TokTok/c-toxcore/pull/2554) fix: Make all the fuzzers work again, and add a test for protodump.
|
||||
- [#2552](https://github.com/TokTok/c-toxcore/pull/2552) fix: Make sure there's enough space for CONSUME1 in fuzzers.
|
||||
- [#2551](https://github.com/TokTok/c-toxcore/pull/2551) chore: Move from gcov to llvm source-based coverage.
|
||||
- [#2549](https://github.com/TokTok/c-toxcore/pull/2549) fix: issues with packet broadcast error reporting
|
||||
- [#2547](https://github.com/TokTok/c-toxcore/pull/2547) test: Add fuzz tests to the coverage run.
|
||||
- [#2545](https://github.com/TokTok/c-toxcore/pull/2545) refactor: Use `operator==` for equality tests of `Node_format`.
|
||||
- [#2543](https://github.com/TokTok/c-toxcore/pull/2543) refactor(test): Slightly nicer C++ interface to tox Random.
|
||||
- [#2542](https://github.com/TokTok/c-toxcore/pull/2542) refactor: packet broadcast functions now return errors
|
||||
- [#2541](https://github.com/TokTok/c-toxcore/pull/2541) fix: don't pass garbage data buffer to packet send functions
|
||||
- [#2540](https://github.com/TokTok/c-toxcore/pull/2540) cleanup: Make group packet entry creation less error-prone
|
||||
- [#2539](https://github.com/TokTok/c-toxcore/pull/2539) refactor: Minor refactoring of get_close_nodes functions.
|
||||
- [#2538](https://github.com/TokTok/c-toxcore/pull/2538) refactor: Factor out malloc+memcpy into memdup.
|
||||
- [#2536](https://github.com/TokTok/c-toxcore/pull/2536) cleanup: Some more test cleanups, removing overly smart code.
|
||||
- [#2531](https://github.com/TokTok/c-toxcore/pull/2531) test: Add more unit tests for `add_to_list`.
|
||||
- [#2530](https://github.com/TokTok/c-toxcore/pull/2530) refactor: Assign malloc return to a local variable first.
|
||||
- [#2529](https://github.com/TokTok/c-toxcore/pull/2529) test: Add "infer" CI check to github, remove from circle.
|
||||
- [#2527](https://github.com/TokTok/c-toxcore/pull/2527) cleanup: Add Toxav alias for ToxAV.
|
||||
- [#2526](https://github.com/TokTok/c-toxcore/pull/2526) cleanup: Make Tox_Options a typedef.
|
||||
- [#2525](https://github.com/TokTok/c-toxcore/pull/2525) cleanup: Add dynamically derived array sizes to the API.
|
||||
- [#2524](https://github.com/TokTok/c-toxcore/pull/2524) cleanup: Add explicit array sizes to toxencryptsave.
|
||||
- [#2523](https://github.com/TokTok/c-toxcore/pull/2523) cleanup: Move `tox_get_system` out of the public API.
|
||||
- [#2522](https://github.com/TokTok/c-toxcore/pull/2522) cleanup: Make setters take non-const `Tox *`.
|
||||
- [#2521](https://github.com/TokTok/c-toxcore/pull/2521) cleanup: Make array params in toxav `[]` instead of `*`.
|
||||
- [#2520](https://github.com/TokTok/c-toxcore/pull/2520) cleanup: Mark arrays in the tox API as `[]` instead of `*`.
|
||||
- [#2519](https://github.com/TokTok/c-toxcore/pull/2519) refactor: Align group message sending with other send functions.
|
||||
- [#2518](https://github.com/TokTok/c-toxcore/pull/2518) cleanup: Add typedefs for public API int identifiers.
|
||||
- [#2517](https://github.com/TokTok/c-toxcore/pull/2517) chore: Spellcheck tox-bootstrapd
|
||||
- [#2516](https://github.com/TokTok/c-toxcore/pull/2516) chore: Remove settings.yml in favour of hs-github-tools.
|
||||
- [#2515](https://github.com/TokTok/c-toxcore/pull/2515) chore: Use GPL license with https.
|
||||
- [#2513](https://github.com/TokTok/c-toxcore/pull/2513) chore: Add fetch-sha256 script to update bootstrap node hash.
|
||||
- [#2512](https://github.com/TokTok/c-toxcore/pull/2512) cleanup: Move all vptr-to-ptr casts to the beginning of a function.
|
||||
- [#2510](https://github.com/TokTok/c-toxcore/pull/2510) cleanup: Use github actions matrix to simplify CI.
|
||||
- [#2509](https://github.com/TokTok/c-toxcore/pull/2509) fix: Use QueryPerformanceCounter on windows for monotonic time.
|
||||
- [#2508](https://github.com/TokTok/c-toxcore/pull/2508) chore: Add `net_(new|kill)_strerror` to cppcheck's allocators.
|
||||
- [#2507](https://github.com/TokTok/c-toxcore/pull/2507) cleanup: Run clang-tidy on headers, as well.
|
||||
- [#2506](https://github.com/TokTok/c-toxcore/pull/2506) cleanup: Make TCP connection failures a warning instead of error.
|
||||
- [#2505](https://github.com/TokTok/c-toxcore/pull/2505) cleanup: Make all .c files include the headers they need.
|
||||
- [#2504](https://github.com/TokTok/c-toxcore/pull/2504) cleanup: Upgrade cppcheck, fix some warnings.
|
||||
- [#2503](https://github.com/TokTok/c-toxcore/pull/2503) cleanup: Upgrade to clang-tidy-17 and fix some warnings.
|
||||
- [#2502](https://github.com/TokTok/c-toxcore/pull/2502) chore: Use `pkg_search_module` directly in cmake.
|
||||
- [#2501](https://github.com/TokTok/c-toxcore/pull/2501) chore: Add `IMPORTED_TARGET` to pkg-config packages.
|
||||
- [#2499](https://github.com/TokTok/c-toxcore/pull/2499) cleanup: Use target_link_libraries directly in cmake.
|
||||
- [#2498](https://github.com/TokTok/c-toxcore/pull/2498) chore: Simplify msvc build using vcpkg.
|
||||
- [#2497](https://github.com/TokTok/c-toxcore/pull/2497) cleanup: Remove NaCl support.
|
||||
- [#2494](https://github.com/TokTok/c-toxcore/pull/2494) fix: unpack enum function names in event impl generator
|
||||
- [#2493](https://github.com/TokTok/c-toxcore/pull/2493) chore: Disable targets for cross-compilation.
|
||||
- [#2491](https://github.com/TokTok/c-toxcore/pull/2491) chore: Build a docker image with coverage info in it.
|
||||
- [#2490](https://github.com/TokTok/c-toxcore/pull/2490) cleanup: Some portability/warning fixes for Windows builds.
|
||||
- [#2488](https://github.com/TokTok/c-toxcore/pull/2488) fix: Correct a use-after-free and fix some memory leaks.
|
||||
- [#2487](https://github.com/TokTok/c-toxcore/pull/2487) refactor: Change all enum-like `#define` sequences into enums.
|
||||
- [#2486](https://github.com/TokTok/c-toxcore/pull/2486) refactor: Change the `TCP_PACKET_*` defines into an enum.
|
||||
- [#2485](https://github.com/TokTok/c-toxcore/pull/2485) refactor: event generation tool for reorder pr
|
||||
- [#2484](https://github.com/TokTok/c-toxcore/pull/2484) chore: Fix make_single_file to support core-only.
|
||||
- [#2481](https://github.com/TokTok/c-toxcore/pull/2481) chore: Update github actions `uses`.
|
||||
- [#2480](https://github.com/TokTok/c-toxcore/pull/2480) feat: add ngc related unpack functions
|
||||
- [#2479](https://github.com/TokTok/c-toxcore/pull/2479) feat: Add `to_string` functions for all public enums.
|
||||
- [#2477](https://github.com/TokTok/c-toxcore/pull/2477) test: add real timeout test
|
||||
- [#2476](https://github.com/TokTok/c-toxcore/pull/2476) chore: Move s390x build to post-merge.
|
||||
- [#2475](https://github.com/TokTok/c-toxcore/pull/2475) refactor: Give `enum-from-int` functions the ability to report errors.
|
||||
- [#2474](https://github.com/TokTok/c-toxcore/pull/2474) cleanup: Remove test net support.
|
||||
- [#2472](https://github.com/TokTok/c-toxcore/pull/2472) feat: Enable ubsan on bootstrap nodes.
|
||||
- [#2470](https://github.com/TokTok/c-toxcore/pull/2470) test: Add check-c run to bazel build.
|
||||
- [#2468](https://github.com/TokTok/c-toxcore/pull/2468) fix(test): tests use ipv6 by default, even with USE_IPV6 set to 0
|
||||
- [#2466](https://github.com/TokTok/c-toxcore/pull/2466) cleanup: Make group saving/loading more forgiving with data errors
|
||||
- [#2465](https://github.com/TokTok/c-toxcore/pull/2465) refactor: replace memset with a loop
|
||||
- [#2459](https://github.com/TokTok/c-toxcore/pull/2459) fix: Enable debug flag for ubsan.
|
||||
- [#2458](https://github.com/TokTok/c-toxcore/pull/2458) fix: also Install header for private/experimental API functions with autotools
|
||||
- [#2456](https://github.com/TokTok/c-toxcore/pull/2456) docs: Remove defunct IRC channel from README.md
|
||||
- [#2454](https://github.com/TokTok/c-toxcore/pull/2454) fix: memory leaks
|
||||
- [#2453](https://github.com/TokTok/c-toxcore/pull/2453) refactor: Install header for private/experimental API functions
|
||||
- [#2452](https://github.com/TokTok/c-toxcore/pull/2452) refactor: replace DEFAULT_TCP_RELAY_PORTS_COUNT with a compile-time calculation
|
||||
- [#2451](https://github.com/TokTok/c-toxcore/pull/2451) cleanup: clarify disabling of static assert checks
|
||||
- [#2449](https://github.com/TokTok/c-toxcore/pull/2449) cleanup: replace tabs with spaces
|
||||
- [#2448](https://github.com/TokTok/c-toxcore/pull/2448) feat: group connection queries now return our own connection type
|
||||
- [#2447](https://github.com/TokTok/c-toxcore/pull/2447) fix: Docker tox-bootstrapd hash update failing when using BuildKit
|
||||
- [#2446](https://github.com/TokTok/c-toxcore/pull/2446) feat: Add groupchat API function that returns an IP address string for a peer
|
||||
- [#2442](https://github.com/TokTok/c-toxcore/pull/2442) perf: Slightly reduce bandwidth usage when there are few nodes.
|
||||
- [#2439](https://github.com/TokTok/c-toxcore/pull/2439) test: Make esp32 build actually try to instantiate tox.
|
||||
- [#2438](https://github.com/TokTok/c-toxcore/pull/2438) cleanup: Remove explicit layering_check feature.
|
||||
- [#2437](https://github.com/TokTok/c-toxcore/pull/2437) chore: Upgrade sonar-scan jvm to java 17.
|
||||
- [#2436](https://github.com/TokTok/c-toxcore/pull/2436) fix: Add missing `htons` call when adding configured TCP relay.
|
||||
- [#2434](https://github.com/TokTok/c-toxcore/pull/2434) chore: Cancel old PR builds on docker and sonar-scan workflows.
|
||||
- [#2432](https://github.com/TokTok/c-toxcore/pull/2432) chore: Use C99 on MSVC instead of C11.
|
||||
- [#2430](https://github.com/TokTok/c-toxcore/pull/2430) chore: Retry freebsd tests 2 times.
|
||||
- [#2429](https://github.com/TokTok/c-toxcore/pull/2429) test: Add an s390x build (on alpine) for CI.
|
||||
- [#2428](https://github.com/TokTok/c-toxcore/pull/2428) chore: Add a compcert docker run script.
|
||||
- [#2427](https://github.com/TokTok/c-toxcore/pull/2427) cleanup: Use tcc docker image for CI.
|
||||
- [#2424](https://github.com/TokTok/c-toxcore/pull/2424) fix: Fix memory leak in the error path of loading savedata.
|
||||
- [#2420](https://github.com/TokTok/c-toxcore/pull/2420) refactor: Use Bin_Pack for packing Node_format.
|
||||
- [#2416](https://github.com/TokTok/c-toxcore/pull/2416) chore: Add more logging to loading conferences from savedata.
|
||||
- [#2415](https://github.com/TokTok/c-toxcore/pull/2415) refactor: Add a `bin_unpack_bin_max` for max-length arrays.
|
||||
- [#2414](https://github.com/TokTok/c-toxcore/pull/2414) fix: inversed return values
|
||||
- [#2413](https://github.com/TokTok/c-toxcore/pull/2413) cleanup: Fix GCC compatibility.
|
||||
- [#2408](https://github.com/TokTok/c-toxcore/pull/2408) fix: Ensure we have allocators available for the error paths.
|
||||
- [#2407](https://github.com/TokTok/c-toxcore/pull/2407) cleanup: Remove redundant `-DSODIUM_EXPORT` from definitions.
|
||||
- [#2406](https://github.com/TokTok/c-toxcore/pull/2406) cleanup: Fix a few more clang-tidy warnings.
|
||||
- [#2405](https://github.com/TokTok/c-toxcore/pull/2405) cleanup: Fix a few more clang-tidy warnings.
|
||||
- [#2404](https://github.com/TokTok/c-toxcore/pull/2404) cleanup: Enforce stricter identifier naming using clang-tidy.
|
||||
- [#2396](https://github.com/TokTok/c-toxcore/pull/2396) chore: Add devcontainer setup for codespaces.
|
||||
- [#2393](https://github.com/TokTok/c-toxcore/pull/2393) refactor: Add `mem` module to allow tests to override allocators.
|
||||
- [#2392](https://github.com/TokTok/c-toxcore/pull/2392) refactor: Make event dispatch ordered by receive time.
|
||||
- [#2391](https://github.com/TokTok/c-toxcore/pull/2391) docs: Fix doxygen config and remove some redundant comments.
|
||||
- [#2390](https://github.com/TokTok/c-toxcore/pull/2390) chore: Fix the Android CI job
|
||||
- [#2389](https://github.com/TokTok/c-toxcore/pull/2389) fix: Add missing `#include <array>`.
|
||||
- [#2388](https://github.com/TokTok/c-toxcore/pull/2388) chore: Add missing module dependencies.
|
||||
- [#2384](https://github.com/TokTok/c-toxcore/pull/2384) feat: increase NGC lossy custom packet size
|
||||
- [#2383](https://github.com/TokTok/c-toxcore/pull/2383) fix: add missing ngc constants getter declarations and definitions
|
||||
- [#2381](https://github.com/TokTok/c-toxcore/pull/2381) fix: incorrect documentation
|
||||
- [#2380](https://github.com/TokTok/c-toxcore/pull/2380) feat: allow for larger incoming NGC packets
|
||||
- [#2371](https://github.com/TokTok/c-toxcore/pull/2371) docs: fix group_peer_exit_cb
|
||||
- [#2370](https://github.com/TokTok/c-toxcore/pull/2370) fix: behaviour of group api function
|
||||
- [#2369](https://github.com/TokTok/c-toxcore/pull/2369) fix: flaky tcp test
|
||||
- [#2367](https://github.com/TokTok/c-toxcore/pull/2367) fix: fuzz support for TCP server
|
||||
- [#2364](https://github.com/TokTok/c-toxcore/pull/2364) fix: potential endless loop under extremely high load
|
||||
- [#2362](https://github.com/TokTok/c-toxcore/pull/2362) test: enable tcp relay for bootstrap fuzzing
|
||||
- [#2361](https://github.com/TokTok/c-toxcore/pull/2361) fix: resolve_bootstrap_node() not checking net_getipport() returned count correctly
|
||||
- [#2357](https://github.com/TokTok/c-toxcore/pull/2357) feat: get the number of close dht nodes with announce/store support
|
||||
- [#2355](https://github.com/TokTok/c-toxcore/pull/2355) fix: group custom packet size limits
|
||||
- [#2354](https://github.com/TokTok/c-toxcore/pull/2354) fix: DHTBootstrap should always respond to version packets with toxcore version
|
||||
- [#2351](https://github.com/TokTok/c-toxcore/pull/2351) fix: Increase max group message length by four bytes
|
||||
- [#2348](https://github.com/TokTok/c-toxcore/pull/2348) refactor: Make some improvements to how often/when we announce a group
|
||||
- [#2341](https://github.com/TokTok/c-toxcore/pull/2341) fix: #1144 by forcing misc_tools to be a static lib
|
||||
- [#2340](https://github.com/TokTok/c-toxcore/pull/2340) fix: missing net to host conversion of port in logging in group_chat.c
|
||||
- [#2339](https://github.com/TokTok/c-toxcore/pull/2339) fix: missing net to host conversion of port in logging
|
||||
- [#2338](https://github.com/TokTok/c-toxcore/pull/2338) fix: bug causing friend group invites to sometimes fail & improve logging
|
||||
- [#2333](https://github.com/TokTok/c-toxcore/pull/2333) docs: Update README for bootstrap node docker
|
||||
- [#2329](https://github.com/TokTok/c-toxcore/pull/2329) refactor: extract each case in handle packet in messenger
|
||||
- [#2327](https://github.com/TokTok/c-toxcore/pull/2327) fix: unlock correct dht_friend
|
||||
- [#2325](https://github.com/TokTok/c-toxcore/pull/2325) fix: Remove cmake cache files after copying to container build directory
|
||||
- [#2323](https://github.com/TokTok/c-toxcore/pull/2323) docs: Update README.md to include cmp submodule info
|
||||
- [#2318](https://github.com/TokTok/c-toxcore/pull/2318) chore: disable warning about pre C99 code
|
||||
- [#2317](https://github.com/TokTok/c-toxcore/pull/2317) Refactor: Extract shared key cache into separate file
|
||||
- [#2311](https://github.com/TokTok/c-toxcore/pull/2311) cleanup: make it more clear that assert and uint32_t increment both only exist if NDEBUG is not defined
|
||||
- [#2291](https://github.com/TokTok/c-toxcore/pull/2291) test: Add a protocol dump test to generate initial fuzzer input.
|
||||
- [#2271](https://github.com/TokTok/c-toxcore/pull/2271) chore: Migrate from Appveyor to Azure Pipelines
|
||||
- [#2269](https://github.com/TokTok/c-toxcore/pull/2269) feat: Merge the remainder of the new groupchats implementation
|
||||
- [#2203](https://github.com/TokTok/c-toxcore/pull/2203) refactor: Store time in Mono_Time in milliseconds.
|
||||
- [#1944](https://github.com/TokTok/c-toxcore/pull/1944) chore: tox_new() should return null when savedata loading fails
|
||||
|
||||
### Closed issues:
|
||||
|
||||
- [#2739](https://github.com/TokTok/c-toxcore/issues/2739) Tox_Options.operating_system is not clear about it being an experimental option
|
||||
- [#2734](https://github.com/TokTok/c-toxcore/issues/2734) error compiling on fedora
|
||||
- [#2649](https://github.com/TokTok/c-toxcore/issues/2649) create_extended_keypair should use Random and be made deterministic for fuzzing
|
||||
- [#2358](https://github.com/TokTok/c-toxcore/issues/2358) resolve_bootstrap_node assert hit
|
||||
- [#2352](https://github.com/TokTok/c-toxcore/issues/2352) SEGV after infinite loop retrying proxy_socks5_read_connection_response
|
||||
- [#2335](https://github.com/TokTok/c-toxcore/issues/2335) ipv6 disabled on kernel cmdline disrupts Tox = most tests fail
|
||||
- [#2303](https://github.com/TokTok/c-toxcore/issues/2303) Add new group chats events to tox_events and tox_dispatch modules.
|
||||
- [#2302](https://github.com/TokTok/c-toxcore/issues/2302) Run strong fuzz tests against NGC
|
||||
- [#2301](https://github.com/TokTok/c-toxcore/issues/2301) Implement NGC save/load in hs-toxcore and run round-trip tests against c-toxcore
|
||||
- [#2192](https://github.com/TokTok/c-toxcore/issues/2192) Provide official signed release tarballs
|
||||
- [#2118](https://github.com/TokTok/c-toxcore/issues/2118) Add a private "get mono_time" API to `tox_private.h` and use it in auto_tests.
|
||||
- [#2029](https://github.com/TokTok/c-toxcore/issues/2029) Migrate all auto tests to the events API.
|
||||
- [#2014](https://github.com/TokTok/c-toxcore/issues/2014) Add sodium autotools CI build
|
||||
- [#1144](https://github.com/TokTok/c-toxcore/issues/1144) DHT_bootstrap should not link against misc_tools
|
||||
|
||||
## v0.2.18
|
||||
|
||||
### Merged PRs:
|
||||
|
||||
- [#2300](https://github.com/TokTok/c-toxcore/pull/2300) chore: Release 0.2.18
|
||||
- [#2299](https://github.com/TokTok/c-toxcore/pull/2299) fix: remove the assert because buffer can be larger than UINT16_MAX.
|
||||
- [#2297](https://github.com/TokTok/c-toxcore/pull/2297) cleanup: remove unused field last_seen from Onion_Friend
|
||||
- [#2289](https://github.com/TokTok/c-toxcore/pull/2289) test: Add a Null_System used in toxsave_harness.
|
||||
@ -107,6 +372,7 @@
|
||||
|
||||
### Closed issues:
|
||||
|
||||
- [#2298](https://github.com/TokTok/c-toxcore/issues/2298) assert makes incorrect assumption
|
||||
- [#2256](https://github.com/TokTok/c-toxcore/issues/2256) New Defects reported by Coverity Scan for TokTok/c-toxcore
|
||||
- [#2109](https://github.com/TokTok/c-toxcore/issues/2109) Assimilate `messenger_test.c`: replace with public API test
|
||||
- [#2012](https://github.com/TokTok/c-toxcore/issues/2012) Support building a DLL on Windows
|
643
CMakeLists.txt
643
CMakeLists.txt
@ -1,67 +1,610 @@
|
||||
cmake_minimum_required(VERSION 3.14...3.24 FATAL_ERROR)
|
||||
################################################################################
|
||||
#
|
||||
# The main toxcore CMake build file.
|
||||
#
|
||||
# This file when processed with cmake produces:
|
||||
# - A number of small libraries (.a/.so/...) containing independent components
|
||||
# of toxcore. E.g. the DHT has its own library, and the system/network
|
||||
# abstractions are in their own library as well. These libraries are not
|
||||
# installed on `make install`. The toxav, and toxencryptsave libraries are
|
||||
# also not installed.
|
||||
# - A number of small programs, statically linked if possible.
|
||||
# - One big library containing all of the toxcore, toxav, and toxencryptsave
|
||||
# code.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
# cmake setup begin
|
||||
project(tomato)
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
cmake_policy(VERSION 3.16)
|
||||
project(toxcore)
|
||||
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
list(APPEND CMAKE_MODULE_PATH ${toxcore_SOURCE_DIR}/cmake)
|
||||
|
||||
# defaulting to debug mode, if not specified
|
||||
if (NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE "Debug")
|
||||
option(FLAT_OUTPUT_STRUCTURE "Whether to produce output artifacts in ${CMAKE_BINARY_DIR}/{bin,lib}" OFF)
|
||||
if(FLAT_OUTPUT_STRUCTURE)
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||
endif()
|
||||
|
||||
# setup my vim ycm :D
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
set_source_files_properties(
|
||||
toxcore/mono_time.c
|
||||
toxcore/network.c
|
||||
toxcore/tox.c
|
||||
toxcore/util.c
|
||||
PROPERTIES SKIP_UNITY_BUILD_INCLUSION TRUE)
|
||||
|
||||
# more paths
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
|
||||
################################################################################
|
||||
#
|
||||
# :: Version management
|
||||
#
|
||||
################################################################################
|
||||
|
||||
option(TOMATO_ASAN "Build tomato with asan (gcc/clang/msvc)" OFF)
|
||||
# This version is for the entire project. All libraries (core, av, ...) move in
|
||||
# versions in a synchronised way.
|
||||
set(PROJECT_VERSION_MAJOR "0")
|
||||
set(PROJECT_VERSION_MINOR "2")
|
||||
set(PROJECT_VERSION_PATCH "19")
|
||||
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
|
||||
|
||||
if (TOMATO_ASAN)
|
||||
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
|
||||
if (NOT WIN32) # exclude mingw
|
||||
link_libraries(-fsanitize=address)
|
||||
#link_libraries(-fsanitize=address,undefined)
|
||||
#link_libraries(-fsanitize=undefined)
|
||||
message("II enabled ASAN")
|
||||
else()
|
||||
message("!! can not enable ASAN on this platform (gcc/clang + win)")
|
||||
endif()
|
||||
elseif (MSVC)
|
||||
add_compile_options("/fsanitize=address")
|
||||
message("II enabled ASAN")
|
||||
else()
|
||||
message("!! can not enable ASAN on this platform")
|
||||
endif()
|
||||
# set .so library version / following libtool scheme
|
||||
# https://www.gnu.org/software/libtool/manual/libtool.html#Updating-version-info
|
||||
file(STRINGS ${toxcore_SOURCE_DIR}/so.version SOVERSION_CURRENT REGEX "^CURRENT=[0-9]+$")
|
||||
string(SUBSTRING "${SOVERSION_CURRENT}" 8 -1 SOVERSION_CURRENT)
|
||||
file(STRINGS ${toxcore_SOURCE_DIR}/so.version SOVERSION_REVISION REGEX "^REVISION=[0-9]+$")
|
||||
string(SUBSTRING "${SOVERSION_REVISION}" 9 -1 SOVERSION_REVISION)
|
||||
file(STRINGS ${toxcore_SOURCE_DIR}/so.version SOVERSION_AGE REGEX "^AGE=[0-9]+$")
|
||||
string(SUBSTRING "${SOVERSION_AGE}" 4 -1 SOVERSION_AGE)
|
||||
# account for some libtool magic, see other/version-sync script for details
|
||||
math(EXPR SOVERSION_MAJOR ${SOVERSION_CURRENT}-${SOVERSION_AGE})
|
||||
set(SOVERSION "${SOVERSION_MAJOR}.${SOVERSION_AGE}.${SOVERSION_REVISION}")
|
||||
message("SOVERSION: ${SOVERSION}")
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# :: Dependencies and configuration
|
||||
#
|
||||
################################################################################
|
||||
|
||||
include(CTest)
|
||||
include(ModulePackage)
|
||||
include(StrictAbi)
|
||||
include(GNUInstallDirs)
|
||||
|
||||
if(APPLE)
|
||||
include(MacRpath)
|
||||
endif()
|
||||
|
||||
# external libs
|
||||
add_subdirectory(./external) # before increasing warn levels, sad :(
|
||||
enable_testing()
|
||||
find_package(GTest)
|
||||
|
||||
set(CMAKE_MACOSX_RPATH ON)
|
||||
|
||||
# Set standard version for compiler.
|
||||
if(MSVC AND MSVC_TOOLSET_VERSION LESS 143)
|
||||
# https://developercommunity.visualstudio.com/t/older-winsdk-headers-are-incompatible-with-zcprepr/1593479
|
||||
set(CMAKE_C_STANDARD 99)
|
||||
else()
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
endif()
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_C_EXTENSIONS OFF)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
# bump up warning levels appropriately for clang, gcc & msvc
|
||||
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
|
||||
add_compile_options(
|
||||
-Wall -Wextra # Reasonable and standard
|
||||
-Wpedantic # Warn if non-standard C++ is used
|
||||
-Wunused # Warn on anything being unused
|
||||
#-Wconversion # Warn on type conversions that may lose data
|
||||
#-Wsign-conversion # Warn on sign conversions
|
||||
-Wshadow # Warn if a variable declaration shadows one from a parent context
|
||||
)
|
||||
elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")
|
||||
if (MSVC)
|
||||
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
else()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
|
||||
endif()
|
||||
message(STATUS "Supported C compiler features = ${CMAKE_C_COMPILE_FEATURES}")
|
||||
message(STATUS "Supported C++ compiler features = ${CMAKE_CXX_COMPILE_FEATURES}")
|
||||
|
||||
# Enable some warnings if we know the compiler.
|
||||
if(MSVC)
|
||||
add_compile_options(/W4 /analyze)
|
||||
add_compile_options(/wd4100) # unreferenced formal parameter
|
||||
add_compile_options(/wd4267) # narrowing conversion
|
||||
add_compile_options(/wd4244) # narrowing conversion
|
||||
add_compile_options(/wd4127) # conditional expression is constant
|
||||
add_compile_options(/wd4995) # #pragma deprecated
|
||||
add_compile_options(/wd4018) # signed/unsigned compare
|
||||
add_compile_options(/wd4310) # cast truncates constant value
|
||||
add_compile_options(/wd4389) # signed/unsigned compare
|
||||
add_compile_options(/wd4245) # signed/unsigned assign/return/function call
|
||||
add_compile_options(/wd4200) # nonstandard extension used: zero-sized array in struct/union
|
||||
add_compile_options(/wd4702) # unreachable code
|
||||
add_compile_options(/wd6340) # unsigned int passed to signed parameter
|
||||
add_compile_options(/wd6326) # potential comparison of a constant with another constant
|
||||
|
||||
# TODO(iphydf): Look into these
|
||||
add_compile_options(/wd4996) # use WSAAddressToStringW() instead of WSAAddressToStringA()
|
||||
add_compile_options(/wd6255) # don't use alloca
|
||||
add_compile_options(/wd6385) # reading invalid data
|
||||
add_compile_options(/wd6001) # using uninitialized memory
|
||||
add_compile_options(/wd6101) # returning uninitialized memory
|
||||
add_compile_options(/wd6386) # buffer overrun
|
||||
add_compile_options(/wd6011) # NULL dereference
|
||||
add_compile_options(/wd6031) # sscanf return value ignored
|
||||
add_compile_options(/wd6387) # passing NULL to fwrite
|
||||
endif()
|
||||
|
||||
# cmake setup end
|
||||
set(MIN_LOGGER_LEVEL "" CACHE STRING "Logging level to use (TRACE, DEBUG, INFO, WARNING, ERROR)")
|
||||
if(MIN_LOGGER_LEVEL)
|
||||
if(("${MIN_LOGGER_LEVEL}" STREQUAL "TRACE") OR
|
||||
("${MIN_LOGGER_LEVEL}" STREQUAL "DEBUG") OR
|
||||
("${MIN_LOGGER_LEVEL}" STREQUAL "INFO") OR
|
||||
("${MIN_LOGGER_LEVEL}" STREQUAL "WARNING") OR
|
||||
("${MIN_LOGGER_LEVEL}" STREQUAL "ERROR"))
|
||||
add_definitions(-DMIN_LOGGER_LEVEL=LOGGER_LEVEL_${MIN_LOGGER_LEVEL})
|
||||
else()
|
||||
message(FATAL_ERROR "Unknown value provided for MIN_LOGGER_LEVEL: \"${MIN_LOGGER_LEVEL}\", must be one of TRACE, DEBUG, INFO, WARNING or ERROR")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_subdirectory(./src)
|
||||
option(EXPERIMENTAL_API "Install experimental header file with unstable API" OFF)
|
||||
|
||||
option(USE_IPV6 "Use IPv6 in tests" ON)
|
||||
if(NOT USE_IPV6)
|
||||
add_definitions(-DUSE_IPV6=0)
|
||||
endif()
|
||||
|
||||
option(BUILD_MISC_TESTS "Build additional tests" OFF)
|
||||
option(BUILD_FUN_UTILS "Build additional just for fun utilities" OFF)
|
||||
|
||||
option(UNITTEST "Enable unit tests (disable if you don't have a working gmock or gtest)" ON)
|
||||
|
||||
option(AUTOTEST "Enable autotests (mainly for CI)" OFF)
|
||||
if(AUTOTEST)
|
||||
option(NON_HERMETIC_TESTS "Whether to build and run tests that depend on an internet connection" OFF)
|
||||
option(PROXY_TEST "Enable proxy test (requires other/proxy/proxy_server.go to be running)" OFF)
|
||||
endif()
|
||||
|
||||
option(BUILD_TOXAV "Whether to build the tox AV library" ON)
|
||||
option(MUST_BUILD_TOXAV "Fail the build if toxav cannot be built" OFF)
|
||||
|
||||
option(DHT_BOOTSTRAP "Enable building of DHT_bootstrap" ON)
|
||||
option(BOOTSTRAP_DAEMON "Enable building of tox-bootstrapd" ON)
|
||||
if(BOOTSTRAP_DAEMON AND WIN32)
|
||||
message(WARNING "Building tox-bootstrapd for Windows is not supported, disabling")
|
||||
set(BOOTSTRAP_DAEMON OFF)
|
||||
endif()
|
||||
|
||||
option(BUILD_FUZZ_TESTS "Build fuzzing harnesses" OFF)
|
||||
|
||||
if(MSVC)
|
||||
option(MSVC_STATIC_SODIUM "Whether to link libsodium statically for MSVC" OFF)
|
||||
if(MSVC_STATIC_SODIUM)
|
||||
add_definitions(-DSODIUM_STATIC=1)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
include(Dependencies)
|
||||
|
||||
if(MUST_BUILD_TOXAV)
|
||||
set(NO_TOXAV_ERROR_TYPE SEND_ERROR)
|
||||
else()
|
||||
set(NO_TOXAV_ERROR_TYPE WARNING)
|
||||
endif()
|
||||
|
||||
if(BUILD_TOXAV)
|
||||
if(NOT OPUS_FOUND)
|
||||
message(${NO_TOXAV_ERROR_TYPE} "Option BUILD_TOXAV is enabled but required library OPUS was not found.")
|
||||
set(BUILD_TOXAV OFF)
|
||||
endif()
|
||||
if(NOT VPX_FOUND)
|
||||
message(${NO_TOXAV_ERROR_TYPE} "Option BUILD_TOXAV is enabled but required library VPX was not found.")
|
||||
set(BUILD_TOXAV OFF)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Disable float/double packing in CMP (C MessagePack library).
|
||||
# We don't transfer floats over the network, so we disable this functionality.
|
||||
add_definitions(-DCMP_NO_FLOAT=1)
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# :: Tox Core Library
|
||||
#
|
||||
################################################################################
|
||||
|
||||
# toxcore_PKGCONFIG_LIBS is what's added to the Libs: line in toxcore.pc. It
|
||||
# needs to contain all the libraries a program using toxcore should link against
|
||||
# if it's statically linked. If it's dynamically linked, there is no need to
|
||||
# explicitly link against all the dependencies, but it doesn't harm much(*)
|
||||
# either.
|
||||
#
|
||||
# (*) It allows client code to use symbols from our dependencies without
|
||||
# explicitly linking against them.
|
||||
set(toxcore_PKGCONFIG_LIBS)
|
||||
# Requires: in pkg-config file.
|
||||
set(toxcore_PKGCONFIG_REQUIRES)
|
||||
|
||||
set(toxcore_SOURCES
|
||||
third_party/cmp/cmp.c
|
||||
third_party/cmp/cmp.h
|
||||
toxcore/announce.c
|
||||
toxcore/announce.h
|
||||
toxcore/bin_pack.c
|
||||
toxcore/bin_pack.h
|
||||
toxcore/bin_unpack.c
|
||||
toxcore/bin_unpack.h
|
||||
toxcore/ccompat.c
|
||||
toxcore/ccompat.h
|
||||
toxcore/crypto_core.c
|
||||
toxcore/crypto_core.h
|
||||
toxcore/crypto_core_pack.c
|
||||
toxcore/crypto_core_pack.h
|
||||
toxcore/DHT.c
|
||||
toxcore/DHT.h
|
||||
toxcore/events/conference_connected.c
|
||||
toxcore/events/conference_invite.c
|
||||
toxcore/events/conference_message.c
|
||||
toxcore/events/conference_peer_list_changed.c
|
||||
toxcore/events/conference_peer_name.c
|
||||
toxcore/events/conference_title.c
|
||||
toxcore/events/dht_get_nodes_response.c
|
||||
toxcore/events/events_alloc.c
|
||||
toxcore/events/events_alloc.h
|
||||
toxcore/events/file_chunk_request.c
|
||||
toxcore/events/file_recv.c
|
||||
toxcore/events/file_recv_chunk.c
|
||||
toxcore/events/file_recv_control.c
|
||||
toxcore/events/friend_connection_status.c
|
||||
toxcore/events/friend_lossless_packet.c
|
||||
toxcore/events/friend_lossy_packet.c
|
||||
toxcore/events/friend_message.c
|
||||
toxcore/events/friend_name.c
|
||||
toxcore/events/friend_read_receipt.c
|
||||
toxcore/events/friend_request.c
|
||||
toxcore/events/friend_status.c
|
||||
toxcore/events/friend_status_message.c
|
||||
toxcore/events/friend_typing.c
|
||||
toxcore/events/self_connection_status.c
|
||||
toxcore/events/group_custom_packet.c
|
||||
toxcore/events/group_custom_private_packet.c
|
||||
toxcore/events/group_invite.c
|
||||
toxcore/events/group_join_fail.c
|
||||
toxcore/events/group_message.c
|
||||
toxcore/events/group_moderation.c
|
||||
toxcore/events/group_password.c
|
||||
toxcore/events/group_peer_exit.c
|
||||
toxcore/events/group_peer_join.c
|
||||
toxcore/events/group_peer_limit.c
|
||||
toxcore/events/group_peer_name.c
|
||||
toxcore/events/group_peer_status.c
|
||||
toxcore/events/group_privacy_state.c
|
||||
toxcore/events/group_private_message.c
|
||||
toxcore/events/group_self_join.c
|
||||
toxcore/events/group_topic.c
|
||||
toxcore/events/group_topic_lock.c
|
||||
toxcore/events/group_voice_state.c
|
||||
toxcore/forwarding.c
|
||||
toxcore/forwarding.h
|
||||
toxcore/friend_connection.c
|
||||
toxcore/friend_connection.h
|
||||
toxcore/friend_requests.c
|
||||
toxcore/friend_requests.h
|
||||
toxcore/group.c
|
||||
toxcore/group_chats.c
|
||||
toxcore/group_chats.h
|
||||
toxcore/group_common.h
|
||||
toxcore/group_connection.c
|
||||
toxcore/group_connection.h
|
||||
toxcore/group.h
|
||||
toxcore/group_announce.c
|
||||
toxcore/group_announce.h
|
||||
toxcore/group_moderation.c
|
||||
toxcore/group_moderation.h
|
||||
toxcore/group_onion_announce.c
|
||||
toxcore/group_onion_announce.h
|
||||
toxcore/group_pack.c
|
||||
toxcore/group_pack.h
|
||||
toxcore/LAN_discovery.c
|
||||
toxcore/LAN_discovery.h
|
||||
toxcore/list.c
|
||||
toxcore/list.h
|
||||
toxcore/logger.c
|
||||
toxcore/logger.h
|
||||
toxcore/Messenger.c
|
||||
toxcore/Messenger.h
|
||||
toxcore/mem.c
|
||||
toxcore/mem.h
|
||||
toxcore/mono_time.c
|
||||
toxcore/mono_time.h
|
||||
toxcore/net_crypto.c
|
||||
toxcore/net_crypto.h
|
||||
toxcore/network.c
|
||||
toxcore/network.h
|
||||
toxcore/onion_announce.c
|
||||
toxcore/onion_announce.h
|
||||
toxcore/onion.c
|
||||
toxcore/onion_client.c
|
||||
toxcore/onion_client.h
|
||||
toxcore/onion.h
|
||||
toxcore/ping_array.c
|
||||
toxcore/ping_array.h
|
||||
toxcore/ping.c
|
||||
toxcore/ping.h
|
||||
toxcore/shared_key_cache.c
|
||||
toxcore/shared_key_cache.h
|
||||
toxcore/state.c
|
||||
toxcore/state.h
|
||||
toxcore/TCP_client.c
|
||||
toxcore/TCP_client.h
|
||||
toxcore/TCP_common.c
|
||||
toxcore/TCP_common.h
|
||||
toxcore/TCP_connection.c
|
||||
toxcore/TCP_connection.h
|
||||
toxcore/TCP_server.c
|
||||
toxcore/TCP_server.h
|
||||
toxcore/timed_auth.c
|
||||
toxcore/timed_auth.h
|
||||
toxcore/tox_api.c
|
||||
toxcore/tox.c
|
||||
toxcore/tox_dispatch.c
|
||||
toxcore/tox_dispatch.h
|
||||
toxcore/tox_event.c
|
||||
toxcore/tox_event.h
|
||||
toxcore/tox_events.c
|
||||
toxcore/tox_events.h
|
||||
toxcore/tox.h
|
||||
toxcore/tox_private.c
|
||||
toxcore/tox_private.h
|
||||
toxcore/tox_pack.c
|
||||
toxcore/tox_pack.h
|
||||
toxcore/tox_unpack.c
|
||||
toxcore/tox_unpack.h
|
||||
toxcore/util.c
|
||||
toxcore/util.h)
|
||||
if(TARGET unofficial-sodium::sodium)
|
||||
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} unofficial-sodium::sodium)
|
||||
else()
|
||||
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} ${LIBSODIUM_LIBRARIES})
|
||||
set(toxcore_LINK_DIRECTORIES ${toxcore_LINK_DIRECTORIES} ${LIBSODIUM_LIBRARY_DIRS})
|
||||
set(toxcore_INCLUDE_DIRECTORIES ${toxcore_INCLUDE_DIRECTORIES} ${LIBSODIUM_INCLUDE_DIRS})
|
||||
set(toxcore_COMPILE_OPTIONS ${toxcore_COMPILE_OPTIONS} ${LIBSODIUM_CFLAGS_OTHER})
|
||||
endif()
|
||||
set(toxcore_PKGCONFIG_REQUIRES ${toxcore_PKGCONFIG_REQUIRES} libsodium)
|
||||
set(toxcore_API_HEADERS
|
||||
${toxcore_SOURCE_DIR}/toxcore/tox.h^tox
|
||||
${toxcore_SOURCE_DIR}/toxcore/tox_events.h^tox
|
||||
${toxcore_SOURCE_DIR}/toxcore/tox_dispatch.h^tox)
|
||||
if(EXPERIMENTAL_API)
|
||||
set(toxcore_API_HEADERS ${toxcore_API_HEADERS}
|
||||
${toxcore_SOURCE_DIR}/toxcore/tox_private.h^tox)
|
||||
endif()
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# :: Audio/Video Library
|
||||
#
|
||||
################################################################################
|
||||
|
||||
if(BUILD_TOXAV)
|
||||
set(toxcore_SOURCES ${toxcore_SOURCES}
|
||||
toxav/audio.c
|
||||
toxav/audio.h
|
||||
toxav/bwcontroller.c
|
||||
toxav/bwcontroller.h
|
||||
toxav/groupav.c
|
||||
toxav/groupav.h
|
||||
toxav/msi.c
|
||||
toxav/msi.h
|
||||
toxav/ring_buffer.c
|
||||
toxav/ring_buffer.h
|
||||
toxav/rtp.c
|
||||
toxav/rtp.h
|
||||
toxav/toxav.c
|
||||
toxav/toxav.h
|
||||
toxav/toxav_old.c
|
||||
toxav/video.c
|
||||
toxav/video.h)
|
||||
set(toxcore_API_HEADERS ${toxcore_API_HEADERS}
|
||||
${toxcore_SOURCE_DIR}/toxav/toxav.h^toxav)
|
||||
|
||||
if(MSVC)
|
||||
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} PkgConfig::OPUS PkgConfig::VPX)
|
||||
else()
|
||||
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} ${OPUS_LIBRARIES} ${VPX_LIBRARIES})
|
||||
set(toxcore_LINK_DIRECTORIES ${toxcore_LINK_DIRECTORIES} ${OPUS_LIBRARY_DIRS} ${VPX_LIBRARY_DIRS})
|
||||
set(toxcore_INCLUDE_DIRECTORIES ${toxcore_INCLUDE_DIRECTORIES} ${OPUS_INCLUDE_DIRS} ${VPX_INCLUDE_DIRS})
|
||||
set(toxcore_COMPILE_OPTIONS ${toxcore_COMPILE_OPTIONS} ${OPUS_CFLAGS_OTHER} ${VPX_CFLAGS_OTHER})
|
||||
endif()
|
||||
set(toxcore_PKGCONFIG_REQUIRES ${toxcore_PKGCONFIG_REQUIRES} opus vpx)
|
||||
endif()
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# :: Block encryption libraries
|
||||
#
|
||||
################################################################################
|
||||
|
||||
set(toxcore_SOURCES ${toxcore_SOURCES}
|
||||
toxencryptsave/toxencryptsave.c
|
||||
toxencryptsave/toxencryptsave.h)
|
||||
set(toxcore_API_HEADERS ${toxcore_API_HEADERS}
|
||||
${toxcore_SOURCE_DIR}/toxencryptsave/toxencryptsave.h^tox)
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# :: System dependencies
|
||||
#
|
||||
################################################################################
|
||||
|
||||
# These need to come after other dependencies, since e.g. libvpx may depend on
|
||||
# pthread, but doesn't list it in VPX_LIBRARIES. We're adding it here, after
|
||||
# any potential libvpx linking.
|
||||
message("CMAKE_THREAD_LIBS_INIT: ${CMAKE_THREAD_LIBS_INIT}")
|
||||
if(CMAKE_THREAD_LIBS_INIT)
|
||||
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
|
||||
set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} ${CMAKE_THREAD_LIBS_INIT})
|
||||
endif()
|
||||
|
||||
if(NSL_LIBRARIES)
|
||||
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} ${NSL_LIBRARIES})
|
||||
set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} -lnsl)
|
||||
endif()
|
||||
|
||||
if(RT_LIBRARIES)
|
||||
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} ${RT_LIBRARIES})
|
||||
set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} -lrt)
|
||||
endif()
|
||||
|
||||
if(SOCKET_LIBRARIES)
|
||||
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} ${SOCKET_LIBRARIES})
|
||||
set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} -lsocket)
|
||||
endif()
|
||||
|
||||
if(TARGET PThreads4W::PThreads4W)
|
||||
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} PThreads4W::PThreads4W)
|
||||
elseif(TARGET Threads::Threads)
|
||||
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} Threads::Threads)
|
||||
endif()
|
||||
if(WIN32)
|
||||
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} iphlpapi ws2_32)
|
||||
endif()
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# :: All layers together in one library for ease of use
|
||||
#
|
||||
################################################################################
|
||||
|
||||
# Create combined library from all the sources.
|
||||
if(ENABLE_SHARED)
|
||||
add_library(toxcore_shared SHARED ${toxcore_SOURCES})
|
||||
set_target_properties(toxcore_shared PROPERTIES OUTPUT_NAME toxcore)
|
||||
target_link_libraries(toxcore_shared PRIVATE ${toxcore_LINK_LIBRARIES})
|
||||
target_link_directories(toxcore_shared PUBLIC ${toxcore_LINK_DIRECTORIES})
|
||||
target_include_directories(toxcore_shared SYSTEM PRIVATE ${toxcore_INCLUDE_DIRECTORIES})
|
||||
target_compile_options(toxcore_shared PRIVATE ${toxcore_COMPILE_OPTIONS})
|
||||
endif()
|
||||
|
||||
if(ENABLE_STATIC)
|
||||
add_library(toxcore_static STATIC ${toxcore_SOURCES})
|
||||
if(NOT MSVC)
|
||||
set_target_properties(toxcore_static PROPERTIES OUTPUT_NAME toxcore)
|
||||
endif()
|
||||
target_link_libraries(toxcore_static PRIVATE ${toxcore_LINK_LIBRARIES})
|
||||
target_link_directories(toxcore_static PUBLIC ${toxcore_LINK_DIRECTORIES})
|
||||
target_include_directories(toxcore_static SYSTEM PRIVATE ${toxcore_INCLUDE_DIRECTORIES})
|
||||
target_compile_options(toxcore_static PRIVATE ${toxcore_COMPILE_OPTIONS})
|
||||
endif()
|
||||
|
||||
if(BUILD_FUZZ_TESTS)
|
||||
add_library(toxcore_fuzz STATIC ${toxcore_SOURCES})
|
||||
target_link_libraries(toxcore_fuzz PRIVATE ${toxcore_LINK_LIBRARIES})
|
||||
target_link_directories(toxcore_fuzz PUBLIC ${toxcore_LINK_DIRECTORIES})
|
||||
target_include_directories(toxcore_fuzz SYSTEM PRIVATE ${toxcore_INCLUDE_DIRECTORIES})
|
||||
target_compile_options(toxcore_fuzz PRIVATE ${toxcore_COMPILE_OPTIONS})
|
||||
target_compile_definitions(toxcore_fuzz PUBLIC "FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION")
|
||||
endif()
|
||||
|
||||
# Make version script (on systems that support it) to limit symbol visibility.
|
||||
make_version_script(toxcore ${toxcore_API_HEADERS})
|
||||
|
||||
# Generate pkg-config file, install library to "${CMAKE_INSTALL_LIBDIR}" and install headers to
|
||||
# "${CMAKE_INSTALL_INCLUDEDIR}/tox".
|
||||
install_module(toxcore DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/tox)
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# :: Unit tests: no networking, just pure function calls.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
add_library(test_util STATIC
|
||||
toxcore/DHT_test_util.cc
|
||||
toxcore/DHT_test_util.hh
|
||||
toxcore/crypto_core_test_util.cc
|
||||
toxcore/crypto_core_test_util.hh
|
||||
toxcore/mem_test_util.cc
|
||||
toxcore/mem_test_util.hh
|
||||
toxcore/network_test_util.cc
|
||||
toxcore/network_test_util.hh
|
||||
toxcore/test_util.cc
|
||||
toxcore/test_util.hh)
|
||||
|
||||
function(unit_test subdir target)
|
||||
add_executable(unit_${target}_test ${subdir}/${target}_test.cc)
|
||||
target_link_libraries(unit_${target}_test PRIVATE test_util)
|
||||
if(TARGET toxcore_static)
|
||||
target_link_libraries(unit_${target}_test PRIVATE toxcore_static)
|
||||
else()
|
||||
target_link_libraries(unit_${target}_test PRIVATE toxcore_shared)
|
||||
endif()
|
||||
target_link_libraries(unit_${target}_test PRIVATE GTest::gtest GTest::gtest_main GTest::gmock)
|
||||
set_target_properties(unit_${target}_test PROPERTIES COMPILE_FLAGS "${TEST_CXX_FLAGS}")
|
||||
add_test(NAME ${target} COMMAND ${CROSSCOMPILING_EMULATOR} unit_${target}_test)
|
||||
set_property(TEST ${target} PROPERTY ENVIRONMENT "LLVM_PROFILE_FILE=${target}.profraw")
|
||||
endfunction()
|
||||
|
||||
# The actual unit tests follow.
|
||||
#
|
||||
if(UNITTEST AND TARGET GTest::gtest AND TARGET GTest::gmock)
|
||||
unit_test(toxav ring_buffer)
|
||||
unit_test(toxav rtp)
|
||||
unit_test(toxcore DHT)
|
||||
unit_test(toxcore bin_pack)
|
||||
unit_test(toxcore crypto_core)
|
||||
unit_test(toxcore group_announce)
|
||||
unit_test(toxcore group_moderation)
|
||||
unit_test(toxcore list)
|
||||
unit_test(toxcore mem)
|
||||
unit_test(toxcore mono_time)
|
||||
unit_test(toxcore ping_array)
|
||||
unit_test(toxcore test_util)
|
||||
unit_test(toxcore tox)
|
||||
unit_test(toxcore util)
|
||||
endif()
|
||||
|
||||
add_subdirectory(testing)
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# :: Automated regression tests: create a tox network and run integration tests
|
||||
#
|
||||
################################################################################
|
||||
|
||||
if(AUTOTEST)
|
||||
add_subdirectory(auto_tests)
|
||||
endif()
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# :: Bootstrap daemon
|
||||
#
|
||||
################################################################################
|
||||
|
||||
if(DHT_BOOTSTRAP)
|
||||
add_executable(DHT_bootstrap
|
||||
other/DHT_bootstrap.c
|
||||
other/bootstrap_node_packets.c)
|
||||
if(TARGET toxcore_static)
|
||||
target_link_libraries(DHT_bootstrap PRIVATE toxcore_static)
|
||||
else()
|
||||
target_link_libraries(DHT_bootstrap PRIVATE toxcore_shared)
|
||||
endif()
|
||||
target_link_libraries(DHT_bootstrap PRIVATE misc_tools)
|
||||
if(TARGET unofficial-sodium::sodium)
|
||||
target_link_libraries(DHT_bootstrap PRIVATE unofficial-sodium::sodium)
|
||||
endif()
|
||||
if(TARGET PThreads4W::PThreads4W)
|
||||
target_link_libraries(DHT_bootstrap PRIVATE PThreads4W::PThreads4W)
|
||||
elseif(TARGET Threads::Threads)
|
||||
target_link_libraries(DHT_bootstrap PRIVATE Threads::Threads)
|
||||
endif()
|
||||
install(TARGETS DHT_bootstrap RUNTIME DESTINATION bin)
|
||||
endif()
|
||||
|
||||
if(BOOTSTRAP_DAEMON)
|
||||
if(LIBCONFIG_FOUND)
|
||||
add_subdirectory(other/bootstrap_daemon)
|
||||
else()
|
||||
message(WARNING "Option BOOTSTRAP_DAEMON is enabled but required library LIBCONFIG was not found.")
|
||||
set(BOOTSTRAP_DAEMON OFF)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(BUILD_FUN_UTILS)
|
||||
add_subdirectory(other/fun)
|
||||
endif()
|
||||
|
||||
if (BUILD_FUZZ_TESTS)
|
||||
add_subdirectory(testing/fuzzing)
|
||||
endif()
|
||||
|
455
INSTALL.md
Normal file
455
INSTALL.md
Normal file
@ -0,0 +1,455 @@
|
||||
# Installation instructions
|
||||
|
||||
These instructions will guide you through the process of building and installing
|
||||
the toxcore library and its components, as well as getting already pre-built
|
||||
binaries.
|
||||
|
||||
## Table of contents
|
||||
|
||||
- [Overview](#overview)
|
||||
- [Components](#components)
|
||||
- [Main](#main)
|
||||
- [Secondary](#secondary)
|
||||
- [Building](#building)
|
||||
- [Requirements](#requirements)
|
||||
- [Library dependencies](#library-dependencies)
|
||||
- [Compiler requirements](#compiler-requirements)
|
||||
- [Build system requirements](#build-system-requirements)
|
||||
- [CMake options](#cmake-options)
|
||||
- [Build process](#build-process)
|
||||
- [Unix-like](#unix-like)
|
||||
- [Windows](#windows)
|
||||
- [Building on Windows host](#building-on-windows-host)
|
||||
- [Microsoft Visual Studio's Developer Command Prompt](#microsoft-visual-studios-developer-command-prompt)
|
||||
- [MSYS/Cygwin](#msyscygwin)
|
||||
- [Cross-compiling from Linux](#cross-compiling-from-linux)
|
||||
- [Pre-built binaries](#pre-built-binaries)
|
||||
- [Linux](#linux)
|
||||
|
||||
## Overview
|
||||
|
||||
### Components
|
||||
|
||||
#### Main
|
||||
|
||||
This repository, although called `toxcore`, in fact contains several libraries
|
||||
besides `toxcore` which complement it, as well as several executables. However,
|
||||
note that although these are separate libraries, at the moment, when building
|
||||
the libraries, they are all merged into a single `toxcore` library. Here is the
|
||||
full list of the main components that can be built using the CMake, their
|
||||
dependencies and descriptions.
|
||||
|
||||
| Name | Type | Dependencies | Platform | Description |
|
||||
| ---------------- | ---------- | ---------------------------------- | -------------- | -------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `toxcore` | Library | libsodium, libm, libpthread, librt | Cross-platform | The main Tox library that provides the messenger functionality. |
|
||||
| `toxav` | Library | libtoxcore, libopus, libvpx | Cross-platform | Provides audio/video functionality. |
|
||||
| `toxencryptsave` | Library | libtoxcore, libsodium | Cross-platform | Provides encryption of Tox profiles (savedata), as well as arbitrary data. |
|
||||
| `DHT_bootstrap` | Executable | libtoxcore | Cross-platform | A simple DHT bootstrap node. |
|
||||
| `tox-bootstrapd` | Executable | libtoxcore, libconfig | Unix-like | Highly configurable DHT bootstrap node daemon (systemd, SysVinit, Docker). |
|
||||
| `cmp` | Library | | Cross-platform | C implementation of the MessagePack serialization format. [https://github.com/camgunz/cmp](https://github.com/camgunz/cmp) |
|
||||
|
||||
#### Secondary
|
||||
|
||||
There are some programs that are not built by default which you might find
|
||||
interesting. You need to pass `-DBUILD_FUN_UTILS=ON` to cmake to build them.
|
||||
|
||||
##### Vanity key generators
|
||||
|
||||
Can be used to generate vanity Tox Ids or DHT bootstrap node public keys.
|
||||
|
||||
| Name | Type | Dependencies | Platform | Description |
|
||||
| ---------------- | ---------- | ----------------- | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `cracker` | Executable | libsodium, OpenMP | Cross-platform | Tries to find a curve25519 key pair, hex representation of the public key of which starts with a specified byte sequence. Multi-threaded. |
|
||||
| `cracker_simple` | Executable | libsodium | Cross-platform | Tries to find a curve25519 key pair, hex representation of the public key of which starts with a specified byte sequence. Single-threaded. |
|
||||
| `strkey` | Executable | libsodium | Cross-platform | Tries to find a curve25519 key pair, hex representation of the public key of which contains a specified byte sequence at a specified or any position at all. Single-threaded. |
|
||||
|
||||
##### Key file generators
|
||||
|
||||
Useful for generating Tox profiles from the output of the vanity key generators,
|
||||
as well as generating random Tox profiles.
|
||||
|
||||
| Name | Type | Dependencies | Platform | Description |
|
||||
| ------------------------- | ---------- | --------------------- | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `make-funny-savefile` | Script | python | Cross-platform | Generates a Tox profile file (savedata file) with the provided key pair. |
|
||||
| `create_bootstrap_keys` | Executable | libsodium | Cross-platform | Generates a keys file for tox-bootstrapd with either the provided or a random key pair. |
|
||||
| `create_minimal_savedata` | Executable | libsodium | Cross-platform | Generates a minimal Tox profile file (savedata file) with either the provided or a random key pair, printing the generated Tox Id and secret & public key information. |
|
||||
| `create_savedata` | Executable | libsodium, libtoxcore | Cross-platform | Generates a Tox profile file (savedata file) with either the provided or a random key pair using libtoxcore, printing the generated Tox Id and secret & public key information. |
|
||||
| `save-generator` | Executable | libtoxcore | Cross-platform | Generates a Tox profile file (savedata file) with a random key pair using libtoxcore, setting the specified user name, going online and adding specified Tox Ids as friends. |
|
||||
|
||||
##### Other
|
||||
|
||||
| Name | Type | Dependencies | Platform | Description |
|
||||
| --------------------- | ---------- | ------------ | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `bootstrap_node_info` | Script | python3 | Cross-platform | Prints version and Message Of The Day (MOTD) information of the specified DHT bootstrap node, given the node doesn't have those disabled. |
|
||||
| `sign` | Executable | libsodium | Cross-platform | Signs a file with a ed25519 key. |
|
||||
|
||||
## Building
|
||||
|
||||
### Requirements
|
||||
|
||||
#### Library dependencies
|
||||
|
||||
Library dependencies are listed in the [components](#components) table. The
|
||||
dependencies need to be satisfied for the components to be built. Note that if
|
||||
you don't have a dependency for some component, e.g. you don't have `libopus`
|
||||
installed required for building `toxav` component, building of that component is
|
||||
silently disabled.
|
||||
|
||||
Be advised that due to the addition of `cmp` as a submodule, you now also need
|
||||
to initialize the git submodules required by toxcore. This can be done by
|
||||
cloning the repo with the addition of `--recurse-submodules` or by running
|
||||
`git submodule update --init` in the root directory of the repo.
|
||||
|
||||
#### Compiler requirements
|
||||
|
||||
The supported compilers are GCC, Clang and MinGW.
|
||||
|
||||
In theory, any compiler that fully supports C99 and accepts GCC flags should
|
||||
work.
|
||||
|
||||
There is a partial and experimental support of Microsoft Visual C++ compiler. We
|
||||
welcome any patches that help improve it.
|
||||
|
||||
You should have a C99 compatible compiler in order to build the main components.
|
||||
The secondary components might require the compiler to support GNU extensions.
|
||||
|
||||
#### Build system requirements
|
||||
|
||||
To build the main components you need to have CMake of at least 2.8.6 version
|
||||
installed. You also need to have pkg-config installed, the build system uses it
|
||||
to find dependency libraries.
|
||||
|
||||
There is some experimental accommodation for building natively on Windows, i.e.
|
||||
without having to use MSYS/Cygwin and pkg-config, but it uses exact hardcoded
|
||||
paths for finding libraries and supports building only of some of toxcore
|
||||
components, so your mileage might vary.
|
||||
|
||||
### CMake options
|
||||
|
||||
There are some options that are available to configure the build.
|
||||
|
||||
| Name | Description | Expected Value | Default Value |
|
||||
| ----------------------- | --------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- | ------------------------------------------------- |
|
||||
| `AUTOTEST` | Enable autotests (mainly for CI). | ON or OFF | OFF |
|
||||
| `BOOTSTRAP_DAEMON` | Enable building of tox-bootstrapd, the DHT bootstrap node daemon. For Unix-like systems only. | ON or OFF | ON |
|
||||
| `BUILD_FUN_UTILS` | Build additional just for fun utilities. | ON or OFF | OFF |
|
||||
| `BUILD_FUZZ_TESTS` | Build fuzzing harnesses. | ON or OFF | OFF |
|
||||
| `BUILD_MISC_TESTS` | Build additional tests. | ON or OFF | OFF |
|
||||
| `BUILD_TOXAV` | Whether to build the toxav library. | ON or OFF | ON |
|
||||
| `CMAKE_BUILD_TYPE` | Specifies the build type on single-configuration generators (e.g. make or ninja). | Debug, Release, RelWithDebInfo, MinSizeRel | Empty string. |
|
||||
| `CMAKE_INSTALL_PREFIX` | Path to where everything should be installed. | Directory path. | Platform-dependent. Refer to CMake documentation. |
|
||||
| `DHT_BOOTSTRAP` | Enable building of `DHT_bootstrap`. | ON or OFF | ON |
|
||||
| `ENABLE_SHARED` | Build shared (dynamic) libraries for all modules. | ON or OFF | ON |
|
||||
| `ENABLE_STATIC` | Build static libraries for all modules. | ON or OFF | ON |
|
||||
| `EXPERIMENTAL_API` | Install experimental header file with unstable API. | ON or OFF | OFF |
|
||||
| `FLAT_OUTPUT_STRUCTURE` | Whether to produce output artifacts in {bin,lib}. | ON or OFF | OFF |
|
||||
| `FULLY_STATIC` | Build fully static executables. | ON or OFF | OFF |
|
||||
| `MIN_LOGGER_LEVEL` | Logging level to use. | TRACE, DEBUG, INFO, WARNING, ERROR or nothing (empty string) for default. | Empty string. |
|
||||
| `MSVC_STATIC_SODIUM` | Whether to link libsodium statically for MSVC. | ON or OFF | OFF |
|
||||
| `MUST_BUILD_TOXAV` | Fail the build if toxav cannot be built. | ON or OFF | OFF |
|
||||
| `NON_HERMETIC_TESTS` | Whether to build and run tests that depend on an internet connection. | ON or OFF | OFF |
|
||||
| `PROXY_TEST` | Enable proxy test (requires `other/proxy/proxy_server.go` to be running). | ON or OFF | OFF |
|
||||
| `STRICT_ABI` | Enforce strict ABI export in dynamic libraries. | ON or OFF | OFF |
|
||||
| `TEST_TIMEOUT_SECONDS` | Limit runtime of each test to the number of seconds specified. | Positive number or nothing (empty string). | Empty string. |
|
||||
| `UNITTEST` | Enable unit tests (disable if you don't have a working gmock or gtest). | ON or OFF | ON |
|
||||
| `USE_IPV6` | Use IPv6 in tests. | ON or OFF | ON |
|
||||
|
||||
You can get this list of option using the following commands
|
||||
|
||||
```sh
|
||||
cmake -B _build -LAH
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```sh
|
||||
grep "option(" CMakeLists.txt cmake/*
|
||||
grep "set(.* CACHE" CMakeLists.txt cmake/*
|
||||
```
|
||||
|
||||
Note that some options might be considered only if other options are enabled.
|
||||
|
||||
Example of calling cmake with options
|
||||
|
||||
```sh
|
||||
cmake \
|
||||
-D ENABLE_STATIC=OFF \
|
||||
-D ENABLE_SHARED=ON \
|
||||
-D CMAKE_INSTALL_PREFIX="${PWD}/prefix" \
|
||||
-D CMAKE_BUILD_TYPE=Release \
|
||||
-D TEST_TIMEOUT_SECONDS=120 \
|
||||
..
|
||||
```
|
||||
|
||||
### Building tests
|
||||
|
||||
In addition to the integration tests ("autotests") and miscellaneous tests
|
||||
enabled by cmake variables described above, there are unit tests which will be
|
||||
built if the source distribution of gtest (the Google Unit Test framework) is
|
||||
found by cmake in `c-toxcore/third_party`. This can be achieved by running 'git
|
||||
clone https://github.com/google/googletest` from that directory.
|
||||
|
||||
### Build process
|
||||
|
||||
#### Unix-like
|
||||
|
||||
Assuming all the [requirements](#requirements) are met, just run
|
||||
|
||||
```sh
|
||||
mkdir _build
|
||||
cd _build
|
||||
cmake ..
|
||||
make
|
||||
make install
|
||||
```
|
||||
|
||||
or shorter
|
||||
|
||||
```sh
|
||||
cmake -B _build
|
||||
cmake -B _build --target install
|
||||
```
|
||||
|
||||
#### Windows
|
||||
|
||||
##### Building on Windows host
|
||||
|
||||
###### Microsoft Visual Studio's Developer Command Prompt
|
||||
|
||||
In addition to meeting the [requirements](#requirements), you need a version of
|
||||
Visual Studio (the
|
||||
[community edition](https://www.visualstudio.com/vs/visual-studio-express/) is
|
||||
enough) and a CMake version that's compatible with the Visual Studio version
|
||||
you're using.
|
||||
|
||||
You must also ensure that the msvc versions of dependencies you're using are
|
||||
placed in the correct folders.
|
||||
|
||||
For libsodium that is `c-toxcore/third_party/libsodium`, and for pthreads-w32,
|
||||
it's `c-toxcore/third_party/pthreads-win32`
|
||||
|
||||
Once all of this is done, from the **Developer Command Prompt for VS**, simply
|
||||
run
|
||||
|
||||
```
|
||||
mkdir _build
|
||||
cd _build
|
||||
cmake ..
|
||||
msbuild ALL_BUILD.vcxproj
|
||||
```
|
||||
|
||||
###### MSYS/Cygwin
|
||||
|
||||
Download Cygwin
|
||||
([32-bit](https://cygwin.com/setup-x86.exe)/[64-bit](https://cygwin.com/setup-x86_64.exe))
|
||||
|
||||
Search and select exactly these packages in Devel category:
|
||||
|
||||
- mingw64-i686-gcc-core (32-bit) / mingw64-x86_64-gcc-core (64-bit)
|
||||
- mingw64-i686-gcc-g++ (32-bit) / mingw64-x86_64-gcc-g++ (64-bit)
|
||||
- make
|
||||
- cmake
|
||||
- libtool
|
||||
- autoconf
|
||||
- automake
|
||||
- tree
|
||||
- curl
|
||||
- perl
|
||||
- yasm
|
||||
- pkg-config
|
||||
|
||||
To handle Windows EOL correctly run the following in the Cygwin Terminal:
|
||||
|
||||
```sh
|
||||
echo '
|
||||
export SHELLOPTS
|
||||
set -o igncr
|
||||
' > ~/.bash_profile
|
||||
```
|
||||
|
||||
Download toxcore source code and extract it to a folder.
|
||||
|
||||
Open Cygwin Terminal in the toxcore folder and run
|
||||
`./other/windows_build_script_toxcore.sh` to start the build process.
|
||||
|
||||
Toxcore build result files will appear in `/root/prefix/` relatively to Cygwin
|
||||
folder (default `C:\cygwin64`).
|
||||
|
||||
Dependency versions can be customized in
|
||||
`./other/windows_build_script_toxcore.sh` and described in the section below.
|
||||
|
||||
##### Cross-compiling from Linux
|
||||
|
||||
These cross-compilation instructions were tested on and written for 64-bit
|
||||
Ubuntu 16.04. You could generalize them for any Linux system, the only
|
||||
requirements are that you have Docker version of >= 1.9.0 and you are running
|
||||
64-bit system.
|
||||
|
||||
The cross-compilation is fully automated by a parameterized
|
||||
[Dockerfile](/other/docker/windows/Dockerfile).
|
||||
|
||||
Install Docker
|
||||
|
||||
```sh
|
||||
apt-get update
|
||||
apt-get install docker.io
|
||||
```
|
||||
|
||||
Get the toxcore source code and navigate to `other/docker/windows`.
|
||||
|
||||
Build the container image based on the Dockerfile. The following options are
|
||||
available to customize the building of the container image.
|
||||
|
||||
| Name | Description | Expected Value | Default Value |
|
||||
| -------------------------- | ----------------------------------------------------- | ----------------------------------- | ------------- |
|
||||
| `SUPPORT_ARCH_i686` | Support building 32-bit toxcore. | "true" or "false" (case sensitive). | true |
|
||||
| `SUPPORT_ARCH_x86_64` | Support building 64-bit toxcore. | "true" or "false" (case sensitive). | true |
|
||||
| `SUPPORT_TEST` | Support running toxcore automated tests. | "true" or "false" (case sensitive). | false |
|
||||
| `VERSION_OPUS` | Version of libopus to build toxcore with. | Numeric version number. | 1.4 |
|
||||
| `VERSION_SODIUM` | Version of libsodium to build toxcore with. | Numeric version number. | 1.0.19 |
|
||||
| `VERSION_VPX` | Version of libvpx to build toxcore with. | Numeric version number. | 1.14.0 |
|
||||
| `ENABLE_HASH_VERIFICATION` | Verify the hashes of the default dependency versions. | "true" or "false" (case sensitive). | true |
|
||||
|
||||
Example of building a container image with options
|
||||
|
||||
```sh
|
||||
cd other/docker/windows
|
||||
docker build \
|
||||
--build-arg SUPPORT_TEST=true \
|
||||
-t toxcore \
|
||||
.
|
||||
```
|
||||
|
||||
Run the container to build toxcore. The following options are available to
|
||||
customize the running of the container image.
|
||||
|
||||
| Name | Description | Expected Value | Default Value |
|
||||
| -------------------- | ------------------------------------------------------------------------------------------ | ----------------------------------- | ------------------------------------------ |
|
||||
| `ALLOW_TEST_FAILURE` | Don't stop if a test suite fails. | "true" or "false" (case sensitive). | `false` |
|
||||
| `ENABLE_ARCH_i686` | Build 32-bit toxcore. The image should have been built with `SUPPORT_ARCH_i686` enabled. | "true" or "false" (case sensitive). | `true` |
|
||||
| `ENABLE_ARCH_x86_64` | Build 64-bit toxcore. The image should have been built with `SUPPORT_ARCH_x86_64` enabled. | "true" or "false" (case sensitive). | `true` |
|
||||
| `ENABLE_TEST` | Run the test suite. The image should have been built with `SUPPORT_TEST` enabled. | "true" or "false" (case sensitive). | `false` |
|
||||
| `EXTRA_CMAKE_FLAGS` | Extra arguments to pass to the CMake command when building toxcore. | CMake options. | `-DTEST_TIMEOUT_SECONDS=90 -DUSE_IPV6=OFF` |
|
||||
|
||||
Example of running the container with options
|
||||
|
||||
```sh
|
||||
docker run \
|
||||
-e ENABLE_TEST=true \
|
||||
-e ALLOW_TEST_FAILURE=true \
|
||||
-v /path/to/toxcore/sourcecode:/toxcore \
|
||||
-v /path/to/where/output/build/result:/prefix \
|
||||
-t \
|
||||
--rm \
|
||||
toxcore
|
||||
```
|
||||
|
||||
After the build succeeds, you should see the built toxcore libraries in
|
||||
`/path/to/where/output/build/result`.
|
||||
|
||||
The file structure should look similar to the following
|
||||
|
||||
```
|
||||
result
|
||||
├── [4.0K] i686
|
||||
│ ├── [ 36K] bin
|
||||
│ │ ├── [636K] DHT_bootstrap.exe
|
||||
│ │ ├── [572K] cracker.exe
|
||||
│ │ ├── [359K] cracker_simple.exe
|
||||
│ │ ├── [378K] create_bootstrap_keys.exe
|
||||
│ │ ├── [378K] create_minimal_savedata.exe
|
||||
│ │ ├── [958K] create_savedata.exe
|
||||
│ │ ├── [ 18K] libtoxcore.def
|
||||
│ │ ├── [2.6M] libtoxcore.dll
|
||||
│ │ ├── [ 65K] libtoxcore.exp
|
||||
│ │ ├── [428K] libtoxcore.lib
|
||||
│ │ ├── [989K] save-generator.exe
|
||||
│ │ ├── [381K] sign.exe
|
||||
│ │ └── [408K] strkey.exe
|
||||
│ ├── [4.0K] include
|
||||
│ │ └── [4.0K] tox
|
||||
│ │ ├── [177K] tox.h
|
||||
│ │ ├── [ 10K] tox_dispatch.h
|
||||
│ │ ├── [ 26K] tox_events.h
|
||||
│ │ ├── [6.4K] tox_private.h
|
||||
│ │ ├── [ 26K] toxav.h
|
||||
│ │ └── [ 12K] toxencryptsave.h
|
||||
│ └── [4.0K] lib
|
||||
│ ├── [577K] libopus.a
|
||||
│ ├── [660K] libsodium.a
|
||||
│ ├── [ 10K] libssp.a
|
||||
│ ├── [1016K] libtoxcore.a
|
||||
│ ├── [456K] libtoxcore.dll.a
|
||||
│ ├── [2.7M] libvpx.a
|
||||
│ ├── [ 72K] libwinpthread.a
|
||||
│ └── [4.0K] pkgconfig
|
||||
│ ├── [ 250] libsodium.pc
|
||||
│ ├── [ 357] opus.pc
|
||||
│ ├── [ 247] toxcore.pc
|
||||
│ └── [ 309] vpx.pc
|
||||
└── [4.0K] x86_64
|
||||
├── [ 36K] bin
|
||||
│ ├── [504K] DHT_bootstrap.exe
|
||||
│ ├── [474K] cracker.exe
|
||||
│ ├── [277K] cracker_simple.exe
|
||||
│ ├── [287K] create_bootstrap_keys.exe
|
||||
│ ├── [288K] create_minimal_savedata.exe
|
||||
│ ├── [769K] create_savedata.exe
|
||||
│ ├── [ 18K] libtoxcore.def
|
||||
│ ├── [2.4M] libtoxcore.dll
|
||||
│ ├── [ 64K] libtoxcore.exp
|
||||
│ ├── [420K] libtoxcore.lib
|
||||
│ ├── [800K] save-generator.exe
|
||||
│ ├── [289K] sign.exe
|
||||
│ └── [317K] strkey.exe
|
||||
├── [4.0K] include
|
||||
│ └── [4.0K] tox
|
||||
│ ├── [177K] tox.h
|
||||
│ ├── [ 10K] tox_dispatch.h
|
||||
│ ├── [ 26K] tox_events.h
|
||||
│ ├── [6.4K] tox_private.h
|
||||
│ ├── [ 26K] toxav.h
|
||||
│ └── [ 12K] toxencryptsave.h
|
||||
└── [4.0K] lib
|
||||
├── [697K] libopus.a
|
||||
├── [575K] libsodium.a
|
||||
├── [ 11K] libssp.a
|
||||
├── [905K] libtoxcore.a
|
||||
├── [449K] libtoxcore.dll.a
|
||||
├── [2.9M] libvpx.a
|
||||
├── [ 68K] libwinpthread.a
|
||||
└── [4.0K] pkgconfig
|
||||
├── [ 252] libsodium.pc
|
||||
├── [ 359] opus.pc
|
||||
├── [ 249] toxcore.pc
|
||||
└── [ 311] vpx.pc
|
||||
|
||||
12 directories, 60 files
|
||||
```
|
||||
|
||||
- `libtoxcore.dll` is the shared library. It is fully self-contained, with no
|
||||
additional dependencies aside from the Windows OS dlls, and can be used in
|
||||
MSVC, MinGW, Clang, etc. projects. Despite its name, it provides toxcore,
|
||||
toxav, toxencryptsave -- all of Tox.
|
||||
- `libtoxcore.a` is the static library. In order to use it, it needs to be
|
||||
linked against the other provided .a libraries (but not the .dll.a!) and
|
||||
additionally -liphlpapi and -lws2_32 Windows dlls. It similarly provides all
|
||||
of Tox APIs.
|
||||
- `libtoxcore.dll.a` is the MinGW import library for `libtoxcore.dll`.
|
||||
- `libtoxcore.lib` is the MSVC import library for `libtoxcore.dll`.
|
||||
- `libtoxcore.exp` and `libtoxcore.def` are the exported by `libtoxcore`
|
||||
symbols.
|
||||
- `*.exe` are statically compiled executables -- `DHT_bootstrap` and
|
||||
[the fun utils](#secondary).
|
||||
|
||||
## Pre-built binaries
|
||||
|
||||
### Linux
|
||||
|
||||
Toxcore is packaged by at least by the following distributions: ALT Linux,
|
||||
[Arch Linux](https://www.archlinux.org/packages/?q=toxcore),
|
||||
[Fedora](https://apps.fedoraproject.org/packages/toxcore), Mageia, openSUSE,
|
||||
PCLinuxOS, ROSA and Slackware,
|
||||
[according to the information from pkgs.org](https://pkgs.org/download/toxcore).
|
||||
Note that this list might be incomplete and some other distributions might
|
||||
package it too.
|
205
README.md
205
README.md
@ -1,4 +1,205 @@
|
||||
# Tomato
|
||||
# 
|
||||
|
||||

|
||||
**Current Coverage:**
|
||||
[](https://codecov.io/gh/TokTok/c-toxcore)
|
||||
|
||||
[**Website**](https://tox.chat) **|** [**Wiki**](https://wiki.tox.chat/) **|**
|
||||
[**Blog**](https://blog.tox.chat/) **|**
|
||||
[**FAQ**](https://wiki.tox.chat/doku.php?id=users:faq) **|**
|
||||
[**Binaries/Downloads**](https://tox.chat/download.html) **|**
|
||||
[**Clients**](https://wiki.tox.chat/doku.php?id=clients) **|**
|
||||
[**Compiling**](/INSTALL.md)
|
||||
|
||||
## What is Tox
|
||||
|
||||
Tox is a peer to peer (serverless) instant messenger aimed at making security
|
||||
and privacy easy to obtain for regular users. It uses
|
||||
[libsodium](https://doc.libsodium.org/) (based on
|
||||
[NaCl](https://nacl.cr.yp.to/)) for its encryption and authentication.
|
||||
|
||||
## IMPORTANT!
|
||||
|
||||
### 
|
||||
|
||||
This is an **experimental** cryptographic network library. It has not been
|
||||
formally audited by an independent third party that specializes in cryptography
|
||||
or cryptanalysis. **Use this library at your own risk.**
|
||||
|
||||
The underlying crypto library [libsodium](https://doc.libsodium.org/) provides
|
||||
reliable encryption, but the security model has not yet been fully specified.
|
||||
See [issue 210](https://github.com/TokTok/c-toxcore/issues/210) for a discussion
|
||||
on developing a threat model. See other issues for known weaknesses (e.g.
|
||||
[issue 426](https://github.com/TokTok/c-toxcore/issues/426) describes what can
|
||||
happen if your secret key is stolen).
|
||||
|
||||
## Toxcore Development Roadmap
|
||||
|
||||
The roadmap and changelog are generated from GitHub issues. You may view them on
|
||||
the website, where they are updated at least once every 24 hours:
|
||||
|
||||
- Changelog: https://toktok.ltd/changelog/c-toxcore
|
||||
- Roadmap: https://toktok.ltd/roadmap/c-toxcore
|
||||
|
||||
## Installing toxcore
|
||||
|
||||
Detailed installation instructions can be found in [INSTALL.md](INSTALL.md).
|
||||
|
||||
Be advised that due to the addition of `cmp` as a submodule, you now also need
|
||||
to initialize the git submodules required by toxcore. This can be done by
|
||||
cloning the repo with the following command:
|
||||
`git clone --recurse-submodules https://github.com/Toktok/c-toxcore` or by
|
||||
running `git submodule update --init` in the root directory of the repo.
|
||||
|
||||
In a nutshell, if you have [libsodium](https://github.com/jedisct1/libsodium)
|
||||
installed, run:
|
||||
|
||||
```sh
|
||||
mkdir _build && cd _build
|
||||
cmake ..
|
||||
make
|
||||
sudo make install
|
||||
```
|
||||
|
||||
If you have [libvpx](https://github.com/webmproject/libvpx) and
|
||||
[opus](https://github.com/xiph/opus) installed, the above will also build the
|
||||
A/V library for multimedia chats.
|
||||
|
||||
## Using toxcore
|
||||
|
||||
The simplest "hello world" example could be an echo bot. Here we will walk
|
||||
through the implementation of a simple bot.
|
||||
|
||||
### Creating the tox instance
|
||||
|
||||
All toxcore API functions work with error parameters. They are enums with one
|
||||
`OK` value and several error codes that describe the different situations in
|
||||
which the function might fail.
|
||||
|
||||
```c
|
||||
TOX_ERR_NEW err_new;
|
||||
Tox *tox = tox_new(NULL, &err_new);
|
||||
if (err_new != TOX_ERR_NEW_OK) {
|
||||
fprintf(stderr, "tox_new failed with error code %d\n", err_new);
|
||||
exit(1);
|
||||
}
|
||||
```
|
||||
|
||||
Here, we simply exit the program, but in a real client you will probably want to
|
||||
do some error handling and proper error reporting to the user. The `NULL`
|
||||
argument given to the first parameter of `tox_new` is the `Tox_Options`. It
|
||||
contains various write-once network settings and allows you to load a previously
|
||||
serialised instance. See [toxcore/tox.h](tox.h) for details.
|
||||
|
||||
### Setting up callbacks
|
||||
|
||||
Toxcore works with callbacks that you can register to listen for certain events.
|
||||
Examples of such events are "friend request received" or "friend sent a
|
||||
message". Search the API for `tox_callback_*` to find all of them.
|
||||
|
||||
Here, we will set up callbacks for receiving friend requests and receiving
|
||||
messages. We will always accept any friend request (because we're a bot), and
|
||||
when we receive a message, we send it back to the sender.
|
||||
|
||||
```c
|
||||
tox_callback_friend_request(tox, handle_friend_request);
|
||||
tox_callback_friend_message(tox, handle_friend_message);
|
||||
```
|
||||
|
||||
These two function calls set up the callbacks. Now we also need to implement
|
||||
these "handle" functions.
|
||||
|
||||
### Handle friend requests
|
||||
|
||||
```c
|
||||
static void handle_friend_request(
|
||||
Tox *tox, const uint8_t *public_key, const uint8_t *message, size_t length,
|
||||
void *user_data) {
|
||||
// Accept the friend request:
|
||||
TOX_ERR_FRIEND_ADD err_friend_add;
|
||||
tox_friend_add_norequest(tox, public_key, &err_friend_add);
|
||||
if (err_friend_add != TOX_ERR_FRIEND_ADD_OK) {
|
||||
fprintf(stderr, "unable to add friend: %d\n", err_friend_add);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The `tox_friend_add_norequest` function adds the friend without sending them a
|
||||
friend request. Since we already got a friend request, this is the right thing
|
||||
to do. If you wanted to send a friend request yourself, you would use
|
||||
`tox_friend_add`, which has an extra parameter for the message.
|
||||
|
||||
### Handle messages
|
||||
|
||||
Now, when the friend sends us a message, we want to respond to them by sending
|
||||
them the same message back. This will be our "echo".
|
||||
|
||||
```c
|
||||
static void handle_friend_message(
|
||||
Tox *tox, uint32_t friend_number, TOX_MESSAGE_TYPE type,
|
||||
const uint8_t *message, size_t length,
|
||||
void *user_data) {
|
||||
TOX_ERR_FRIEND_SEND_MESSAGE err_send;
|
||||
tox_friend_send_message(tox, friend_number, type, message, length,
|
||||
&err_send);
|
||||
if (err_send != TOX_ERR_FRIEND_SEND_MESSAGE_OK) {
|
||||
fprintf(stderr, "unable to send message back to friend %d: %d\n",
|
||||
friend_number, err_send);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
That's it for the setup. Now we want to actually run the bot.
|
||||
|
||||
### Main event loop
|
||||
|
||||
Toxcore works with a main event loop function `tox_iterate` that you need to
|
||||
call at a certain frequency dictated by `tox_iteration_interval`. This is a
|
||||
polling function that receives new network messages and processes them.
|
||||
|
||||
```c
|
||||
while (true) {
|
||||
usleep(1000 * tox_iteration_interval(tox));
|
||||
tox_iterate(tox, NULL);
|
||||
}
|
||||
```
|
||||
|
||||
That's it! Now you have a working echo bot. The only problem is that since Tox
|
||||
works with public keys, and you can't really guess your bot's public key, you
|
||||
can't add it as a friend in your client. For this, we need to call another API
|
||||
function: `tox_self_get_address(tox, address)`. This will fill the 38 byte
|
||||
friend address into the `address` buffer. You can then display that binary
|
||||
string as hex and input it into your client. Writing a `bin2hex` function is
|
||||
left as exercise for the reader.
|
||||
|
||||
We glossed over a lot of details, such as the user data which we passed to
|
||||
`tox_iterate` (passing `NULL`), bootstrapping into an actual network (this bot
|
||||
will work in the LAN, but not on an internet server) and the fact that we now
|
||||
have no clean way of stopping the bot (`while (true)`). If you want to write a
|
||||
real bot, you will probably want to read up on all the API functions. Consult
|
||||
the API documentation in [toxcore/tox.h](toxcore/tox.h) for more information.
|
||||
|
||||
### Other resources
|
||||
|
||||
- [Another echo bot](https://wiki.tox.chat/developers/client_examples/echo_bot)
|
||||
- [minitox](https://github.com/hqwrong/minitox) (A minimal tox client)
|
||||
|
||||
## SAST Tools
|
||||
|
||||
This project uses various tools supporting Static Application Security Testing:
|
||||
|
||||
- [clang-tidy](https://clang.llvm.org/extra/clang-tidy/): A clang-based C++
|
||||
"linter" tool.
|
||||
- [Coverity](https://scan.coverity.com/): A cloud-based static analyzer service
|
||||
for Java, C/C++, C#, JavaScript, Ruby, or Python that is free for open source
|
||||
projects.
|
||||
- [cppcheck](https://cppcheck.sourceforge.io/): A static analyzer for C/C++
|
||||
code.
|
||||
- [cpplint](https://github.com/cpplint/cpplint): Static code checker for C++
|
||||
- [goblint](https://goblint.in.tum.de/): A static analyzer for multi-threaded C
|
||||
programs, specializing in finding concurrency bugs.
|
||||
- [infer](https://github.com/facebook/infer): A static analyzer for Java, C,
|
||||
C++, and Objective-C.
|
||||
- [PVS-Studio](https://pvs-studio.com/en/pvs-studio/?utm_source=website&utm_medium=github&utm_campaign=open_source):
|
||||
A static analyzer for C, C++, C#, and Java code.
|
||||
- [tokstyle](https://github.com/TokTok/hs-tokstyle): A style checker for TokTok
|
||||
C projects.
|
||||
|
@ -17,6 +17,8 @@ cc_library(
|
||||
"//c-toxcore/toxcore:Messenger",
|
||||
"//c-toxcore/toxcore:mono_time",
|
||||
"//c-toxcore/toxcore:tox",
|
||||
"//c-toxcore/toxcore:tox_dispatch",
|
||||
"//c-toxcore/toxcore:tox_events",
|
||||
],
|
||||
)
|
||||
|
@ -240,6 +240,7 @@ endif
|
||||
|
||||
|
||||
EXTRA_DIST += \
|
||||
$(top_srcdir)/auto_tests/data/save.tox \
|
||||
$(top_srcdir)/auto_tests/data/save.tox.big \
|
||||
$(top_srcdir)/auto_tests/data/save.tox.little \
|
||||
$(top_srcdir)/auto_tests/check_compat.h \
|
||||
$(top_srcdir)/auto_tests/auto_test_support.h
|
@ -45,11 +45,11 @@ static uint16_t ports[NUM_PORTS] = {13215, 33445, 25643};
|
||||
|
||||
static void test_basic(void)
|
||||
{
|
||||
const Random *rng = system_random();
|
||||
const Random *rng = os_random();
|
||||
ck_assert(rng != nullptr);
|
||||
const Network *ns = system_network();
|
||||
const Network *ns = os_network();
|
||||
ck_assert(ns != nullptr);
|
||||
const Memory *mem = system_memory();
|
||||
const Memory *mem = os_memory();
|
||||
ck_assert(mem != nullptr);
|
||||
|
||||
Mono_Time *mono_time = mono_time_new(mem, nullptr, nullptr);
|
||||
@ -266,13 +266,14 @@ static void kill_tcp_con(struct sec_TCP_con *con)
|
||||
static int write_packet_tcp_test_connection(const Logger *logger, struct sec_TCP_con *con, const uint8_t *data,
|
||||
uint16_t length)
|
||||
{
|
||||
VLA(uint8_t, packet, sizeof(uint16_t) + length + CRYPTO_MAC_SIZE);
|
||||
const uint16_t packet_size = sizeof(uint16_t) + length + CRYPTO_MAC_SIZE;
|
||||
VLA(uint8_t, packet, packet_size);
|
||||
|
||||
uint16_t c_length = net_htons(length + CRYPTO_MAC_SIZE);
|
||||
memcpy(packet, &c_length, sizeof(uint16_t));
|
||||
int len = encrypt_data_symmetric(con->shared_key, con->sent_nonce, data, length, packet + sizeof(uint16_t));
|
||||
|
||||
if ((unsigned int)len != (SIZEOF_VLA(packet) - sizeof(uint16_t))) {
|
||||
if ((unsigned int)len != (packet_size - sizeof(uint16_t))) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -282,7 +283,7 @@ static int write_packet_tcp_test_connection(const Logger *logger, struct sec_TCP
|
||||
localhost.ip = get_loopback();
|
||||
localhost.port = 0;
|
||||
|
||||
ck_assert_msg(net_send(con->ns, logger, con->sock, packet, SIZEOF_VLA(packet), &localhost) == SIZEOF_VLA(packet),
|
||||
ck_assert_msg(net_send(con->ns, logger, con->sock, packet, packet_size, &localhost) == packet_size,
|
||||
"Failed to send a packet.");
|
||||
return 0;
|
||||
}
|
||||
@ -303,11 +304,11 @@ static int read_packet_sec_tcp(const Logger *logger, struct sec_TCP_con *con, ui
|
||||
|
||||
static void test_some(void)
|
||||
{
|
||||
const Random *rng = system_random();
|
||||
const Random *rng = os_random();
|
||||
ck_assert(rng != nullptr);
|
||||
const Network *ns = system_network();
|
||||
const Network *ns = os_network();
|
||||
ck_assert(ns != nullptr);
|
||||
const Memory *mem = system_memory();
|
||||
const Memory *mem = os_memory();
|
||||
ck_assert(mem != nullptr);
|
||||
|
||||
Mono_Time *mono_time = mono_time_new(mem, nullptr, nullptr);
|
||||
@ -498,11 +499,11 @@ static int oob_data_callback(void *object, const uint8_t *public_key, const uint
|
||||
|
||||
static void test_client(void)
|
||||
{
|
||||
const Random *rng = system_random();
|
||||
const Random *rng = os_random();
|
||||
ck_assert(rng != nullptr);
|
||||
const Network *ns = system_network();
|
||||
const Network *ns = os_network();
|
||||
ck_assert(ns != nullptr);
|
||||
const Memory *mem = system_memory();
|
||||
const Memory *mem = os_memory();
|
||||
ck_assert(mem != nullptr);
|
||||
|
||||
Logger *logger = logger_new();
|
||||
@ -524,8 +525,9 @@ static void test_client(void)
|
||||
ip_port_tcp_s.ip = get_loopback();
|
||||
|
||||
TCP_Client_Connection *conn = new_tcp_connection(logger, mem, mono_time, rng, ns, &ip_port_tcp_s, self_public_key, f_public_key, f_secret_key, nullptr);
|
||||
do_tcp_connection(logger, mono_time, conn, nullptr);
|
||||
// TCP sockets might need a moment before they can be written to.
|
||||
c_sleep(50);
|
||||
do_tcp_connection(logger, mono_time, conn, nullptr);
|
||||
|
||||
// The connection status should be unconfirmed here because we have finished
|
||||
// sending our data and are awaiting a response.
|
||||
@ -559,6 +561,7 @@ static void test_client(void)
|
||||
ip_port_tcp_s.port = net_htons(ports[random_u32(rng) % NUM_PORTS]);
|
||||
TCP_Client_Connection *conn2 = new_tcp_connection(logger, mem, mono_time, rng, ns, &ip_port_tcp_s, self_public_key, f2_public_key,
|
||||
f2_secret_key, nullptr);
|
||||
c_sleep(50);
|
||||
|
||||
// The client should call this function (defined earlier) during the routing process.
|
||||
routing_response_handler(conn, response_callback, (char *)conn + 2);
|
||||
@ -581,7 +584,7 @@ static void test_client(void)
|
||||
do_tcp_connection(logger, mono_time, conn2, nullptr);
|
||||
c_sleep(50);
|
||||
|
||||
uint8_t data[5] = {1, 2, 3, 4, 5};
|
||||
const uint8_t data[5] = {1, 2, 3, 4, 5};
|
||||
memcpy(oob_pubkey, f2_public_key, CRYPTO_PUBLIC_KEY_SIZE);
|
||||
send_oob_packet(logger, conn2, f_public_key, data, 5);
|
||||
send_routing_request(logger, conn, f2_public_key);
|
||||
@ -632,11 +635,11 @@ static void test_client(void)
|
||||
// Test how the client handles servers that don't respond.
|
||||
static void test_client_invalid(void)
|
||||
{
|
||||
const Random *rng = system_random();
|
||||
const Random *rng = os_random();
|
||||
ck_assert(rng != nullptr);
|
||||
const Network *ns = system_network();
|
||||
const Network *ns = os_network();
|
||||
ck_assert(ns != nullptr);
|
||||
const Memory *mem = system_memory();
|
||||
const Memory *mem = os_memory();
|
||||
ck_assert(mem != nullptr);
|
||||
|
||||
Mono_Time *mono_time = mono_time_new(mem, nullptr, nullptr);
|
||||
@ -654,7 +657,7 @@ static void test_client_invalid(void)
|
||||
ip_port_tcp_s.port = net_htons(ports[random_u32(rng) % NUM_PORTS]);
|
||||
ip_port_tcp_s.ip = get_loopback();
|
||||
TCP_Client_Connection *conn = new_tcp_connection(logger, mem, mono_time, rng, ns, &ip_port_tcp_s,
|
||||
self_public_key, f_public_key, f_secret_key, nullptr);
|
||||
self_public_key, f_public_key, f_secret_key, nullptr);
|
||||
|
||||
// Run the client's main loop but not the server.
|
||||
mono_time_update(mono_time);
|
||||
@ -708,14 +711,13 @@ static int tcp_data_callback(void *object, int id, const uint8_t *data, uint16_t
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void test_tcp_connection(void)
|
||||
{
|
||||
const Random *rng = system_random();
|
||||
const Random *rng = os_random();
|
||||
ck_assert(rng != nullptr);
|
||||
const Network *ns = system_network();
|
||||
const Network *ns = os_network();
|
||||
ck_assert(ns != nullptr);
|
||||
const Memory *mem = system_memory();
|
||||
const Memory *mem = os_memory();
|
||||
ck_assert(mem != nullptr);
|
||||
|
||||
Mono_Time *mono_time = mono_time_new(mem, nullptr, nullptr);
|
||||
@ -824,11 +826,11 @@ static int tcp_oobdata_callback(void *object, const uint8_t *public_key, unsigne
|
||||
|
||||
static void test_tcp_connection2(void)
|
||||
{
|
||||
const Random *rng = system_random();
|
||||
const Random *rng = os_random();
|
||||
ck_assert(rng != nullptr);
|
||||
const Network *ns = system_network();
|
||||
const Network *ns = os_network();
|
||||
ck_assert(ns != nullptr);
|
||||
const Memory *mem = system_memory();
|
||||
const Memory *mem = os_memory();
|
||||
ck_assert(mem != nullptr);
|
||||
|
||||
Mono_Time *mono_time = mono_time_new(mem, nullptr, nullptr);
|
@ -13,7 +13,7 @@
|
||||
|
||||
static void test_bucketnum(void)
|
||||
{
|
||||
const Random *rng = system_random();
|
||||
const Random *rng = os_random();
|
||||
ck_assert(rng != nullptr);
|
||||
uint8_t key1[CRYPTO_PUBLIC_KEY_SIZE], key2[CRYPTO_PUBLIC_KEY_SIZE];
|
||||
random_bytes(rng, key1, sizeof(key1));
|
||||
@ -50,11 +50,11 @@ static void test_announce_data(void *object, const uint8_t *data, uint16_t lengt
|
||||
|
||||
static void test_store_data(void)
|
||||
{
|
||||
const Random *rng = system_random();
|
||||
const Random *rng = os_random();
|
||||
ck_assert(rng != nullptr);
|
||||
const Network *ns = system_network();
|
||||
const Network *ns = os_network();
|
||||
ck_assert(ns != nullptr);
|
||||
const Memory *mem = system_memory();
|
||||
const Memory *mem = os_memory();
|
||||
ck_assert(mem != nullptr);
|
||||
|
||||
Logger *log = logger_new();
|
||||
@ -120,7 +120,6 @@ static void basic_announce_tests(void)
|
||||
test_store_data();
|
||||
}
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
setvbuf(stdout, nullptr, _IONBF, 0);
|
@ -5,6 +5,8 @@
|
||||
#include "../testing/misc_tools.h"
|
||||
#include "../toxcore/Messenger.h"
|
||||
#include "../toxcore/mono_time.h"
|
||||
#include "../toxcore/tox_dispatch.h"
|
||||
#include "../toxcore/tox_events.h"
|
||||
#include "../toxcore/tox_struct.h"
|
||||
|
||||
#include "auto_test_support.h"
|
||||
@ -23,6 +25,7 @@ Run_Auto_Options default_run_auto_options(void)
|
||||
.graph = GRAPH_COMPLETE,
|
||||
.init_autotox = nullptr,
|
||||
.tcp_port = 33188,
|
||||
.events = true,
|
||||
};
|
||||
}
|
||||
|
||||
@ -131,7 +134,15 @@ void iterate_all_wait(AutoTox *autotoxes, uint32_t tox_count, uint32_t wait)
|
||||
|
||||
for (uint32_t i = 0; i < tox_count; ++i) {
|
||||
if (autotoxes[i].alive) {
|
||||
tox_iterate(autotoxes[i].tox, &autotoxes[i]);
|
||||
if (autotoxes[i].events) {
|
||||
Tox_Err_Events_Iterate err;
|
||||
Tox_Events *events = tox_events_iterate(autotoxes[i].tox, true, &err);
|
||||
ck_assert(err == TOX_ERR_EVENTS_ITERATE_OK);
|
||||
tox_dispatch_invoke(autotoxes[i].dispatch, events, &autotoxes[i]);
|
||||
tox_events_free(events);
|
||||
} else {
|
||||
tox_iterate(autotoxes[i].tox, &autotoxes[i]);
|
||||
}
|
||||
autotoxes[i].clock += wait;
|
||||
}
|
||||
}
|
||||
@ -181,6 +192,7 @@ void kill_autotox(AutoTox *autotox)
|
||||
ck_assert(autotox->alive);
|
||||
fprintf(stderr, "Killing #%u\n", autotox->index);
|
||||
autotox->alive = false;
|
||||
tox_dispatch_free(autotox->dispatch);
|
||||
tox_kill(autotox->tox);
|
||||
}
|
||||
|
||||
@ -202,6 +214,11 @@ void reload(AutoTox *autotox)
|
||||
tox_options_set_savedata_data(options, autotox->save_state, autotox->save_size);
|
||||
autotox->tox = tox_new_log(options, nullptr, &autotox->index);
|
||||
ck_assert(autotox->tox != nullptr);
|
||||
autotox->dispatch = tox_dispatch_new(nullptr);
|
||||
ck_assert(autotox->dispatch != nullptr);
|
||||
if (autotox->events) {
|
||||
tox_events_init(autotox->tox);
|
||||
}
|
||||
tox_options_free(options);
|
||||
|
||||
set_mono_time_callback(autotox);
|
||||
@ -212,6 +229,7 @@ static void initialise_autotox(struct Tox_Options *options, AutoTox *autotox, ui
|
||||
Run_Auto_Options *autotest_opts)
|
||||
{
|
||||
autotox->index = index;
|
||||
autotox->events = autotest_opts->events;
|
||||
|
||||
Tox_Err_New err = TOX_ERR_NEW_OK;
|
||||
|
||||
@ -259,6 +277,12 @@ static void initialise_autotox(struct Tox_Options *options, AutoTox *autotox, ui
|
||||
|
||||
set_mono_time_callback(autotox);
|
||||
|
||||
autotox->dispatch = tox_dispatch_new(nullptr);
|
||||
ck_assert(autotox->dispatch != nullptr);
|
||||
if (autotox->events) {
|
||||
tox_events_init(autotox->tox);
|
||||
}
|
||||
|
||||
autotox->alive = true;
|
||||
autotox->save_state = nullptr;
|
||||
|
||||
@ -311,7 +335,7 @@ static void initialise_friend_graph(Graph_Type graph, uint32_t num_toxes, AutoTo
|
||||
}
|
||||
}
|
||||
|
||||
static void bootstrap_autotoxes(struct Tox_Options *options, uint32_t tox_count, const Run_Auto_Options *autotest_opts,
|
||||
static void bootstrap_autotoxes(const Tox_Options *options, uint32_t tox_count, const Run_Auto_Options *autotest_opts,
|
||||
AutoTox *autotoxes)
|
||||
{
|
||||
const bool udp_enabled = options != nullptr ? tox_options_get_udp_enabled(options) : true;
|
||||
@ -339,7 +363,9 @@ static void bootstrap_autotoxes(struct Tox_Options *options, uint32_t tox_count,
|
||||
}
|
||||
}
|
||||
|
||||
void run_auto_test(struct Tox_Options *options, uint32_t tox_count, void test(AutoTox *autotoxes),
|
||||
typedef void autotox_test_cb(AutoTox *autotoxes);
|
||||
|
||||
void run_auto_test(struct Tox_Options *options, uint32_t tox_count, autotox_test_cb *test,
|
||||
uint32_t state_size, Run_Auto_Options *autotest_opts)
|
||||
{
|
||||
printf("initialising %u toxes\n", tox_count);
|
||||
@ -371,6 +397,7 @@ void run_auto_test(struct Tox_Options *options, uint32_t tox_count, void test(Au
|
||||
test(autotoxes);
|
||||
|
||||
for (uint32_t i = 0; i < tox_count; ++i) {
|
||||
tox_dispatch_free(autotoxes[i].dispatch);
|
||||
tox_kill(autotoxes[i].tox);
|
||||
free(autotoxes[i].state);
|
||||
free(autotoxes[i].save_state);
|
||||
@ -417,7 +444,6 @@ void print_debug_log(Tox *m, Tox_Log_Level level, const char *file, uint32_t lin
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void print_debug_logger(void *context, Logger_Level level, const char *file, int line, const char *func, const char *message, void *userdata)
|
||||
{
|
||||
print_debug_log(nullptr, (Tox_Log_Level) level, file, (uint32_t) line, func, message, userdata);
|
||||
@ -455,4 +481,3 @@ Tox *tox_new_log(struct Tox_Options *options, Tox_Err_New *err, void *log_user_d
|
||||
{
|
||||
return tox_new_log_lan(options, err, log_user_data, false);
|
||||
}
|
||||
|
@ -7,9 +7,11 @@
|
||||
#include "../testing/misc_tools.h"
|
||||
#include "../toxcore/Messenger.h"
|
||||
#include "../toxcore/mono_time.h"
|
||||
#include "../toxcore/tox_dispatch.h"
|
||||
|
||||
typedef struct AutoTox {
|
||||
Tox *tox;
|
||||
Tox_Dispatch *dispatch;
|
||||
|
||||
uint32_t index;
|
||||
uint64_t clock;
|
||||
@ -17,6 +19,7 @@ typedef struct AutoTox {
|
||||
size_t save_size;
|
||||
uint8_t *save_state;
|
||||
bool alive;
|
||||
bool events;
|
||||
|
||||
void *state;
|
||||
} AutoTox;
|
||||
@ -42,6 +45,7 @@ typedef struct Run_Auto_Options {
|
||||
Graph_Type graph;
|
||||
void (*init_autotox)(AutoTox *autotox, uint32_t n);
|
||||
uint16_t tcp_port;
|
||||
bool events;
|
||||
} Run_Auto_Options;
|
||||
|
||||
Run_Auto_Options default_run_auto_options(void);
|
||||
@ -57,7 +61,7 @@ void print_debug_log(Tox *m, Tox_Log_Level level, const char *file, uint32_t lin
|
||||
|
||||
// Use this function when setting the log callback on a Logger object
|
||||
void print_debug_logger(void *context, Logger_Level level, const char *file, int line,
|
||||
const char *func, const char *message, void *userdata);
|
||||
const char *func, const char *message, void *userdata);
|
||||
|
||||
Tox *tox_new_log(struct Tox_Options *options, Tox_Err_New *err, void *log_user_data);
|
||||
Tox *tox_new_log_lan(struct Tox_Options *options, Tox_Err_New *err, void *log_user_data, bool lan_discovery);
|
@ -23,10 +23,11 @@ typedef struct State {
|
||||
} State;
|
||||
|
||||
static void handle_self_connection_status(
|
||||
Tox *tox, Tox_Connection connection_status, void *user_data)
|
||||
const Tox_Event_Self_Connection_Status *event, void *user_data)
|
||||
{
|
||||
const AutoTox *autotox = (AutoTox *)user_data;
|
||||
|
||||
const Tox_Connection connection_status = tox_event_self_connection_status_get_connection_status(event);
|
||||
if (connection_status != TOX_CONNECTION_NONE) {
|
||||
printf("tox #%u: is now connected\n", autotox->index);
|
||||
} else {
|
||||
@ -35,10 +36,13 @@ static void handle_self_connection_status(
|
||||
}
|
||||
|
||||
static void handle_friend_connection_status(
|
||||
Tox *tox, uint32_t friendnumber, Tox_Connection connection_status, void *user_data)
|
||||
const Tox_Event_Friend_Connection_Status *event, void *user_data)
|
||||
{
|
||||
const AutoTox *autotox = (AutoTox *)user_data;
|
||||
|
||||
const uint32_t friendnumber = tox_event_friend_connection_status_get_friend_number(event);
|
||||
const Tox_Connection connection_status = tox_event_friend_connection_status_get_connection_status(event);
|
||||
|
||||
if (connection_status != TOX_CONNECTION_NONE) {
|
||||
printf("tox #%u: is now connected to friend %u\n", autotox->index, friendnumber);
|
||||
} else {
|
||||
@ -70,28 +74,33 @@ static void audio_callback(void *tox, uint32_t groupnumber, uint32_t peernumber,
|
||||
}
|
||||
|
||||
static void handle_conference_invite(
|
||||
Tox *tox, uint32_t friendnumber, Tox_Conference_Type type,
|
||||
const uint8_t *data, size_t length, void *user_data)
|
||||
const Tox_Event_Conference_Invite *event, void *user_data)
|
||||
{
|
||||
const AutoTox *autotox = (AutoTox *)user_data;
|
||||
|
||||
const uint32_t friend_number = tox_event_conference_invite_get_friend_number(event);
|
||||
const Tox_Conference_Type type = tox_event_conference_invite_get_type(event);
|
||||
const uint8_t *cookie = tox_event_conference_invite_get_cookie(event);
|
||||
const size_t length = tox_event_conference_invite_get_cookie_length(event);
|
||||
|
||||
ck_assert_msg(type == TOX_CONFERENCE_TYPE_AV, "tox #%u: wrong conference type: %d", autotox->index, type);
|
||||
|
||||
ck_assert_msg(toxav_join_av_groupchat(tox, friendnumber, data, length, audio_callback, user_data) == 0,
|
||||
ck_assert_msg(toxav_join_av_groupchat(autotox->tox, friend_number, cookie, length, audio_callback, user_data) == 0,
|
||||
"tox #%u: failed to join group", autotox->index);
|
||||
}
|
||||
|
||||
static void handle_conference_connected(
|
||||
Tox *tox, uint32_t conference_number, void *user_data)
|
||||
const Tox_Event_Conference_Connected *event, void *user_data)
|
||||
{
|
||||
const AutoTox *autotox = (AutoTox *)user_data;
|
||||
State *state = (State *)autotox->state;
|
||||
|
||||
if (state->invited_next || tox_self_get_friend_list_size(tox) <= 1) {
|
||||
if (state->invited_next || tox_self_get_friend_list_size(autotox->tox) <= 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
Tox_Err_Conference_Invite err;
|
||||
tox_conference_invite(tox, 1, 0, &err);
|
||||
tox_conference_invite(autotox->tox, 1, 0, &err);
|
||||
ck_assert_msg(err == TOX_ERR_CONFERENCE_INVITE_OK, "tox #%u failed to invite next friend: err = %d", autotox->index,
|
||||
err);
|
||||
printf("tox #%u: invited next friend\n", autotox->index);
|
||||
@ -99,7 +108,7 @@ static void handle_conference_connected(
|
||||
}
|
||||
|
||||
static bool toxes_are_disconnected_from_group(uint32_t tox_count, AutoTox *autotoxes,
|
||||
bool *disconnected)
|
||||
const bool *disconnected)
|
||||
{
|
||||
uint32_t num_disconnected = 0;
|
||||
|
||||
@ -138,7 +147,10 @@ static void disconnect_toxes(uint32_t tox_count, AutoTox *autotoxes,
|
||||
do {
|
||||
for (uint32_t i = 0; i < tox_count; ++i) {
|
||||
if (!disconnect_now[i]) {
|
||||
tox_iterate(autotoxes[i].tox, &autotoxes[i]);
|
||||
Tox_Err_Events_Iterate err;
|
||||
Tox_Events *events = tox_events_iterate(autotoxes[i].tox, true, &err);
|
||||
tox_dispatch_invoke(autotoxes[i].dispatch, events, &autotoxes[i]);
|
||||
tox_events_free(events);
|
||||
autotoxes[i].clock += 1000;
|
||||
}
|
||||
}
|
||||
@ -165,7 +177,7 @@ static bool all_connected_to_group(uint32_t tox_count, AutoTox *autotoxes)
|
||||
* returns a random index at which a list of booleans is false
|
||||
* (some such index is required to exist)
|
||||
*/
|
||||
static uint32_t random_false_index(const Random *rng, bool *list, const uint32_t length)
|
||||
static uint32_t random_false_index(const Random *rng, const bool *list, const uint32_t length)
|
||||
{
|
||||
uint32_t index;
|
||||
|
||||
@ -185,7 +197,7 @@ static bool all_got_audio(AutoTox *autotoxes, const bool *disabled)
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < NUM_AV_GROUP_TOX; ++i) {
|
||||
State *state = (State *)autotoxes[i].state;
|
||||
const State *state = (const State *)autotoxes[i].state;
|
||||
|
||||
if (disabled[i] ^ (state->received_audio_num
|
||||
!= NUM_AV_GROUP_TOX - num_disabled - 1)) {
|
||||
@ -291,7 +303,7 @@ static void do_audio(AutoTox *autotoxes, uint32_t iterations)
|
||||
|
||||
static void run_conference_tests(AutoTox *autotoxes)
|
||||
{
|
||||
const Random *rng = system_random();
|
||||
const Random *rng = os_random();
|
||||
ck_assert(rng != nullptr);
|
||||
bool disabled[NUM_AV_GROUP_TOX] = {0};
|
||||
|
||||
@ -402,10 +414,10 @@ static void test_groupav(AutoTox *autotoxes)
|
||||
const time_t test_start_time = time(nullptr);
|
||||
|
||||
for (uint32_t i = 0; i < NUM_AV_GROUP_TOX; ++i) {
|
||||
tox_callback_self_connection_status(autotoxes[i].tox, &handle_self_connection_status);
|
||||
tox_callback_friend_connection_status(autotoxes[i].tox, &handle_friend_connection_status);
|
||||
tox_callback_conference_invite(autotoxes[i].tox, &handle_conference_invite);
|
||||
tox_callback_conference_connected(autotoxes[i].tox, &handle_conference_connected);
|
||||
tox_events_callback_self_connection_status(autotoxes[i].dispatch, handle_self_connection_status);
|
||||
tox_events_callback_friend_connection_status(autotoxes[i].dispatch, handle_friend_connection_status);
|
||||
tox_events_callback_conference_invite(autotoxes[i].dispatch, handle_conference_invite);
|
||||
tox_events_callback_conference_connected(autotoxes[i].dispatch, handle_conference_connected);
|
||||
}
|
||||
|
||||
ck_assert_msg(toxav_add_av_groupchat(autotoxes[0].tox, audio_callback, &autotoxes[0]) != UINT32_MAX,
|
||||
@ -414,7 +426,6 @@ static void test_groupav(AutoTox *autotoxes)
|
||||
ck_assert_msg(tox_conference_invite(autotoxes[0].tox, 0, 0, nullptr) != 0, "failed to invite friend");
|
||||
((State *)autotoxes[0].state)->invited_next = true;
|
||||
|
||||
|
||||
printf("waiting for invitations to be made\n");
|
||||
uint32_t invited_count = 0;
|
||||
|
@ -12,12 +12,16 @@ typedef struct State {
|
||||
#include "auto_test_support.h"
|
||||
|
||||
static void handle_conference_invite(
|
||||
Tox *tox, uint32_t friend_number, Tox_Conference_Type type,
|
||||
const uint8_t *cookie, size_t length, void *user_data)
|
||||
const Tox_Event_Conference_Invite *event, void *user_data)
|
||||
{
|
||||
const AutoTox *autotox = (AutoTox *)user_data;
|
||||
State *state = (State *)autotox->state;
|
||||
|
||||
const uint32_t friend_number = tox_event_conference_invite_get_friend_number(event);
|
||||
const Tox_Conference_Type type = tox_event_conference_invite_get_type(event);
|
||||
const uint8_t *cookie = tox_event_conference_invite_get_cookie(event);
|
||||
const size_t length = tox_event_conference_invite_get_cookie_length(event);
|
||||
|
||||
fprintf(stderr, "handle_conference_invite(#%u, %u, %d, uint8_t[%u], _)\n",
|
||||
autotox->index, friend_number, type, (unsigned)length);
|
||||
fprintf(stderr, "tox%u joining conference\n", autotox->index);
|
||||
@ -26,7 +30,7 @@ static void handle_conference_invite(
|
||||
|
||||
if (friend_number != -1) {
|
||||
Tox_Err_Conference_Join err;
|
||||
state->conference = tox_conference_join(tox, friend_number, cookie, length, &err);
|
||||
state->conference = tox_conference_join(autotox->tox, friend_number, cookie, length, &err);
|
||||
ck_assert_msg(err == TOX_ERR_CONFERENCE_JOIN_OK,
|
||||
"attempting to join the conference returned with an error: %d", err);
|
||||
fprintf(stderr, "tox%u joined conference %u\n", autotox->index, state->conference);
|
||||
@ -37,8 +41,8 @@ static void handle_conference_invite(
|
||||
static void conference_double_invite_test(AutoTox *autotoxes)
|
||||
{
|
||||
// Conference callbacks.
|
||||
tox_callback_conference_invite(autotoxes[0].tox, handle_conference_invite);
|
||||
tox_callback_conference_invite(autotoxes[1].tox, handle_conference_invite);
|
||||
tox_events_callback_conference_invite(autotoxes[0].dispatch, handle_conference_invite);
|
||||
tox_events_callback_conference_invite(autotoxes[1].dispatch, handle_conference_invite);
|
||||
|
||||
State *state[2];
|
||||
state[0] = (State *)autotoxes[0].state;
|
@ -12,15 +12,18 @@ typedef struct State {
|
||||
#include "auto_test_support.h"
|
||||
|
||||
static void handle_conference_invite(
|
||||
Tox *tox, uint32_t friend_number, Tox_Conference_Type type,
|
||||
const uint8_t *cookie, size_t length, void *user_data)
|
||||
const Tox_Event_Conference_Invite *event, void *user_data)
|
||||
{
|
||||
const AutoTox *autotox = (AutoTox *)user_data;
|
||||
State *state = (State *)autotox->state;
|
||||
|
||||
const uint32_t friend_number = tox_event_conference_invite_get_friend_number(event);
|
||||
const uint8_t *cookie = tox_event_conference_invite_get_cookie(event);
|
||||
const size_t length = tox_event_conference_invite_get_cookie_length(event);
|
||||
|
||||
if (friend_number != -1) {
|
||||
Tox_Err_Conference_Join err;
|
||||
state->conference = tox_conference_join(tox, friend_number, cookie, length, &err);
|
||||
state->conference = tox_conference_join(autotox->tox, friend_number, cookie, length, &err);
|
||||
ck_assert_msg(err == TOX_ERR_CONFERENCE_JOIN_OK,
|
||||
"attempting to join the conference returned with an error: %d", err);
|
||||
fprintf(stderr, "#%u accepted invite to conference %u\n", autotox->index, state->conference);
|
||||
@ -28,7 +31,7 @@ static void handle_conference_invite(
|
||||
}
|
||||
|
||||
static void handle_conference_connected(
|
||||
Tox *tox, uint32_t conference_number, void *user_data)
|
||||
const Tox_Event_Conference_Connected *event, void *user_data)
|
||||
{
|
||||
const AutoTox *autotox = (AutoTox *)user_data;
|
||||
State *state = (State *)autotox->state;
|
||||
@ -37,7 +40,7 @@ static void handle_conference_connected(
|
||||
state->connected = true;
|
||||
}
|
||||
|
||||
static void wait_connected(AutoTox *autotoxes, AutoTox *autotox, uint32_t friendnumber)
|
||||
static void wait_connected(AutoTox *autotoxes, const AutoTox *autotox, uint32_t friendnumber)
|
||||
{
|
||||
do {
|
||||
iterate_all_wait(autotoxes, NUM_INVITE_MERGE_TOX, ITERATION_INTERVAL);
|
||||
@ -95,8 +98,8 @@ static void conference_invite_merge_test(AutoTox *autotoxes)
|
||||
// components will cause a split group to merge
|
||||
|
||||
for (int i = 0; i < NUM_INVITE_MERGE_TOX; i++) {
|
||||
tox_callback_conference_invite(autotoxes[i].tox, &handle_conference_invite);
|
||||
tox_callback_conference_connected(autotoxes[i].tox, &handle_conference_connected);
|
||||
tox_events_callback_conference_invite(autotoxes[i].dispatch, handle_conference_invite);
|
||||
tox_events_callback_conference_connected(autotoxes[i].dispatch, handle_conference_connected);
|
||||
}
|
||||
|
||||
State *state2 = (State *)autotoxes[2].state;
|
@ -13,34 +13,39 @@ typedef struct State {
|
||||
#include "auto_test_support.h"
|
||||
|
||||
static void handle_conference_invite(
|
||||
Tox *tox, uint32_t friend_number, Tox_Conference_Type type,
|
||||
const uint8_t *cookie, size_t length, void *user_data)
|
||||
const Tox_Event_Conference_Invite *event, void *user_data)
|
||||
{
|
||||
const AutoTox *autotox = (AutoTox *)user_data;
|
||||
State *state = (State *)autotox->state;
|
||||
|
||||
const uint32_t friend_number = tox_event_conference_invite_get_friend_number(event);
|
||||
const Tox_Conference_Type type = tox_event_conference_invite_get_type(event);
|
||||
const uint8_t *cookie = tox_event_conference_invite_get_cookie(event);
|
||||
const size_t length = tox_event_conference_invite_get_cookie_length(event);
|
||||
|
||||
fprintf(stderr, "handle_conference_invite(#%u, %u, %d, uint8_t[%u], _)\n",
|
||||
autotox->index, friend_number, type, (unsigned)length);
|
||||
fprintf(stderr, "tox%u joining conference\n", autotox->index);
|
||||
|
||||
Tox_Err_Conference_Join err;
|
||||
state->conference = tox_conference_join(tox, friend_number, cookie, length, &err);
|
||||
state->conference = tox_conference_join(autotox->tox, friend_number, cookie, length, &err);
|
||||
ck_assert_msg(err == TOX_ERR_CONFERENCE_JOIN_OK,
|
||||
"attempting to join the conference returned with an error: %d", err);
|
||||
fprintf(stderr, "tox%u joined conference %u\n", autotox->index, state->conference);
|
||||
state->joined = true;
|
||||
}
|
||||
|
||||
static void handle_peer_list_changed(Tox *tox, uint32_t conference_number, void *user_data)
|
||||
static void handle_peer_list_changed(const Tox_Event_Conference_Peer_List_Changed *event, void *user_data)
|
||||
{
|
||||
const AutoTox *autotox = (AutoTox *)user_data;
|
||||
State *state = (State *)autotox->state;
|
||||
|
||||
const uint32_t conference_number = tox_event_conference_peer_list_changed_get_conference_number(event);
|
||||
fprintf(stderr, "handle_peer_list_changed(#%u, %u, _)\n",
|
||||
autotox->index, conference_number);
|
||||
|
||||
Tox_Err_Conference_Peer_Query err;
|
||||
uint32_t const count = tox_conference_peer_count(tox, conference_number, &err);
|
||||
uint32_t const count = tox_conference_peer_count(autotox->tox, conference_number, &err);
|
||||
ck_assert_msg(err == TOX_ERR_CONFERENCE_PEER_QUERY_OK,
|
||||
"failed to get conference peer count: err = %d", err);
|
||||
printf("tox%u has %u peers\n", autotox->index, count);
|
||||
@ -75,10 +80,10 @@ static void rebuild_peer_list(Tox *tox)
|
||||
static void conference_peer_nick_test(AutoTox *autotoxes)
|
||||
{
|
||||
// Conference callbacks.
|
||||
tox_callback_conference_invite(autotoxes[0].tox, handle_conference_invite);
|
||||
tox_callback_conference_invite(autotoxes[1].tox, handle_conference_invite);
|
||||
tox_callback_conference_peer_list_changed(autotoxes[0].tox, handle_peer_list_changed);
|
||||
tox_callback_conference_peer_list_changed(autotoxes[1].tox, handle_peer_list_changed);
|
||||
tox_events_callback_conference_invite(autotoxes[0].dispatch, handle_conference_invite);
|
||||
tox_events_callback_conference_invite(autotoxes[1].dispatch, handle_conference_invite);
|
||||
tox_events_callback_conference_peer_list_changed(autotoxes[0].dispatch, handle_peer_list_changed);
|
||||
tox_events_callback_conference_peer_list_changed(autotoxes[1].dispatch, handle_peer_list_changed);
|
||||
|
||||
// Set the names of the toxes.
|
||||
tox_self_set_name(autotoxes[0].tox, (const uint8_t *)"test-tox-0", 10, nullptr);
|
268
auto_tests/conference_simple_test.c
Normal file
268
auto_tests/conference_simple_test.c
Normal file
@ -0,0 +1,268 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "../testing/misc_tools.h"
|
||||
#include "../toxcore/tox.h"
|
||||
#include "../toxcore/tox_dispatch.h"
|
||||
#include "../toxcore/tox_events.h"
|
||||
#include "auto_test_support.h"
|
||||
#include "check_compat.h"
|
||||
|
||||
typedef struct State {
|
||||
uint32_t id;
|
||||
Tox *tox;
|
||||
bool self_online;
|
||||
bool friend_online;
|
||||
bool invited_next;
|
||||
|
||||
bool joined;
|
||||
uint32_t conference;
|
||||
|
||||
bool received;
|
||||
|
||||
uint32_t peers;
|
||||
} State;
|
||||
|
||||
static void handle_self_connection_status(const Tox_Event_Self_Connection_Status *event, void *user_data)
|
||||
{
|
||||
State *state = (State *)user_data;
|
||||
|
||||
const Tox_Connection connection_status = tox_event_self_connection_status_get_connection_status(event);
|
||||
fprintf(stderr, "self_connection_status(#%u, %d, _)\n", state->id, connection_status);
|
||||
state->self_online = connection_status != TOX_CONNECTION_NONE;
|
||||
}
|
||||
|
||||
static void handle_friend_connection_status(const Tox_Event_Friend_Connection_Status *event,
|
||||
void *user_data)
|
||||
{
|
||||
State *state = (State *)user_data;
|
||||
|
||||
const uint32_t friend_number = tox_event_friend_connection_status_get_friend_number(event);
|
||||
const Tox_Connection connection_status = tox_event_friend_connection_status_get_connection_status(event);
|
||||
fprintf(stderr, "handle_friend_connection_status(#%u, %u, %d, _)\n", state->id, friend_number, connection_status);
|
||||
state->friend_online = connection_status != TOX_CONNECTION_NONE;
|
||||
}
|
||||
|
||||
static void handle_conference_invite(const Tox_Event_Conference_Invite *event, void *user_data)
|
||||
{
|
||||
State *state = (State *)user_data;
|
||||
|
||||
const uint32_t friend_number = tox_event_conference_invite_get_friend_number(event);
|
||||
const Tox_Conference_Type type = tox_event_conference_invite_get_type(event);
|
||||
const uint8_t *cookie = tox_event_conference_invite_get_cookie(event);
|
||||
const size_t length = tox_event_conference_invite_get_cookie_length(event);
|
||||
fprintf(stderr, "handle_conference_invite(#%u, %u, %d, uint8_t[%u], _)\n",
|
||||
state->id, friend_number, type, (unsigned)length);
|
||||
fprintf(stderr, "tox%u joining conference\n", state->id);
|
||||
|
||||
{
|
||||
Tox_Err_Conference_Join err;
|
||||
state->conference = tox_conference_join(state->tox, friend_number, cookie, length, &err);
|
||||
ck_assert_msg(err == TOX_ERR_CONFERENCE_JOIN_OK, "failed to join a conference: err = %d", err);
|
||||
fprintf(stderr, "tox%u Joined conference %u\n", state->id, state->conference);
|
||||
state->joined = true;
|
||||
}
|
||||
}
|
||||
|
||||
static void handle_conference_message(const Tox_Event_Conference_Message *event, void *user_data)
|
||||
{
|
||||
State *state = (State *)user_data;
|
||||
|
||||
const uint32_t conference_number = tox_event_conference_message_get_conference_number(event);
|
||||
const uint32_t peer_number = tox_event_conference_message_get_peer_number(event);
|
||||
const Tox_Message_Type type = tox_event_conference_message_get_type(event);
|
||||
const uint8_t *message = tox_event_conference_message_get_message(event);
|
||||
const size_t length = tox_event_conference_message_get_message_length(event);
|
||||
|
||||
fprintf(stderr, "handle_conference_message(#%u, %u, %u, %d, uint8_t[%u], _)\n",
|
||||
state->id, conference_number, peer_number, type, (unsigned)length);
|
||||
|
||||
fprintf(stderr, "tox%u got message: %s\n", state->id, (const char *)message);
|
||||
state->received = true;
|
||||
}
|
||||
|
||||
static void handle_conference_peer_list_changed(const Tox_Event_Conference_Peer_List_Changed *event, void *user_data)
|
||||
{
|
||||
State *state = (State *)user_data;
|
||||
|
||||
const uint32_t conference_number = tox_event_conference_peer_list_changed_get_conference_number(event);
|
||||
fprintf(stderr, "handle_conference_peer_list_changed(#%u, %u, _)\n",
|
||||
state->id, conference_number);
|
||||
|
||||
Tox_Err_Conference_Peer_Query err;
|
||||
uint32_t count = tox_conference_peer_count(state->tox, conference_number, &err);
|
||||
|
||||
if (err != TOX_ERR_CONFERENCE_PEER_QUERY_OK) {
|
||||
fprintf(stderr, "ERROR: %d\n", err);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
fprintf(stderr, "tox%u has %u peers online\n", state->id, count);
|
||||
state->peers = count;
|
||||
}
|
||||
|
||||
static void handle_conference_connected(const Tox_Event_Conference_Connected *event, void *user_data)
|
||||
{
|
||||
State *state = (State *)user_data;
|
||||
|
||||
// We're tox2, so now we invite tox3.
|
||||
if (state->id == 2 && !state->invited_next) {
|
||||
Tox_Err_Conference_Invite err;
|
||||
tox_conference_invite(state->tox, 1, state->conference, &err);
|
||||
ck_assert_msg(err == TOX_ERR_CONFERENCE_INVITE_OK, "tox2 failed to invite tox3: err = %d", err);
|
||||
|
||||
state->invited_next = true;
|
||||
fprintf(stderr, "tox2 invited tox3\n");
|
||||
}
|
||||
}
|
||||
|
||||
static void iterate_one(
|
||||
Tox *tox, State *state, const Tox_Dispatch *dispatch)
|
||||
{
|
||||
Tox_Err_Events_Iterate err;
|
||||
Tox_Events *events = tox_events_iterate(tox, true, &err);
|
||||
ck_assert(err == TOX_ERR_EVENTS_ITERATE_OK);
|
||||
tox_dispatch_invoke(dispatch, events, state);
|
||||
tox_events_free(events);
|
||||
}
|
||||
|
||||
static void iterate3_wait(
|
||||
State *state1, State *state2, State *state3,
|
||||
const Tox_Dispatch *dispatch, int interval)
|
||||
{
|
||||
iterate_one(state1->tox, state1, dispatch);
|
||||
iterate_one(state2->tox, state2, dispatch);
|
||||
iterate_one(state3->tox, state3, dispatch);
|
||||
|
||||
c_sleep(interval);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
setvbuf(stdout, nullptr, _IONBF, 0);
|
||||
|
||||
State state1 = {1};
|
||||
State state2 = {2};
|
||||
State state3 = {3};
|
||||
|
||||
// Create toxes.
|
||||
state1.tox = tox_new_log(nullptr, nullptr, &state1.id);
|
||||
state2.tox = tox_new_log(nullptr, nullptr, &state2.id);
|
||||
state3.tox = tox_new_log(nullptr, nullptr, &state3.id);
|
||||
|
||||
tox_events_init(state1.tox);
|
||||
tox_events_init(state2.tox);
|
||||
tox_events_init(state3.tox);
|
||||
|
||||
// tox1 <-> tox2, tox2 <-> tox3
|
||||
uint8_t key[TOX_PUBLIC_KEY_SIZE];
|
||||
tox_self_get_public_key(state2.tox, key);
|
||||
tox_friend_add_norequest(state1.tox, key, nullptr); // tox1 -> tox2
|
||||
tox_self_get_public_key(state1.tox, key);
|
||||
tox_friend_add_norequest(state2.tox, key, nullptr); // tox2 -> tox1
|
||||
tox_self_get_public_key(state3.tox, key);
|
||||
tox_friend_add_norequest(state2.tox, key, nullptr); // tox2 -> tox3
|
||||
tox_self_get_public_key(state2.tox, key);
|
||||
tox_friend_add_norequest(state3.tox, key, nullptr); // tox3 -> tox2
|
||||
|
||||
printf("bootstrapping tox2 and tox3 off tox1\n");
|
||||
uint8_t dht_key[TOX_PUBLIC_KEY_SIZE];
|
||||
tox_self_get_dht_id(state1.tox, dht_key);
|
||||
const uint16_t dht_port = tox_self_get_udp_port(state1.tox, nullptr);
|
||||
|
||||
tox_bootstrap(state2.tox, "localhost", dht_port, dht_key, nullptr);
|
||||
tox_bootstrap(state3.tox, "localhost", dht_port, dht_key, nullptr);
|
||||
|
||||
Tox_Dispatch *dispatch = tox_dispatch_new(nullptr);
|
||||
ck_assert(dispatch != nullptr);
|
||||
|
||||
// Connection callbacks.
|
||||
tox_events_callback_self_connection_status(dispatch, handle_self_connection_status);
|
||||
tox_events_callback_friend_connection_status(dispatch, handle_friend_connection_status);
|
||||
|
||||
// Conference callbacks.
|
||||
tox_events_callback_conference_invite(dispatch, handle_conference_invite);
|
||||
tox_events_callback_conference_connected(dispatch, handle_conference_connected);
|
||||
tox_events_callback_conference_message(dispatch, handle_conference_message);
|
||||
tox_events_callback_conference_peer_list_changed(dispatch, handle_conference_peer_list_changed);
|
||||
|
||||
// Wait for self connection.
|
||||
fprintf(stderr, "Waiting for toxes to come online\n");
|
||||
|
||||
do {
|
||||
iterate3_wait(&state1, &state2, &state3, dispatch, 100);
|
||||
} while (!state1.self_online || !state2.self_online || !state3.self_online);
|
||||
|
||||
fprintf(stderr, "Toxes are online\n");
|
||||
|
||||
// Wait for friend connection.
|
||||
fprintf(stderr, "Waiting for friends to connect\n");
|
||||
|
||||
do {
|
||||
iterate3_wait(&state1, &state2, &state3, dispatch, 100);
|
||||
} while (!state1.friend_online || !state2.friend_online || !state3.friend_online);
|
||||
|
||||
fprintf(stderr, "Friends are connected\n");
|
||||
|
||||
{
|
||||
// Create new conference, tox1 is the founder.
|
||||
Tox_Err_Conference_New err;
|
||||
state1.conference = tox_conference_new(state1.tox, &err);
|
||||
state1.joined = true;
|
||||
ck_assert_msg(err == TOX_ERR_CONFERENCE_NEW_OK, "failed to create a conference: err = %d", err);
|
||||
fprintf(stderr, "Created conference: id = %u\n", state1.conference);
|
||||
}
|
||||
|
||||
{
|
||||
// Invite friend.
|
||||
Tox_Err_Conference_Invite err;
|
||||
tox_conference_invite(state1.tox, 0, state1.conference, &err);
|
||||
ck_assert_msg(err == TOX_ERR_CONFERENCE_INVITE_OK, "failed to invite a friend: err = %d", err);
|
||||
state1.invited_next = true;
|
||||
fprintf(stderr, "tox1 invited tox2\n");
|
||||
}
|
||||
|
||||
fprintf(stderr, "Waiting for invitation to arrive\n");
|
||||
|
||||
do {
|
||||
iterate3_wait(&state1, &state2, &state3, dispatch, 100);
|
||||
} while (!state1.joined || !state2.joined || !state3.joined);
|
||||
|
||||
fprintf(stderr, "Invitations accepted\n");
|
||||
|
||||
fprintf(stderr, "Waiting for peers to come online\n");
|
||||
|
||||
do {
|
||||
iterate3_wait(&state1, &state2, &state3, dispatch, 100);
|
||||
} while (state1.peers == 0 || state2.peers == 0 || state3.peers == 0);
|
||||
|
||||
fprintf(stderr, "All peers are online\n");
|
||||
|
||||
{
|
||||
fprintf(stderr, "tox1 sends a message to the group: \"hello!\"\n");
|
||||
Tox_Err_Conference_Send_Message err;
|
||||
tox_conference_send_message(state1.tox, state1.conference, TOX_MESSAGE_TYPE_NORMAL,
|
||||
(const uint8_t *)"hello!", 7, &err);
|
||||
|
||||
if (err != TOX_ERR_CONFERENCE_SEND_MESSAGE_OK) {
|
||||
fprintf(stderr, "ERROR: %d\n", err);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stderr, "Waiting for messages to arrive\n");
|
||||
|
||||
do {
|
||||
iterate3_wait(&state1, &state2, &state3, dispatch, 100);
|
||||
c_sleep(100);
|
||||
} while (!state2.received || !state3.received);
|
||||
|
||||
fprintf(stderr, "Messages received. Test complete.\n");
|
||||
|
||||
tox_dispatch_free(dispatch);
|
||||
tox_kill(state3.tox);
|
||||
tox_kill(state2.tox);
|
||||
tox_kill(state1.tox);
|
||||
|
||||
return 0;
|
||||
}
|
@ -56,13 +56,13 @@ static void handle_conference_invite(
|
||||
ck_assert_msg(type == TOX_CONFERENCE_TYPE_TEXT, "tox #%u: wrong conference type: %d", autotox->index, type);
|
||||
|
||||
Tox_Err_Conference_Join err;
|
||||
uint32_t g_num = tox_conference_join(tox, friendnumber, data, length, &err);
|
||||
uint32_t g_num = tox_conference_join(autotox->tox, friendnumber, data, length, &err);
|
||||
|
||||
ck_assert_msg(err == TOX_ERR_CONFERENCE_JOIN_OK, "tox #%u: error joining group: %d", autotox->index, err);
|
||||
ck_assert_msg(g_num == 0, "tox #%u: group number was not 0", autotox->index);
|
||||
|
||||
// Try joining again. We should only be allowed to join once.
|
||||
tox_conference_join(tox, friendnumber, data, length, &err);
|
||||
tox_conference_join(autotox->tox, friendnumber, data, length, &err);
|
||||
ck_assert_msg(err != TOX_ERR_CONFERENCE_JOIN_OK,
|
||||
"tox #%u: joining groupchat twice should be impossible.", autotox->index);
|
||||
}
|
||||
@ -73,12 +73,12 @@ static void handle_conference_connected(
|
||||
const AutoTox *autotox = (AutoTox *)user_data;
|
||||
State *state = (State *)autotox->state;
|
||||
|
||||
if (state->invited_next || tox_self_get_friend_list_size(tox) <= 1) {
|
||||
if (state->invited_next || tox_self_get_friend_list_size(autotox->tox) <= 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
Tox_Err_Conference_Invite err;
|
||||
tox_conference_invite(tox, 1, 0, &err);
|
||||
tox_conference_invite(autotox->tox, 1, 0, &err);
|
||||
ck_assert_msg(err == TOX_ERR_CONFERENCE_INVITE_OK, "tox #%u failed to invite next friend: err = %d", autotox->index,
|
||||
err);
|
||||
printf("tox #%u: invited next friend\n", autotox->index);
|
||||
@ -97,7 +97,7 @@ static void handle_conference_message(
|
||||
}
|
||||
|
||||
static bool toxes_are_disconnected_from_group(uint32_t tox_count, AutoTox *autotoxes,
|
||||
bool *disconnected)
|
||||
const bool *disconnected)
|
||||
{
|
||||
uint32_t num_disconnected = 0;
|
||||
|
||||
@ -174,12 +174,11 @@ static bool names_propagated(uint32_t tox_count, AutoTox *autotoxes)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* returns a random index at which a list of booleans is false
|
||||
* (some such index is required to exist)
|
||||
*/
|
||||
static uint32_t random_false_index(const Random *rng, bool *list, const uint32_t length)
|
||||
static uint32_t random_false_index(const Random *rng, const bool *list, const uint32_t length)
|
||||
{
|
||||
uint32_t index;
|
||||
|
||||
@ -192,7 +191,7 @@ static uint32_t random_false_index(const Random *rng, bool *list, const uint32_t
|
||||
|
||||
static void run_conference_tests(AutoTox *autotoxes)
|
||||
{
|
||||
const Random *rng = system_random();
|
||||
const Random *rng = os_random();
|
||||
ck_assert(rng != nullptr);
|
||||
/* disabling name change propagation check for now, as it occasionally
|
||||
* fails due to disconnections too short to trigger freezing */
|
||||
@ -357,7 +356,6 @@ static void test_many_group(AutoTox *autotoxes)
|
||||
nullptr) != 0,
|
||||
"failed to set group title");
|
||||
|
||||
|
||||
printf("waiting for invitations to be made\n");
|
||||
uint32_t invited_count = 0;
|
||||
|
||||
@ -435,6 +433,7 @@ int main(void)
|
||||
|
||||
Run_Auto_Options options = default_run_auto_options();
|
||||
options.graph = GRAPH_LINEAR;
|
||||
options.events = false;
|
||||
|
||||
run_auto_test(nullptr, NUM_GROUP_TOX, test_many_group, sizeof(State), &options);
|
||||
return 0;
|
@ -125,7 +125,7 @@ static void test_fast_known(void)
|
||||
|
||||
static void test_endtoend(void)
|
||||
{
|
||||
const Random *rng = system_random();
|
||||
const Random *rng = os_random();
|
||||
ck_assert(rng != nullptr);
|
||||
|
||||
// Test 100 random messages and keypairs
|
||||
@ -192,7 +192,7 @@ static void test_endtoend(void)
|
||||
|
||||
static void test_large_data(void)
|
||||
{
|
||||
const Random *rng = system_random();
|
||||
const Random *rng = os_random();
|
||||
ck_assert(rng != nullptr);
|
||||
uint8_t k[CRYPTO_SHARED_KEY_SIZE];
|
||||
uint8_t n[CRYPTO_NONCE_SIZE];
|
||||
@ -236,7 +236,7 @@ static void test_large_data(void)
|
||||
|
||||
static void test_large_data_symmetric(void)
|
||||
{
|
||||
const Random *rng = system_random();
|
||||
const Random *rng = os_random();
|
||||
ck_assert(rng != nullptr);
|
||||
uint8_t k[CRYPTO_SYMMETRIC_KEY_SIZE];
|
||||
|
||||
@ -271,10 +271,10 @@ static void test_large_data_symmetric(void)
|
||||
|
||||
static void test_very_large_data(void)
|
||||
{
|
||||
const Random *rng = system_random();
|
||||
const Random *rng = os_random();
|
||||
ck_assert(rng != nullptr);
|
||||
|
||||
uint8_t nonce[CRYPTO_NONCE_SIZE] = {0};
|
||||
const uint8_t nonce[CRYPTO_NONCE_SIZE] = {0};
|
||||
uint8_t pk[CRYPTO_PUBLIC_KEY_SIZE];
|
||||
uint8_t sk[CRYPTO_SECRET_KEY_SIZE];
|
||||
crypto_new_keypair(rng, pk, sk);
|
||||
@ -316,7 +316,7 @@ static void increment_nonce_number_cmp(uint8_t *nonce, uint32_t num)
|
||||
|
||||
static void test_increment_nonce(void)
|
||||
{
|
||||
const Random *rng = system_random();
|
||||
const Random *rng = os_random();
|
||||
ck_assert(rng != nullptr);
|
||||
|
||||
uint8_t n[CRYPTO_NONCE_SIZE];
|
Binary file not shown.
BIN
auto_tests/data/save.tox.little
Normal file
BIN
auto_tests/data/save.tox.little
Normal file
Binary file not shown.
@ -72,12 +72,16 @@ static bool all_nodes_crawled(const AutoTox *autotoxes, uint32_t num_toxes, uint
|
||||
return true;
|
||||
}
|
||||
|
||||
static void getnodes_response_cb(Tox *tox, const uint8_t *public_key, const char *ip, uint16_t port, void *user_data)
|
||||
static void getnodes_response_cb(const Tox_Event_Dht_Get_Nodes_Response *event, void *user_data)
|
||||
{
|
||||
ck_assert(user_data != nullptr);
|
||||
|
||||
AutoTox *autotoxes = (AutoTox *)user_data;
|
||||
State *state = (State *)autotoxes->state;
|
||||
AutoTox *autotox = (AutoTox *)user_data;
|
||||
State *state = (State *)autotox->state;
|
||||
|
||||
const uint8_t *public_key = tox_event_dht_get_nodes_response_get_public_key(event);
|
||||
const char *ip = (const char *)tox_event_dht_get_nodes_response_get_ip(event);
|
||||
const uint16_t port = tox_event_dht_get_nodes_response_get_port(event);
|
||||
|
||||
if (node_crawled(state->nodes, state->num_nodes, public_key)) {
|
||||
return;
|
||||
@ -97,7 +101,7 @@ static void getnodes_response_cb(Tox *tox, const uint8_t *public_key, const char
|
||||
|
||||
// ask new node to give us their close nodes to every public key
|
||||
for (size_t i = 0; i < NUM_TOXES; ++i) {
|
||||
tox_dht_get_nodes(tox, public_key, ip, port, state->public_key_list[i], nullptr);
|
||||
tox_dht_get_nodes(autotox->tox, public_key, ip, port, state->public_key_list[i], nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,13 +125,12 @@ static void test_dht_getnodes(AutoTox *autotoxes)
|
||||
ck_assert(public_key_list[i] != nullptr);
|
||||
|
||||
tox_self_get_dht_id(autotoxes[i].tox, public_key_list[i]);
|
||||
tox_callback_dht_get_nodes_response(autotoxes[i].tox, getnodes_response_cb);
|
||||
tox_events_callback_dht_get_nodes_response(autotoxes[i].dispatch, getnodes_response_cb);
|
||||
|
||||
printf("Peer %zu dht closenode count total/announce-capable: %d/%d\n",
|
||||
i,
|
||||
tox_dht_get_num_closelist(autotoxes[i].tox),
|
||||
tox_dht_get_num_closelist_announce_capable(autotoxes[i].tox)
|
||||
);
|
||||
i,
|
||||
tox_dht_get_num_closelist(autotoxes[i].tox),
|
||||
tox_dht_get_num_closelist_announce_capable(autotoxes[i].tox));
|
||||
}
|
||||
|
||||
while (!all_nodes_crawled(autotoxes, NUM_TOXES, public_key_list)) {
|
@ -168,7 +168,7 @@ static void test_keys(void)
|
||||
ck_assert(encrypted2a != nullptr);
|
||||
uint8_t *in_plaintext2a = (uint8_t *)malloc(plaintext_length2a);
|
||||
ck_assert(in_plaintext2a != nullptr);
|
||||
const Random *rng = system_random();
|
||||
const Random *rng = os_random();
|
||||
ck_assert(rng != nullptr);
|
||||
random_bytes(rng, in_plaintext2a, plaintext_length2a);
|
||||
ret = tox_pass_encrypt(in_plaintext2a, plaintext_length2a, key_char, 12, encrypted2a, &encerr);
|
||||
@ -184,7 +184,6 @@ static void test_keys(void)
|
||||
free(in_plaintext2a);
|
||||
free(out_plaintext2a);
|
||||
|
||||
|
||||
uint8_t encrypted2[44 + TOX_PASS_ENCRYPTION_EXTRA_LENGTH];
|
||||
ret = tox_pass_encrypt(string, 44, key_char, 12, encrypted2, &encerr);
|
||||
ck_assert_msg(ret, "generic failure 3: %d", encerr);
|
@ -53,7 +53,7 @@ static void tox_file_receive(Tox *tox, uint32_t friend_number, uint32_t file_num
|
||||
|
||||
ck_assert_msg(memcmp(file_id, file_cmp_id, TOX_FILE_ID_LENGTH) == 0, "bad file_id");
|
||||
|
||||
uint8_t empty[TOX_FILE_ID_LENGTH] = {0};
|
||||
const uint8_t empty[TOX_FILE_ID_LENGTH] = {0};
|
||||
|
||||
ck_assert_msg(memcmp(empty, file_cmp_id, TOX_FILE_ID_LENGTH) != 0, "empty file_id");
|
||||
|
||||
@ -126,7 +126,6 @@ static void tox_file_chunk_request(Tox *tox, uint32_t friend_number, uint32_t fi
|
||||
Tox_Err_File_Send_Chunk error;
|
||||
tox_file_send_chunk(tox, friend_number, file_number, position, f_data, length, &error);
|
||||
|
||||
|
||||
ck_assert_msg(error == TOX_ERR_FILE_SEND_CHUNK_OK,
|
||||
"could not send chunk, error num=%d pos=%d len=%d", (int)error, (int)position, (int)length);
|
||||
|
||||
@ -134,7 +133,6 @@ static void tox_file_chunk_request(Tox *tox, uint32_t friend_number, uint32_t fi
|
||||
sending_pos += length;
|
||||
}
|
||||
|
||||
|
||||
static uint8_t num;
|
||||
static bool file_recv;
|
||||
static void write_file(Tox *tox, uint32_t friendnumber, uint32_t filenumber, uint64_t position, const uint8_t *data,
|
||||
@ -209,7 +207,6 @@ static void file_transfer_test(void)
|
||||
file_accepted = file_size = sendf_ok = size_recv = 0;
|
||||
file_recv = 0;
|
||||
max_sending = UINT64_MAX;
|
||||
uint64_t totalf_size = 100 * 1024 * 1024;
|
||||
|
||||
printf("Starting file streaming transfer test.\n");
|
||||
|
||||
@ -224,10 +221,10 @@ static void file_transfer_test(void)
|
||||
tox_callback_file_chunk_request(tox2, tox_file_chunk_request);
|
||||
tox_callback_file_recv_control(tox3, file_print_control);
|
||||
tox_callback_file_recv(tox3, tox_file_receive);
|
||||
totalf_size = UINT64_MAX;
|
||||
const uint64_t totalf_size = UINT64_MAX;
|
||||
Tox_File_Number fnum = tox_file_send(
|
||||
tox2, 0, TOX_FILE_KIND_DATA, totalf_size, nullptr,
|
||||
(const uint8_t *)"Gentoo.exe", sizeof("Gentoo.exe"), nullptr);
|
||||
tox2, 0, TOX_FILE_KIND_DATA, totalf_size, nullptr,
|
||||
(const uint8_t *)"Gentoo.exe", sizeof("Gentoo.exe"), nullptr);
|
||||
ck_assert_msg(fnum != UINT32_MAX, "tox_new_file_sender fail");
|
||||
|
||||
Tox_Err_File_Get gfierr;
|
@ -26,10 +26,16 @@
|
||||
#define TOX_LOCALHOST "127.0.0.1"
|
||||
#endif
|
||||
|
||||
static void accept_friend_request(Tox *m, const uint8_t *public_key, const uint8_t *data, size_t length, void *userdata)
|
||||
static void accept_friend_request(const Tox_Event_Friend_Request *event, void *userdata)
|
||||
{
|
||||
Tox *tox = (Tox *)userdata;
|
||||
|
||||
const uint8_t *public_key = tox_event_friend_request_get_public_key(event);
|
||||
const uint8_t *data = tox_event_friend_request_get_message(event);
|
||||
const size_t length = tox_event_friend_request_get_message_length(event);
|
||||
|
||||
if (length == 7 && memcmp("Gentoo", data, 7) == 0) {
|
||||
tox_friend_add_norequest(m, public_key, nullptr);
|
||||
tox_friend_add_norequest(tox, public_key, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,9 +45,17 @@ static uint64_t sending_pos;
|
||||
static uint8_t file_cmp_id[TOX_FILE_ID_LENGTH];
|
||||
static uint32_t file_accepted;
|
||||
static uint64_t file_size;
|
||||
static void tox_file_receive(Tox *tox, uint32_t friend_number, uint32_t file_number, uint32_t kind, uint64_t filesize,
|
||||
const uint8_t *filename, size_t filename_length, void *userdata)
|
||||
static void tox_file_receive(const Tox_Event_File_Recv *event, void *userdata)
|
||||
{
|
||||
Tox *state_tox = (Tox *)userdata;
|
||||
|
||||
const uint32_t friend_number = tox_event_file_recv_get_friend_number(event);
|
||||
const uint32_t file_number = tox_event_file_recv_get_file_number(event);
|
||||
const uint32_t kind = tox_event_file_recv_get_kind(event);
|
||||
const uint64_t filesize = tox_event_file_recv_get_file_size(event);
|
||||
const uint8_t *filename = tox_event_file_recv_get_filename(event);
|
||||
const size_t filename_length = tox_event_file_recv_get_filename_length(event);
|
||||
|
||||
ck_assert_msg(kind == TOX_FILE_KIND_DATA, "bad kind");
|
||||
|
||||
ck_assert_msg(filename_length == sizeof("Gentoo.exe")
|
||||
@ -49,11 +63,11 @@ static void tox_file_receive(Tox *tox, uint32_t friend_number, uint32_t file_num
|
||||
|
||||
uint8_t file_id[TOX_FILE_ID_LENGTH];
|
||||
|
||||
ck_assert_msg(tox_file_get_file_id(tox, friend_number, file_number, file_id, nullptr), "tox_file_get_file_id error");
|
||||
ck_assert_msg(tox_file_get_file_id(state_tox, friend_number, file_number, file_id, nullptr), "tox_file_get_file_id error");
|
||||
|
||||
ck_assert_msg(memcmp(file_id, file_cmp_id, TOX_FILE_ID_LENGTH) == 0, "bad file_id");
|
||||
|
||||
uint8_t empty[TOX_FILE_ID_LENGTH] = {0};
|
||||
const uint8_t empty[TOX_FILE_ID_LENGTH] = {0};
|
||||
|
||||
ck_assert_msg(memcmp(empty, file_cmp_id, TOX_FILE_ID_LENGTH) != 0, "empty file_id");
|
||||
|
||||
@ -64,7 +78,7 @@ static void tox_file_receive(Tox *tox, uint32_t friend_number, uint32_t file_num
|
||||
|
||||
Tox_Err_File_Seek err_s;
|
||||
|
||||
ck_assert_msg(tox_file_seek(tox, friend_number, file_number, 1337, &err_s), "tox_file_seek error");
|
||||
ck_assert_msg(tox_file_seek(state_tox, friend_number, file_number, 1337, &err_s), "tox_file_seek error");
|
||||
|
||||
ck_assert_msg(err_s == TOX_ERR_FILE_SEEK_OK, "tox_file_seek wrong error");
|
||||
|
||||
@ -74,21 +88,24 @@ static void tox_file_receive(Tox *tox, uint32_t friend_number, uint32_t file_num
|
||||
|
||||
Tox_Err_File_Control error;
|
||||
|
||||
ck_assert_msg(tox_file_control(tox, friend_number, file_number, TOX_FILE_CONTROL_RESUME, &error),
|
||||
ck_assert_msg(tox_file_control(state_tox, friend_number, file_number, TOX_FILE_CONTROL_RESUME, &error),
|
||||
"tox_file_control failed. %i", error);
|
||||
++file_accepted;
|
||||
|
||||
Tox_Err_File_Seek err_s;
|
||||
|
||||
ck_assert_msg(!tox_file_seek(tox, friend_number, file_number, 1234, &err_s), "tox_file_seek no error");
|
||||
ck_assert_msg(!tox_file_seek(state_tox, friend_number, file_number, 1234, &err_s), "tox_file_seek no error");
|
||||
|
||||
ck_assert_msg(err_s == TOX_ERR_FILE_SEEK_DENIED, "tox_file_seek wrong error");
|
||||
}
|
||||
|
||||
static uint32_t sendf_ok;
|
||||
static void file_print_control(Tox *tox, uint32_t friend_number, uint32_t file_number, Tox_File_Control control,
|
||||
static void file_print_control(const Tox_Event_File_Recv_Control *event,
|
||||
void *userdata)
|
||||
{
|
||||
const uint32_t file_number = tox_event_file_recv_control_get_file_number(event);
|
||||
const Tox_File_Control control = tox_event_file_recv_control_get_control(event);
|
||||
|
||||
/* First send file num is 0.*/
|
||||
if (file_number == 0 && control == TOX_FILE_CONTROL_RESUME) {
|
||||
sendf_ok = 1;
|
||||
@ -99,12 +116,18 @@ static uint64_t max_sending;
|
||||
static bool m_send_reached;
|
||||
static uint8_t sending_num;
|
||||
static bool file_sending_done;
|
||||
static void tox_file_chunk_request(Tox *tox, uint32_t friend_number, uint32_t file_number, uint64_t position,
|
||||
size_t length, void *user_data)
|
||||
static void tox_file_chunk_request(const Tox_Event_File_Chunk_Request *event, void *user_data)
|
||||
{
|
||||
Tox *state_tox = (Tox *)user_data;
|
||||
|
||||
const uint32_t friend_number = tox_event_file_chunk_request_get_friend_number(event);
|
||||
const uint32_t file_number = tox_event_file_chunk_request_get_file_number(event);
|
||||
const uint64_t position = tox_event_file_chunk_request_get_position(event);
|
||||
size_t length = tox_event_file_chunk_request_get_length(event);
|
||||
|
||||
ck_assert_msg(sendf_ok, "didn't get resume control");
|
||||
|
||||
ck_assert_msg(sending_pos == position, "bad position %lu", (unsigned long)position);
|
||||
ck_assert_msg(sending_pos == position, "bad position %lu (should be %lu)", (unsigned long)position, (unsigned long)sending_pos);
|
||||
|
||||
if (length == 0) {
|
||||
ck_assert_msg(!file_sending_done, "file sending already done");
|
||||
@ -124,8 +147,7 @@ static void tox_file_chunk_request(Tox *tox, uint32_t friend_number, uint32_t fi
|
||||
memset(f_data, sending_num, length);
|
||||
|
||||
Tox_Err_File_Send_Chunk error;
|
||||
tox_file_send_chunk(tox, friend_number, file_number, position, f_data, length, &error);
|
||||
|
||||
tox_file_send_chunk(state_tox, friend_number, file_number, position, f_data, length, &error);
|
||||
|
||||
ck_assert_msg(error == TOX_ERR_FILE_SEND_CHUNK_OK,
|
||||
"could not send chunk, error num=%d pos=%d len=%d", (int)error, (int)position, (int)length);
|
||||
@ -134,12 +156,14 @@ static void tox_file_chunk_request(Tox *tox, uint32_t friend_number, uint32_t fi
|
||||
sending_pos += length;
|
||||
}
|
||||
|
||||
|
||||
static uint8_t num;
|
||||
static bool file_recv;
|
||||
static void write_file(Tox *tox, uint32_t friendnumber, uint32_t filenumber, uint64_t position, const uint8_t *data,
|
||||
size_t length, void *user_data)
|
||||
static void write_file(const Tox_Event_File_Recv_Chunk *event, void *user_data)
|
||||
{
|
||||
const uint64_t position = tox_event_file_recv_chunk_get_position(event);
|
||||
const uint8_t *data = tox_event_file_recv_chunk_get_data(event);
|
||||
const size_t length = tox_event_file_recv_chunk_get_data_length(event);
|
||||
|
||||
ck_assert_msg(size_recv == position, "bad position");
|
||||
|
||||
if (length == 0) {
|
||||
@ -156,6 +180,17 @@ static void write_file(Tox *tox, uint32_t friendnumber, uint32_t filenumber, uin
|
||||
size_recv += length;
|
||||
}
|
||||
|
||||
static void iterate_and_dispatch(const Tox_Dispatch *dispatch, Tox *tox)
|
||||
{
|
||||
Tox_Err_Events_Iterate err;
|
||||
Tox_Events *events;
|
||||
|
||||
events = tox_events_iterate(tox, true, &err);
|
||||
ck_assert(err == TOX_ERR_EVENTS_ITERATE_OK);
|
||||
tox_dispatch_invoke(dispatch, events, tox);
|
||||
tox_events_free(events);
|
||||
}
|
||||
|
||||
static void file_transfer_test(void)
|
||||
{
|
||||
printf("Starting test: few_clients\n");
|
||||
@ -171,7 +206,19 @@ static void file_transfer_test(void)
|
||||
|
||||
ck_assert_msg(tox1 && tox2 && tox3, "Failed to create 3 tox instances");
|
||||
|
||||
tox_callback_friend_request(tox2, accept_friend_request);
|
||||
tox_events_init(tox1);
|
||||
tox_events_init(tox2);
|
||||
tox_events_init(tox3);
|
||||
|
||||
Tox_Dispatch *dispatch1 = tox_dispatch_new(nullptr);
|
||||
ck_assert(dispatch1 != nullptr);
|
||||
Tox_Dispatch *dispatch2 = tox_dispatch_new(nullptr);
|
||||
ck_assert(dispatch2 != nullptr);
|
||||
Tox_Dispatch *dispatch3 = tox_dispatch_new(nullptr);
|
||||
ck_assert(dispatch3 != nullptr);
|
||||
|
||||
tox_events_callback_friend_request(dispatch2, accept_friend_request);
|
||||
|
||||
uint8_t address[TOX_ADDRESS_SIZE];
|
||||
tox_self_get_address(tox2, address);
|
||||
uint32_t test = tox_friend_add(tox3, address, (const uint8_t *)"Gentoo", 7, nullptr);
|
||||
@ -187,9 +234,9 @@ static void file_transfer_test(void)
|
||||
printf("Waiting for toxes to come online\n");
|
||||
|
||||
do {
|
||||
tox_iterate(tox1, nullptr);
|
||||
tox_iterate(tox2, nullptr);
|
||||
tox_iterate(tox3, nullptr);
|
||||
iterate_and_dispatch(dispatch1, tox1);
|
||||
iterate_and_dispatch(dispatch2, tox2);
|
||||
iterate_and_dispatch(dispatch3, tox3);
|
||||
|
||||
printf("Connections: self (%d, %d, %d), friends (%d, %d)\n",
|
||||
tox_self_get_connection_status(tox1),
|
||||
@ -210,11 +257,11 @@ static void file_transfer_test(void)
|
||||
file_recv = 0;
|
||||
max_sending = UINT64_MAX;
|
||||
uint64_t f_time = time(nullptr);
|
||||
tox_callback_file_recv_chunk(tox3, write_file);
|
||||
tox_callback_file_recv_control(tox2, file_print_control);
|
||||
tox_callback_file_chunk_request(tox2, tox_file_chunk_request);
|
||||
tox_callback_file_recv_control(tox3, file_print_control);
|
||||
tox_callback_file_recv(tox3, tox_file_receive);
|
||||
tox_events_callback_file_recv_chunk(dispatch3, write_file);
|
||||
tox_events_callback_file_recv_control(dispatch2, file_print_control);
|
||||
tox_events_callback_file_chunk_request(dispatch2, tox_file_chunk_request);
|
||||
tox_events_callback_file_recv_control(dispatch3, file_print_control);
|
||||
tox_events_callback_file_recv(dispatch3, tox_file_receive);
|
||||
uint64_t totalf_size = 100 * 1024 * 1024;
|
||||
uint32_t fnum = tox_file_send(tox2, 0, TOX_FILE_KIND_DATA, totalf_size, nullptr, (const uint8_t *)"Gentoo.exe",
|
||||
sizeof("Gentoo.exe"), nullptr);
|
||||
@ -231,9 +278,9 @@ static void file_transfer_test(void)
|
||||
const size_t max_iterations = INT16_MAX;
|
||||
|
||||
for (size_t i = 0; i < max_iterations; i++) {
|
||||
tox_iterate(tox1, nullptr);
|
||||
tox_iterate(tox2, nullptr);
|
||||
tox_iterate(tox3, nullptr);
|
||||
iterate_and_dispatch(dispatch1, tox1);
|
||||
iterate_and_dispatch(dispatch2, tox2);
|
||||
iterate_and_dispatch(dispatch3, tox3);
|
||||
|
||||
if (file_sending_done) {
|
||||
ck_assert_msg(sendf_ok && file_recv && totalf_size == file_size && size_recv == file_size && sending_pos == size_recv
|
||||
@ -274,11 +321,11 @@ static void file_transfer_test(void)
|
||||
sendf_ok = 0;
|
||||
size_recv = 0;
|
||||
file_recv = 0;
|
||||
tox_callback_file_recv_chunk(tox3, write_file);
|
||||
tox_callback_file_recv_control(tox2, file_print_control);
|
||||
tox_callback_file_chunk_request(tox2, tox_file_chunk_request);
|
||||
tox_callback_file_recv_control(tox3, file_print_control);
|
||||
tox_callback_file_recv(tox3, tox_file_receive);
|
||||
tox_events_callback_file_recv_chunk(dispatch3, write_file);
|
||||
tox_events_callback_file_recv_control(dispatch2, file_print_control);
|
||||
tox_events_callback_file_chunk_request(dispatch2, tox_file_chunk_request);
|
||||
tox_events_callback_file_recv_control(dispatch3, file_print_control);
|
||||
tox_events_callback_file_recv(dispatch3, tox_file_receive);
|
||||
totalf_size = 0;
|
||||
fnum = tox_file_send(tox2, 0, TOX_FILE_KIND_DATA, totalf_size, nullptr,
|
||||
(const uint8_t *)"Gentoo.exe", sizeof("Gentoo.exe"), nullptr);
|
||||
@ -298,9 +345,9 @@ static void file_transfer_test(void)
|
||||
|
||||
c_sleep(min_u32(tox1_interval, min_u32(tox2_interval, tox3_interval)));
|
||||
|
||||
tox_iterate(tox1, nullptr);
|
||||
tox_iterate(tox2, nullptr);
|
||||
tox_iterate(tox3, nullptr);
|
||||
iterate_and_dispatch(dispatch1, tox1);
|
||||
iterate_and_dispatch(dispatch2, tox2);
|
||||
iterate_and_dispatch(dispatch3, tox3);
|
||||
} while (!file_sending_done);
|
||||
|
||||
ck_assert_msg(sendf_ok && file_recv && totalf_size == file_size && size_recv == file_size
|
||||
@ -312,9 +359,12 @@ static void file_transfer_test(void)
|
||||
|
||||
printf("file_transfer_test succeeded, took %llu seconds\n", time(nullptr) - cur_time);
|
||||
|
||||
tox_kill(tox1);
|
||||
tox_kill(tox2);
|
||||
tox_dispatch_free(dispatch3);
|
||||
tox_dispatch_free(dispatch2);
|
||||
tox_dispatch_free(dispatch1);
|
||||
tox_kill(tox3);
|
||||
tox_kill(tox2);
|
||||
tox_kill(tox1);
|
||||
}
|
||||
|
||||
int main(void)
|
@ -47,8 +47,8 @@ static void test_forwarded_request_cb(void *object, const IP_Port *forwarder,
|
||||
const uint8_t *sendback, uint16_t sendback_length,
|
||||
const uint8_t *data, uint16_t length, void *userdata)
|
||||
{
|
||||
Test_Data *test_data = (Test_Data *)object;
|
||||
uint8_t *index = (uint8_t *)userdata;
|
||||
const Test_Data *test_data = (const Test_Data *)object;
|
||||
const uint8_t *index = (const uint8_t *)userdata;
|
||||
|
||||
if (length != 12 || memcmp("hello: ", data, 8) != 0) {
|
||||
printf("[%u] got unexpected data of length %d\n", *index, length);
|
||||
@ -66,7 +66,7 @@ static void test_forwarded_response_cb(void *object,
|
||||
const uint8_t *data, uint16_t length, void *userdata)
|
||||
{
|
||||
Test_Data *test_data = (Test_Data *)object;
|
||||
uint8_t *index = (uint8_t *)userdata;
|
||||
const uint8_t *index = (const uint8_t *)userdata;
|
||||
|
||||
if (length != 12 || memcmp("reply: ", data, 8) != 0) {
|
||||
printf("[%u] got unexpected data of length %d\n", *index, length);
|
||||
@ -104,9 +104,9 @@ typedef struct Forwarding_Subtox {
|
||||
|
||||
static Forwarding_Subtox *new_forwarding_subtox(const Memory *mem, bool no_udp, uint32_t *index, uint16_t port)
|
||||
{
|
||||
const Random *rng = system_random();
|
||||
const Random *rng = os_random();
|
||||
ck_assert(rng != nullptr);
|
||||
const Network *ns = system_network();
|
||||
const Network *ns = os_network();
|
||||
ck_assert(ns != nullptr);
|
||||
|
||||
Forwarding_Subtox *subtox = (Forwarding_Subtox *)calloc(1, sizeof(Forwarding_Subtox));
|
||||
@ -152,11 +152,11 @@ static void kill_forwarding_subtox(const Memory *mem, Forwarding_Subtox *subtox)
|
||||
|
||||
static void test_forwarding(void)
|
||||
{
|
||||
const Memory *mem = system_memory();
|
||||
const Memory *mem = os_memory();
|
||||
ck_assert(mem != nullptr);
|
||||
const Random *rng = system_random();
|
||||
const Random *rng = os_random();
|
||||
ck_assert(rng != nullptr);
|
||||
const Network *ns = system_network();
|
||||
const Network *ns = os_network();
|
||||
ck_assert(ns != nullptr);
|
||||
|
||||
uint32_t index[NUM_FORWARDER];
|
||||
@ -317,7 +317,6 @@ static void test_forwarding(void)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (uint32_t i = 0; i < NUM_FORWARDER; ++i) {
|
||||
kill_forwarding_subtox(mem, subtoxes[i]);
|
||||
}
|
||||
@ -325,7 +324,6 @@ static void test_forwarding(void)
|
||||
tox_kill(relay);
|
||||
}
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
setvbuf(stdout, nullptr, _IONBF, 0);
|
@ -22,12 +22,18 @@ typedef struct State {
|
||||
bool unused;
|
||||
} State;
|
||||
|
||||
static void accept_friend_request(Tox *tox, const uint8_t *public_key, const uint8_t *data, size_t length,
|
||||
static void accept_friend_request(const Tox_Event_Friend_Request *event,
|
||||
void *userdata)
|
||||
{
|
||||
AutoTox *autotox = (AutoTox *)userdata;
|
||||
|
||||
const uint8_t *public_key = tox_event_friend_request_get_public_key(event);
|
||||
const uint8_t *data = tox_event_friend_request_get_message(event);
|
||||
const size_t length = tox_event_friend_request_get_message_length(event);
|
||||
|
||||
ck_assert_msg(length == sizeof(FR_MESSAGE) && memcmp(FR_MESSAGE, data, sizeof(FR_MESSAGE)) == 0,
|
||||
"unexpected friend request message");
|
||||
tox_friend_add_norequest(tox, public_key, nullptr);
|
||||
tox_friend_add_norequest(autotox->tox, public_key, nullptr);
|
||||
}
|
||||
|
||||
static void test_friend_request(AutoTox *autotoxes)
|
||||
@ -35,7 +41,7 @@ static void test_friend_request(AutoTox *autotoxes)
|
||||
const time_t con_time = time(nullptr);
|
||||
|
||||
printf("All toxes add tox1 as friend.\n");
|
||||
tox_callback_friend_request(autotoxes[0].tox, accept_friend_request);
|
||||
tox_events_callback_friend_request(autotoxes[0].dispatch, accept_friend_request);
|
||||
|
||||
uint8_t address[TOX_ADDRESS_SIZE];
|
||||
tox_self_get_address(autotoxes[0].tox, address);
|
@ -15,12 +15,36 @@
|
||||
|
||||
#define FR_MESSAGE "Gentoo"
|
||||
|
||||
static void accept_friend_request(Tox *tox, const uint8_t *public_key, const uint8_t *data, size_t length,
|
||||
static void accept_friend_request(const Tox_Event_Friend_Request *event,
|
||||
void *userdata)
|
||||
{
|
||||
Tox *state_tox = (Tox *)userdata;
|
||||
|
||||
const uint8_t *public_key = tox_event_friend_request_get_public_key(event);
|
||||
const uint8_t *data = tox_event_friend_request_get_message(event);
|
||||
const size_t length = tox_event_friend_request_get_message_length(event);
|
||||
|
||||
ck_assert_msg(length == sizeof(FR_MESSAGE) && memcmp(FR_MESSAGE, data, sizeof(FR_MESSAGE)) == 0,
|
||||
"unexpected friend request message");
|
||||
tox_friend_add_norequest(tox, public_key, nullptr);
|
||||
tox_friend_add_norequest(state_tox, public_key, nullptr);
|
||||
}
|
||||
|
||||
static void iterate2_wait(const Tox_Dispatch *dispatch, Tox *tox1, Tox *tox2)
|
||||
{
|
||||
Tox_Err_Events_Iterate err;
|
||||
Tox_Events *events;
|
||||
|
||||
events = tox_events_iterate(tox1, true, &err);
|
||||
ck_assert(err == TOX_ERR_EVENTS_ITERATE_OK);
|
||||
tox_dispatch_invoke(dispatch, events, tox1);
|
||||
tox_events_free(events);
|
||||
|
||||
events = tox_events_iterate(tox2, true, &err);
|
||||
ck_assert(err == TOX_ERR_EVENTS_ITERATE_OK);
|
||||
tox_dispatch_invoke(dispatch, events, tox2);
|
||||
tox_events_free(events);
|
||||
|
||||
c_sleep(ITERATION_INTERVAL);
|
||||
}
|
||||
|
||||
static void test_friend_request(void)
|
||||
@ -33,6 +57,9 @@ static void test_friend_request(void)
|
||||
|
||||
ck_assert_msg(tox1 && tox2, "failed to create 2 tox instances");
|
||||
|
||||
tox_events_init(tox1);
|
||||
tox_events_init(tox2);
|
||||
|
||||
printf("Bootstrapping tox2 off tox1.\n");
|
||||
uint8_t dht_key[TOX_PUBLIC_KEY_SIZE];
|
||||
tox_self_get_dht_id(tox1, dht_key);
|
||||
@ -40,11 +67,11 @@ static void test_friend_request(void)
|
||||
|
||||
tox_bootstrap(tox2, "localhost", dht_port, dht_key, nullptr);
|
||||
|
||||
do {
|
||||
tox_iterate(tox1, nullptr);
|
||||
tox_iterate(tox2, nullptr);
|
||||
Tox_Dispatch *dispatch = tox_dispatch_new(nullptr);
|
||||
ck_assert(dispatch != nullptr);
|
||||
|
||||
c_sleep(ITERATION_INTERVAL);
|
||||
do {
|
||||
iterate2_wait(dispatch, tox1, tox2);
|
||||
} while (tox_self_get_connection_status(tox1) == TOX_CONNECTION_NONE ||
|
||||
tox_self_get_connection_status(tox2) == TOX_CONNECTION_NONE);
|
||||
|
||||
@ -52,7 +79,7 @@ static void test_friend_request(void)
|
||||
const time_t con_time = time(nullptr);
|
||||
|
||||
printf("Tox1 adds tox2 as friend, tox2 accepts.\n");
|
||||
tox_callback_friend_request(tox2, accept_friend_request);
|
||||
tox_events_callback_friend_request(dispatch, accept_friend_request);
|
||||
|
||||
uint8_t address[TOX_ADDRESS_SIZE];
|
||||
tox_self_get_address(tox2, address);
|
||||
@ -61,16 +88,14 @@ static void test_friend_request(void)
|
||||
ck_assert_msg(test == 0, "failed to add friend error code: %u", test);
|
||||
|
||||
do {
|
||||
tox_iterate(tox1, nullptr);
|
||||
tox_iterate(tox2, nullptr);
|
||||
|
||||
c_sleep(ITERATION_INTERVAL);
|
||||
iterate2_wait(dispatch, tox1, tox2);
|
||||
} while (tox_friend_get_connection_status(tox1, 0, nullptr) != TOX_CONNECTION_UDP ||
|
||||
tox_friend_get_connection_status(tox2, 0, nullptr) != TOX_CONNECTION_UDP);
|
||||
|
||||
printf("Tox clients connected took %lu seconds.\n", (unsigned long)(time(nullptr) - con_time));
|
||||
printf("friend_request_test succeeded, took %lu seconds.\n", (unsigned long)(time(nullptr) - cur_time));
|
||||
|
||||
tox_dispatch_free(dispatch);
|
||||
tox_kill(tox1);
|
||||
tox_kill(tox2);
|
||||
}
|
@ -43,7 +43,7 @@ typedef struct State {
|
||||
|
||||
#define PEER_LIMIT 20
|
||||
|
||||
static void print_ip(Tox *tox, uint32_t groupnumber, uint32_t peer_id)
|
||||
static void print_ip(const Tox *tox, uint32_t groupnumber, uint32_t peer_id)
|
||||
{
|
||||
Tox_Err_Group_Peer_Query err;
|
||||
size_t length = tox_group_peer_get_ip_address_size(tox, groupnumber, peer_id, &err);
|
||||
@ -81,32 +81,35 @@ static bool all_group_peers_connected(AutoTox *autotoxes, uint32_t tox_count, ui
|
||||
return true;
|
||||
}
|
||||
|
||||
static void group_peer_join_handler(Tox *tox, uint32_t groupnumber, uint32_t peer_id, void *user_data)
|
||||
static void group_peer_join_handler(const Tox_Event_Group_Peer_Join *event, void *user_data)
|
||||
{
|
||||
AutoTox *autotox = (AutoTox *)user_data;
|
||||
ck_assert(autotox != nullptr);
|
||||
|
||||
State *state = (State *)autotox->state;
|
||||
|
||||
const uint32_t groupnumber = tox_event_group_peer_join_get_group_number(event);
|
||||
const uint32_t peer_id = tox_event_group_peer_join_get_peer_id(event);
|
||||
|
||||
// we do a connection test here for fun
|
||||
Tox_Err_Group_Peer_Query pq_err;
|
||||
TOX_CONNECTION connection_status = tox_group_peer_get_connection_status(tox, groupnumber, peer_id, &pq_err);
|
||||
Tox_Connection connection_status = tox_group_peer_get_connection_status(autotox->tox, groupnumber, peer_id, &pq_err);
|
||||
ck_assert(pq_err == TOX_ERR_GROUP_PEER_QUERY_OK);
|
||||
ck_assert(connection_status != TOX_CONNECTION_NONE);
|
||||
|
||||
Tox_Group_Role role = tox_group_peer_get_role(tox, groupnumber, peer_id, &pq_err);
|
||||
Tox_Group_Role role = tox_group_peer_get_role(autotox->tox, groupnumber, peer_id, &pq_err);
|
||||
ck_assert_msg(pq_err == TOX_ERR_GROUP_PEER_QUERY_OK, "%d", pq_err);
|
||||
|
||||
Tox_User_Status status = tox_group_peer_get_status(tox, groupnumber, peer_id, &pq_err);
|
||||
Tox_User_Status status = tox_group_peer_get_status(autotox->tox, groupnumber, peer_id, &pq_err);
|
||||
ck_assert_msg(pq_err == TOX_ERR_GROUP_PEER_QUERY_OK, "%d", pq_err);
|
||||
|
||||
size_t peer_name_len = tox_group_peer_get_name_size(tox, groupnumber, peer_id, &pq_err);
|
||||
size_t peer_name_len = tox_group_peer_get_name_size(autotox->tox, groupnumber, peer_id, &pq_err);
|
||||
char peer_name[TOX_MAX_NAME_LENGTH + 1];
|
||||
|
||||
ck_assert(pq_err == TOX_ERR_GROUP_PEER_QUERY_OK);
|
||||
ck_assert(peer_name_len <= TOX_MAX_NAME_LENGTH);
|
||||
|
||||
tox_group_peer_get_name(tox, groupnumber, peer_id, (uint8_t *) peer_name, &pq_err);
|
||||
tox_group_peer_get_name(autotox->tox, groupnumber, peer_id, (uint8_t *)peer_name, &pq_err);
|
||||
ck_assert(pq_err == TOX_ERR_GROUP_PEER_QUERY_OK);
|
||||
|
||||
peer_name[peer_name_len] = 0;
|
||||
@ -137,35 +140,37 @@ static void group_peer_join_handler(Tox *tox, uint32_t groupnumber, uint32_t pee
|
||||
}
|
||||
|
||||
fprintf(stderr, "%s joined with IP: ", peer_name);
|
||||
print_ip(tox, groupnumber, peer_id);
|
||||
print_ip(autotox->tox, groupnumber, peer_id);
|
||||
|
||||
state->peer_id = peer_id;
|
||||
++state->peer_joined_count;
|
||||
}
|
||||
|
||||
static void group_peer_self_join_handler(Tox *tox, uint32_t groupnumber, void *user_data)
|
||||
static void group_peer_self_join_handler(const Tox_Event_Group_Self_Join *event, void *user_data)
|
||||
{
|
||||
AutoTox *autotox = (AutoTox *)user_data;
|
||||
ck_assert(autotox != nullptr);
|
||||
|
||||
State *state = (State *)autotox->state;
|
||||
|
||||
const uint32_t groupnumber = tox_event_group_self_join_get_group_number(event);
|
||||
|
||||
// make sure we see our own correct peer state on join callback
|
||||
|
||||
Tox_Err_Group_Self_Query sq_err;
|
||||
size_t self_length = tox_group_self_get_name_size(tox, groupnumber, &sq_err);
|
||||
size_t self_length = tox_group_self_get_name_size(autotox->tox, groupnumber, &sq_err);
|
||||
|
||||
ck_assert(sq_err == TOX_ERR_GROUP_SELF_QUERY_OK);
|
||||
|
||||
uint8_t self_name[TOX_MAX_NAME_LENGTH];
|
||||
tox_group_self_get_name(tox, groupnumber, self_name, &sq_err);
|
||||
tox_group_self_get_name(autotox->tox, groupnumber, self_name, &sq_err);
|
||||
|
||||
ck_assert(sq_err == TOX_ERR_GROUP_SELF_QUERY_OK);
|
||||
|
||||
TOX_USER_STATUS self_status = tox_group_self_get_status(tox, groupnumber, &sq_err);
|
||||
Tox_User_Status self_status = tox_group_self_get_status(autotox->tox, groupnumber, &sq_err);
|
||||
ck_assert(sq_err == TOX_ERR_GROUP_SELF_QUERY_OK);
|
||||
|
||||
Tox_Group_Role self_role = tox_group_self_get_role(tox, groupnumber, &sq_err);
|
||||
Tox_Group_Role self_role = tox_group_self_get_role(autotox->tox, groupnumber, &sq_err);
|
||||
ck_assert(sq_err == TOX_ERR_GROUP_SELF_QUERY_OK);
|
||||
|
||||
if (state->is_founder) {
|
||||
@ -185,36 +190,37 @@ static void group_peer_self_join_handler(Tox *tox, uint32_t groupnumber, void *u
|
||||
uint8_t group_name[GROUP_NAME_LEN];
|
||||
uint8_t topic[TOX_GROUP_MAX_TOPIC_LENGTH];
|
||||
|
||||
ck_assert(tox_group_get_peer_limit(tox, groupnumber, nullptr) == PEER_LIMIT);
|
||||
ck_assert(tox_group_get_name_size(tox, groupnumber, nullptr) == GROUP_NAME_LEN);
|
||||
ck_assert(tox_group_get_topic_size(tox, groupnumber, nullptr) == TOPIC_LEN);
|
||||
ck_assert(tox_group_get_peer_limit(autotox->tox, groupnumber, nullptr) == PEER_LIMIT);
|
||||
ck_assert(tox_group_get_name_size(autotox->tox, groupnumber, nullptr) == GROUP_NAME_LEN);
|
||||
ck_assert(tox_group_get_topic_size(autotox->tox, groupnumber, nullptr) == TOPIC_LEN);
|
||||
|
||||
Tox_Err_Group_State_Queries query_err;
|
||||
tox_group_get_name(tox, groupnumber, group_name, &query_err);
|
||||
ck_assert_msg(query_err == TOX_ERR_GROUP_STATE_QUERIES_OK, "%d", query_err);
|
||||
Tox_Err_Group_State_Query query_err;
|
||||
tox_group_get_name(autotox->tox, groupnumber, group_name, &query_err);
|
||||
ck_assert_msg(query_err == TOX_ERR_GROUP_STATE_QUERY_OK, "%d", query_err);
|
||||
ck_assert(memcmp(group_name, GROUP_NAME, GROUP_NAME_LEN) == 0);
|
||||
|
||||
tox_group_get_topic(tox, groupnumber, topic, &query_err);
|
||||
ck_assert_msg(query_err == TOX_ERR_GROUP_STATE_QUERIES_OK, "%d", query_err);
|
||||
tox_group_get_topic(autotox->tox, groupnumber, topic, &query_err);
|
||||
ck_assert_msg(query_err == TOX_ERR_GROUP_STATE_QUERY_OK, "%d", query_err);
|
||||
ck_assert(memcmp(topic, TOPIC, TOPIC_LEN) == 0);
|
||||
|
||||
uint32_t peer_id = tox_group_self_get_peer_id(tox, groupnumber, nullptr);
|
||||
uint32_t peer_id = tox_group_self_get_peer_id(autotox->tox, groupnumber, nullptr);
|
||||
|
||||
fprintf(stderr, "self joined with IP: ");
|
||||
print_ip(tox, groupnumber, peer_id);
|
||||
print_ip(autotox->tox, groupnumber, peer_id);
|
||||
|
||||
++state->self_joined_count;
|
||||
}
|
||||
|
||||
static void group_peer_exit_handler(Tox *tox, uint32_t groupnumber, uint32_t peer_id, Tox_Group_Exit_Type exit_type,
|
||||
const uint8_t *name, size_t name_length, const uint8_t *part_message,
|
||||
size_t length, void *user_data)
|
||||
static void group_peer_exit_handler(const Tox_Event_Group_Peer_Exit *event, void *user_data)
|
||||
{
|
||||
AutoTox *autotox = (AutoTox *)user_data;
|
||||
ck_assert(autotox != nullptr);
|
||||
|
||||
State *state = (State *)autotox->state;
|
||||
|
||||
const uint8_t *part_message = tox_event_group_peer_exit_get_part_message(event);
|
||||
const size_t length = tox_event_group_peer_exit_get_part_message_length(event);
|
||||
|
||||
++state->peer_exit_count;
|
||||
|
||||
// first exit is a disconnect. second is a real exit with a part message
|
||||
@ -224,14 +230,16 @@ static void group_peer_exit_handler(Tox *tox, uint32_t groupnumber, uint32_t pee
|
||||
}
|
||||
}
|
||||
|
||||
static void group_peer_name_handler(Tox *tox, uint32_t groupnumber, uint32_t peer_id, const uint8_t *name,
|
||||
size_t length, void *user_data)
|
||||
static void group_peer_name_handler(const Tox_Event_Group_Peer_Name *event, void *user_data)
|
||||
{
|
||||
AutoTox *autotox = (AutoTox *)user_data;
|
||||
ck_assert(autotox != nullptr);
|
||||
|
||||
State *state = (State *)autotox->state;
|
||||
|
||||
const uint8_t *name = tox_event_group_peer_name_get_name(event);
|
||||
const size_t length = tox_event_group_peer_name_get_name_length(event);
|
||||
|
||||
// note: we already test the name_get api call elsewhere
|
||||
|
||||
ck_assert(length == PEER0_NICK2_LEN);
|
||||
@ -240,7 +248,7 @@ static void group_peer_name_handler(Tox *tox, uint32_t groupnumber, uint32_t pee
|
||||
state->peer_nick = true;
|
||||
}
|
||||
|
||||
static void group_peer_status_handler(Tox *tox, uint32_t groupnumber, uint32_t peer_id, TOX_USER_STATUS status,
|
||||
static void group_peer_status_handler(const Tox_Event_Group_Peer_Status *event,
|
||||
void *user_data)
|
||||
{
|
||||
AutoTox *autotox = (AutoTox *)user_data;
|
||||
@ -248,8 +256,12 @@ static void group_peer_status_handler(Tox *tox, uint32_t groupnumber, uint32_t p
|
||||
|
||||
State *state = (State *)autotox->state;
|
||||
|
||||
const uint32_t groupnumber = tox_event_group_peer_status_get_group_number(event);
|
||||
const uint32_t peer_id = tox_event_group_peer_status_get_peer_id(event);
|
||||
const Tox_User_Status status = tox_event_group_peer_status_get_status(event);
|
||||
|
||||
Tox_Err_Group_Peer_Query err;
|
||||
TOX_USER_STATUS cur_status = tox_group_peer_get_status(tox, groupnumber, peer_id, &err);
|
||||
Tox_User_Status cur_status = tox_group_peer_get_status(autotox->tox, groupnumber, peer_id, &err);
|
||||
|
||||
ck_assert_msg(cur_status == status, "%d, %d", cur_status, status);
|
||||
ck_assert(status == TOX_USER_STATUS_BUSY);
|
||||
@ -264,15 +276,15 @@ static void group_announce_test(AutoTox *autotoxes)
|
||||
Tox *tox0 = autotoxes[0].tox;
|
||||
Tox *tox1 = autotoxes[1].tox;
|
||||
State *state0 = (State *)autotoxes[0].state;
|
||||
State *state1 = (State *)autotoxes[1].state;
|
||||
const State *state1 = (const State *)autotoxes[1].state;
|
||||
|
||||
tox_callback_group_peer_join(tox0, group_peer_join_handler);
|
||||
tox_callback_group_peer_join(tox1, group_peer_join_handler);
|
||||
tox_callback_group_self_join(tox0, group_peer_self_join_handler);
|
||||
tox_callback_group_self_join(tox1, group_peer_self_join_handler);
|
||||
tox_callback_group_peer_name(tox1, group_peer_name_handler);
|
||||
tox_callback_group_peer_status(tox1, group_peer_status_handler);
|
||||
tox_callback_group_peer_exit(tox1, group_peer_exit_handler);
|
||||
tox_events_callback_group_peer_join(autotoxes[0].dispatch, group_peer_join_handler);
|
||||
tox_events_callback_group_peer_join(autotoxes[1].dispatch, group_peer_join_handler);
|
||||
tox_events_callback_group_self_join(autotoxes[0].dispatch, group_peer_self_join_handler);
|
||||
tox_events_callback_group_self_join(autotoxes[1].dispatch, group_peer_self_join_handler);
|
||||
tox_events_callback_group_peer_name(autotoxes[1].dispatch, group_peer_name_handler);
|
||||
tox_events_callback_group_peer_status(autotoxes[1].dispatch, group_peer_status_handler);
|
||||
tox_events_callback_group_peer_exit(autotoxes[1].dispatch, group_peer_exit_handler);
|
||||
|
||||
// tox0 makes new group.
|
||||
Tox_Err_Group_New err_new;
|
||||
@ -286,19 +298,19 @@ static void group_announce_test(AutoTox *autotoxes)
|
||||
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL);
|
||||
|
||||
// changes the state (for sync check purposes)
|
||||
Tox_Err_Group_Founder_Set_Peer_Limit limit_set_err;
|
||||
tox_group_founder_set_peer_limit(tox0, groupnumber, PEER_LIMIT, &limit_set_err);
|
||||
ck_assert_msg(limit_set_err == TOX_ERR_GROUP_FOUNDER_SET_PEER_LIMIT_OK, "failed to set peer limit: %d", limit_set_err);
|
||||
Tox_Err_Group_Set_Peer_Limit limit_set_err;
|
||||
tox_group_set_peer_limit(tox0, groupnumber, PEER_LIMIT, &limit_set_err);
|
||||
ck_assert_msg(limit_set_err == TOX_ERR_GROUP_SET_PEER_LIMIT_OK, "failed to set peer limit: %d", limit_set_err);
|
||||
|
||||
Tox_Err_Group_Topic_Set tp_err;
|
||||
tox_group_set_topic(tox0, groupnumber, (const uint8_t *)TOPIC, TOPIC_LEN, &tp_err);
|
||||
ck_assert(tp_err == TOX_ERR_GROUP_TOPIC_SET_OK);
|
||||
|
||||
// get the chat id of the new group.
|
||||
Tox_Err_Group_State_Queries err_id;
|
||||
Tox_Err_Group_State_Query err_id;
|
||||
uint8_t chat_id[TOX_GROUP_CHAT_ID_SIZE];
|
||||
tox_group_get_chat_id(tox0, groupnumber, chat_id, &err_id);
|
||||
ck_assert(err_id == TOX_ERR_GROUP_STATE_QUERIES_OK);
|
||||
ck_assert(err_id == TOX_ERR_GROUP_STATE_QUERY_OK);
|
||||
|
||||
// tox1 joins it.
|
||||
Tox_Err_Group_Join err_join;
|
||||
@ -343,7 +355,7 @@ static void group_announce_test(AutoTox *autotoxes)
|
||||
|
||||
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL);
|
||||
|
||||
TOX_USER_STATUS self_status = tox_group_self_get_status(tox0, groupnumber, &sq_err);
|
||||
Tox_User_Status self_status = tox_group_self_get_status(tox0, groupnumber, &sq_err);
|
||||
ck_assert(sq_err == TOX_ERR_GROUP_SELF_QUERY_OK);
|
||||
ck_assert(self_status == TOX_USER_STATUS_BUSY);
|
||||
|
||||
@ -429,10 +441,12 @@ static void group_announce_test(AutoTox *autotoxes)
|
||||
tox_group_leave(tox1, groupnumber, nullptr, 0, &err_exit);
|
||||
ck_assert(err_exit == TOX_ERR_GROUP_LEAVE_OK);
|
||||
|
||||
num_groups1 = tox_group_get_number_groups(tox0);
|
||||
num_groups2 = tox_group_get_number_groups(tox1);
|
||||
while (num_groups1 != 0 || num_groups2 != 0) {
|
||||
num_groups1 = tox_group_get_number_groups(tox0);
|
||||
num_groups2 = tox_group_get_number_groups(tox1);
|
||||
|
||||
ck_assert(num_groups1 == num_groups2 && num_groups2 == 0);
|
||||
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL);
|
||||
}
|
||||
|
||||
printf("All tests passed!\n");
|
||||
}
|
@ -51,13 +51,15 @@ static bool group_has_full_graph(const AutoTox *autotoxes, uint32_t group_number
|
||||
return true;
|
||||
}
|
||||
|
||||
static void group_join_fail_handler(Tox *tox, uint32_t group_number, Tox_Group_Join_Fail fail_type, void *user_data)
|
||||
static void group_join_fail_handler(const Tox_Event_Group_Join_Fail *event, void *user_data)
|
||||
{
|
||||
AutoTox *autotox = (AutoTox *)user_data;
|
||||
ck_assert(autotox != nullptr);
|
||||
|
||||
State *state = (State *)autotox->state;
|
||||
|
||||
const Tox_Group_Join_Fail fail_type = tox_event_group_join_fail_get_fail_type(event);
|
||||
|
||||
switch (fail_type) {
|
||||
case TOX_GROUP_JOIN_FAIL_PEER_LIMIT: {
|
||||
state->peer_limit_fail = true;
|
||||
@ -79,7 +81,7 @@ static void group_join_fail_handler(Tox *tox, uint32_t group_number, Tox_Group_J
|
||||
}
|
||||
}
|
||||
|
||||
static void group_self_join_handler(Tox *tox, uint32_t group_number, void *user_data)
|
||||
static void group_self_join_handler(const Tox_Event_Group_Self_Join *event, void *user_data)
|
||||
{
|
||||
AutoTox *autotox = (AutoTox *)user_data;
|
||||
ck_assert(autotox != nullptr);
|
||||
@ -89,7 +91,7 @@ static void group_self_join_handler(Tox *tox, uint32_t group_number, void *user_
|
||||
state->connected = true;
|
||||
}
|
||||
|
||||
static void group_peer_join_handler(Tox *tox, uint32_t group_number, uint32_t peer_id, void *user_data)
|
||||
static void group_peer_join_handler(const Tox_Event_Group_Peer_Join *event, void *user_data)
|
||||
{
|
||||
AutoTox *autotox = (AutoTox *)user_data;
|
||||
ck_assert(autotox != nullptr);
|
||||
@ -105,9 +107,9 @@ static void group_invite_test(AutoTox *autotoxes)
|
||||
ck_assert_msg(NUM_GROUP_TOXES > 7, "NUM_GROUP_TOXES is too small: %d", NUM_GROUP_TOXES);
|
||||
|
||||
for (size_t i = 0; i < NUM_GROUP_TOXES; ++i) {
|
||||
tox_callback_group_peer_join(autotoxes[i].tox, group_peer_join_handler);
|
||||
tox_callback_group_join_fail(autotoxes[i].tox, group_join_fail_handler);
|
||||
tox_callback_group_self_join(autotoxes[i].tox, group_self_join_handler);
|
||||
tox_events_callback_group_peer_join(autotoxes[i].dispatch, group_peer_join_handler);
|
||||
tox_events_callback_group_join_fail(autotoxes[i].dispatch, group_join_fail_handler);
|
||||
tox_events_callback_group_self_join(autotoxes[i].dispatch, group_self_join_handler);
|
||||
}
|
||||
|
||||
Tox *tox0 = autotoxes[0].tox;
|
||||
@ -118,12 +120,12 @@ static void group_invite_test(AutoTox *autotoxes)
|
||||
Tox *tox5 = autotoxes[5].tox;
|
||||
Tox *tox6 = autotoxes[6].tox;
|
||||
|
||||
State *state0 = (State *)autotoxes[0].state;
|
||||
State *state2 = (State *)autotoxes[2].state;
|
||||
State *state3 = (State *)autotoxes[3].state;
|
||||
State *state4 = (State *)autotoxes[4].state;
|
||||
State *state5 = (State *)autotoxes[5].state;
|
||||
State *state6 = (State *)autotoxes[6].state;
|
||||
const State *state0 = (const State *)autotoxes[0].state;
|
||||
const State *state2 = (const State *)autotoxes[2].state;
|
||||
const State *state3 = (const State *)autotoxes[3].state;
|
||||
const State *state4 = (const State *)autotoxes[4].state;
|
||||
const State *state5 = (const State *)autotoxes[5].state;
|
||||
const State *state6 = (const State *)autotoxes[6].state;
|
||||
|
||||
Tox_Err_Group_New new_err;
|
||||
uint32_t groupnumber = tox_group_new(tox0, TOX_GROUP_PRIVACY_STATE_PUBLIC, (const uint8_t *)"test", 4,
|
||||
@ -132,11 +134,11 @@ static void group_invite_test(AutoTox *autotoxes)
|
||||
|
||||
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL);
|
||||
|
||||
Tox_Err_Group_State_Queries id_err;
|
||||
Tox_Err_Group_State_Query id_err;
|
||||
uint8_t chat_id[TOX_GROUP_CHAT_ID_SIZE];
|
||||
|
||||
tox_group_get_chat_id(tox0, groupnumber, chat_id, &id_err);
|
||||
ck_assert_msg(id_err == TOX_ERR_GROUP_STATE_QUERIES_OK, "%d", id_err);
|
||||
ck_assert_msg(id_err == TOX_ERR_GROUP_STATE_QUERY_OK, "%d", id_err);
|
||||
|
||||
// peer 1 joins public group with no password
|
||||
Tox_Err_Group_Join join_err;
|
||||
@ -150,9 +152,9 @@ static void group_invite_test(AutoTox *autotoxes)
|
||||
printf("Peer 1 joined group\n");
|
||||
|
||||
// founder sets a password
|
||||
Tox_Err_Group_Founder_Set_Password pass_set_err;
|
||||
tox_group_founder_set_password(tox0, groupnumber, (const uint8_t *)PASSWORD, PASS_LEN, &pass_set_err);
|
||||
ck_assert_msg(pass_set_err == TOX_ERR_GROUP_FOUNDER_SET_PASSWORD_OK, "%d", pass_set_err);
|
||||
Tox_Err_Group_Set_Password pass_set_err;
|
||||
tox_group_set_password(tox0, groupnumber, (const uint8_t *)PASSWORD, PASS_LEN, &pass_set_err);
|
||||
ck_assert_msg(pass_set_err == TOX_ERR_GROUP_SET_PASSWORD_OK, "%d", pass_set_err);
|
||||
|
||||
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, 5000);
|
||||
|
||||
@ -177,9 +179,9 @@ static void group_invite_test(AutoTox *autotoxes)
|
||||
printf("Peer 3 successfully blocked with invalid password\n");
|
||||
|
||||
// founder sets peer limit to 1
|
||||
Tox_Err_Group_Founder_Set_Peer_Limit limit_set_err;
|
||||
tox_group_founder_set_peer_limit(tox0, groupnumber, 1, &limit_set_err);
|
||||
ck_assert_msg(limit_set_err == TOX_ERR_GROUP_FOUNDER_SET_PEER_LIMIT_OK, "%d", limit_set_err);
|
||||
Tox_Err_Group_Set_Peer_Limit limit_set_err;
|
||||
tox_group_set_peer_limit(tox0, groupnumber, 1, &limit_set_err);
|
||||
ck_assert_msg(limit_set_err == TOX_ERR_GROUP_SET_PEER_LIMIT_OK, "%d", limit_set_err);
|
||||
|
||||
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, 5000);
|
||||
|
||||
@ -194,11 +196,11 @@ static void group_invite_test(AutoTox *autotoxes)
|
||||
printf("Peer 4 successfully blocked from joining full group\n");
|
||||
|
||||
// founder removes password and increases peer limit to 100
|
||||
tox_group_founder_set_password(tox0, groupnumber, nullptr, 0, &pass_set_err);
|
||||
ck_assert_msg(pass_set_err == TOX_ERR_GROUP_FOUNDER_SET_PASSWORD_OK, "%d", pass_set_err);
|
||||
tox_group_set_password(tox0, groupnumber, nullptr, 0, &pass_set_err);
|
||||
ck_assert_msg(pass_set_err == TOX_ERR_GROUP_SET_PASSWORD_OK, "%d", pass_set_err);
|
||||
|
||||
tox_group_founder_set_peer_limit(tox0, groupnumber, 100, &limit_set_err);
|
||||
ck_assert_msg(limit_set_err == TOX_ERR_GROUP_FOUNDER_SET_PEER_LIMIT_OK, "%d", limit_set_err);
|
||||
tox_group_set_peer_limit(tox0, groupnumber, 100, &limit_set_err);
|
||||
ck_assert_msg(limit_set_err == TOX_ERR_GROUP_SET_PEER_LIMIT_OK, "%d", limit_set_err);
|
||||
|
||||
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, 5000);
|
||||
|
||||
@ -213,9 +215,9 @@ static void group_invite_test(AutoTox *autotoxes)
|
||||
printf("Peer 5 successfully joined the group\n");
|
||||
|
||||
// founder makes group private
|
||||
Tox_Err_Group_Founder_Set_Privacy_State priv_err;
|
||||
tox_group_founder_set_privacy_state(tox0, groupnumber, TOX_GROUP_PRIVACY_STATE_PRIVATE, &priv_err);
|
||||
ck_assert_msg(priv_err == TOX_ERR_GROUP_FOUNDER_SET_PRIVACY_STATE_OK, "%d", priv_err);
|
||||
Tox_Err_Group_Set_Privacy_State priv_err;
|
||||
tox_group_set_privacy_state(tox0, groupnumber, TOX_GROUP_PRIVACY_STATE_PRIVATE, &priv_err);
|
||||
ck_assert_msg(priv_err == TOX_ERR_GROUP_SET_PRIVACY_STATE_OK, "%d", priv_err);
|
||||
|
||||
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, 5000);
|
||||
|
||||
@ -231,8 +233,8 @@ static void group_invite_test(AutoTox *autotoxes)
|
||||
printf("Peer 6 failed to join private group via chat ID\n");
|
||||
|
||||
// founder makes group public again
|
||||
tox_group_founder_set_privacy_state(tox0, groupnumber, TOX_GROUP_PRIVACY_STATE_PUBLIC, &priv_err);
|
||||
ck_assert_msg(priv_err == TOX_ERR_GROUP_FOUNDER_SET_PRIVACY_STATE_OK, "%d", priv_err);
|
||||
tox_group_set_privacy_state(tox0, groupnumber, TOX_GROUP_PRIVACY_STATE_PUBLIC, &priv_err);
|
||||
ck_assert_msg(priv_err == TOX_ERR_GROUP_SET_PRIVACY_STATE_OK, "%d", priv_err);
|
||||
|
||||
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL);
|
||||
|
@ -19,7 +19,7 @@ typedef struct State {
|
||||
bool peer_joined;
|
||||
bool message_sent;
|
||||
bool message_received;
|
||||
uint32_t pseudo_msg_id;
|
||||
Tox_Group_Message_Id pseudo_msg_id;
|
||||
bool private_message_received;
|
||||
size_t custom_packets_received;
|
||||
size_t custom_private_packets_received;
|
||||
@ -71,28 +71,37 @@ static uint16_t get_message_checksum(const uint8_t *message, uint16_t length)
|
||||
return sum;
|
||||
}
|
||||
|
||||
static void group_invite_handler(Tox *tox, uint32_t friend_number, const uint8_t *invite_data, size_t length,
|
||||
const uint8_t *group_name, size_t group_name_length, void *user_data)
|
||||
static void group_invite_handler(const Tox_Event_Group_Invite *event, void *user_data)
|
||||
{
|
||||
AutoTox *autotox = (AutoTox *)user_data;
|
||||
ck_assert(autotox != nullptr);
|
||||
|
||||
const uint32_t friend_number = tox_event_group_invite_get_friend_number(event);
|
||||
const uint8_t *invite_data = tox_event_group_invite_get_invite_data(event);
|
||||
const size_t length = tox_event_group_invite_get_invite_data_length(event);
|
||||
|
||||
printf("invite arrived; accepting\n");
|
||||
Tox_Err_Group_Invite_Accept err_accept;
|
||||
tox_group_invite_accept(tox, friend_number, invite_data, length, (const uint8_t *)PEER0_NICK, PEER0_NICK_LEN,
|
||||
tox_group_invite_accept(autotox->tox, friend_number, invite_data, length, (const uint8_t *)PEER0_NICK, PEER0_NICK_LEN,
|
||||
nullptr, 0, &err_accept);
|
||||
ck_assert(err_accept == TOX_ERR_GROUP_INVITE_ACCEPT_OK);
|
||||
}
|
||||
|
||||
static void group_join_fail_handler(Tox *tox, uint32_t groupnumber, Tox_Group_Join_Fail fail_type, void *user_data)
|
||||
static void group_join_fail_handler(const Tox_Event_Group_Join_Fail *event, void *user_data)
|
||||
{
|
||||
const Tox_Group_Join_Fail fail_type = tox_event_group_join_fail_get_fail_type(event);
|
||||
printf("join failed: %d\n", fail_type);
|
||||
}
|
||||
|
||||
static void group_peer_join_handler(Tox *tox, uint32_t groupnumber, uint32_t peer_id, void *user_data)
|
||||
static void group_peer_join_handler(const Tox_Event_Group_Peer_Join *event, void *user_data)
|
||||
{
|
||||
AutoTox *autotox = (AutoTox *)user_data;
|
||||
ck_assert(autotox != nullptr);
|
||||
|
||||
State *state = (State *)autotox->state;
|
||||
|
||||
const uint32_t peer_id = tox_event_group_peer_join_get_peer_id(event);
|
||||
|
||||
ck_assert_msg(state->peer_joined == false, "Peer timedout");
|
||||
|
||||
printf("peer %u joined, sending message\n", peer_id);
|
||||
@ -100,9 +109,16 @@ static void group_peer_join_handler(Tox *tox, uint32_t groupnumber, uint32_t pee
|
||||
state->peer_id = peer_id;
|
||||
}
|
||||
|
||||
static void group_custom_private_packet_handler(Tox *tox, uint32_t groupnumber, uint32_t peer_id, const uint8_t *data,
|
||||
size_t length, void *user_data)
|
||||
static void group_custom_private_packet_handler(const Tox_Event_Group_Custom_Private_Packet *event, void *user_data)
|
||||
{
|
||||
AutoTox *autotox = (AutoTox *)user_data;
|
||||
ck_assert(autotox != nullptr);
|
||||
|
||||
const uint32_t groupnumber = tox_event_group_custom_private_packet_get_group_number(event);
|
||||
const uint32_t peer_id = tox_event_group_custom_private_packet_get_peer_id(event);
|
||||
const uint8_t *data = tox_event_group_custom_private_packet_get_data(event);
|
||||
const size_t length = tox_event_group_custom_private_packet_get_data_length(event);
|
||||
|
||||
ck_assert_msg(length == TEST_CUSTOM_PRIVATE_PACKET_LEN,
|
||||
"Failed to receive custom private packet. Invalid length: %zu\n", length);
|
||||
|
||||
@ -111,25 +127,25 @@ static void group_custom_private_packet_handler(Tox *tox, uint32_t groupnumber,
|
||||
message_buf[length] = 0;
|
||||
|
||||
Tox_Err_Group_Peer_Query q_err;
|
||||
size_t peer_name_len = tox_group_peer_get_name_size(tox, groupnumber, peer_id, &q_err);
|
||||
size_t peer_name_len = tox_group_peer_get_name_size(autotox->tox, groupnumber, peer_id, &q_err);
|
||||
|
||||
ck_assert(q_err == TOX_ERR_GROUP_PEER_QUERY_OK);
|
||||
ck_assert(peer_name_len <= TOX_MAX_NAME_LENGTH);
|
||||
|
||||
char peer_name[TOX_MAX_NAME_LENGTH + 1];
|
||||
tox_group_peer_get_name(tox, groupnumber, peer_id, (uint8_t *) peer_name, &q_err);
|
||||
tox_group_peer_get_name(autotox->tox, groupnumber, peer_id, (uint8_t *) peer_name, &q_err);
|
||||
peer_name[peer_name_len] = 0;
|
||||
|
||||
ck_assert(q_err == TOX_ERR_GROUP_PEER_QUERY_OK);
|
||||
ck_assert(memcmp(peer_name, PEER0_NICK, peer_name_len) == 0);
|
||||
|
||||
Tox_Err_Group_Self_Query s_err;
|
||||
size_t self_name_len = tox_group_self_get_name_size(tox, groupnumber, &s_err);
|
||||
size_t self_name_len = tox_group_self_get_name_size(autotox->tox, groupnumber, &s_err);
|
||||
ck_assert(s_err == TOX_ERR_GROUP_SELF_QUERY_OK);
|
||||
ck_assert(self_name_len <= TOX_MAX_NAME_LENGTH);
|
||||
|
||||
char self_name[TOX_MAX_NAME_LENGTH + 1];
|
||||
tox_group_self_get_name(tox, groupnumber, (uint8_t *) self_name, &s_err);
|
||||
tox_group_self_get_name(autotox->tox, groupnumber, (uint8_t *)self_name, &s_err);
|
||||
self_name[self_name_len] = 0;
|
||||
|
||||
ck_assert(s_err == TOX_ERR_GROUP_SELF_QUERY_OK);
|
||||
@ -138,17 +154,21 @@ static void group_custom_private_packet_handler(Tox *tox, uint32_t groupnumber,
|
||||
printf("%s sent custom private packet to %s: %s\n", peer_name, self_name, message_buf);
|
||||
ck_assert(memcmp(message_buf, TEST_CUSTOM_PRIVATE_PACKET, length) == 0);
|
||||
|
||||
AutoTox *autotox = (AutoTox *)user_data;
|
||||
ck_assert(autotox != nullptr);
|
||||
|
||||
State *state = (State *)autotox->state;
|
||||
|
||||
++state->custom_private_packets_received;
|
||||
}
|
||||
|
||||
static void group_custom_packet_handler(Tox *tox, uint32_t groupnumber, uint32_t peer_id, const uint8_t *data,
|
||||
size_t length, void *user_data)
|
||||
static void group_custom_packet_handler(const Tox_Event_Group_Custom_Packet *event, void *user_data)
|
||||
{
|
||||
AutoTox *autotox = (AutoTox *)user_data;
|
||||
ck_assert(autotox != nullptr);
|
||||
|
||||
const uint32_t groupnumber = tox_event_group_custom_packet_get_group_number(event);
|
||||
const uint32_t peer_id = tox_event_group_custom_packet_get_peer_id(event);
|
||||
const uint8_t *data = tox_event_group_custom_packet_get_data(event);
|
||||
const size_t length = tox_event_group_custom_packet_get_data_length(event);
|
||||
|
||||
ck_assert_msg(length == TEST_CUSTOM_PACKET_LEN, "Failed to receive custom packet. Invalid length: %zu\n", length);
|
||||
|
||||
char message_buf[TOX_MAX_CUSTOM_PACKET_SIZE + 1];
|
||||
@ -156,25 +176,25 @@ static void group_custom_packet_handler(Tox *tox, uint32_t groupnumber, uint32_t
|
||||
message_buf[length] = 0;
|
||||
|
||||
Tox_Err_Group_Peer_Query q_err;
|
||||
size_t peer_name_len = tox_group_peer_get_name_size(tox, groupnumber, peer_id, &q_err);
|
||||
size_t peer_name_len = tox_group_peer_get_name_size(autotox->tox, groupnumber, peer_id, &q_err);
|
||||
|
||||
ck_assert(q_err == TOX_ERR_GROUP_PEER_QUERY_OK);
|
||||
ck_assert(peer_name_len <= TOX_MAX_NAME_LENGTH);
|
||||
|
||||
char peer_name[TOX_MAX_NAME_LENGTH + 1];
|
||||
tox_group_peer_get_name(tox, groupnumber, peer_id, (uint8_t *) peer_name, &q_err);
|
||||
tox_group_peer_get_name(autotox->tox, groupnumber, peer_id, (uint8_t *)peer_name, &q_err);
|
||||
peer_name[peer_name_len] = 0;
|
||||
|
||||
ck_assert(q_err == TOX_ERR_GROUP_PEER_QUERY_OK);
|
||||
ck_assert(memcmp(peer_name, PEER0_NICK, peer_name_len) == 0);
|
||||
|
||||
Tox_Err_Group_Self_Query s_err;
|
||||
size_t self_name_len = tox_group_self_get_name_size(tox, groupnumber, &s_err);
|
||||
size_t self_name_len = tox_group_self_get_name_size(autotox->tox, groupnumber, &s_err);
|
||||
ck_assert(s_err == TOX_ERR_GROUP_SELF_QUERY_OK);
|
||||
ck_assert(self_name_len <= TOX_MAX_NAME_LENGTH);
|
||||
|
||||
char self_name[TOX_MAX_NAME_LENGTH + 1];
|
||||
tox_group_self_get_name(tox, groupnumber, (uint8_t *) self_name, &s_err);
|
||||
tox_group_self_get_name(autotox->tox, groupnumber, (uint8_t *)self_name, &s_err);
|
||||
self_name[self_name_len] = 0;
|
||||
|
||||
ck_assert(s_err == TOX_ERR_GROUP_SELF_QUERY_OK);
|
||||
@ -183,32 +203,39 @@ static void group_custom_packet_handler(Tox *tox, uint32_t groupnumber, uint32_t
|
||||
printf("%s sent custom packet to %s: %s\n", peer_name, self_name, message_buf);
|
||||
ck_assert(memcmp(message_buf, TEST_CUSTOM_PACKET, length) == 0);
|
||||
|
||||
AutoTox *autotox = (AutoTox *)user_data;
|
||||
ck_assert(autotox != nullptr);
|
||||
|
||||
State *state = (State *)autotox->state;
|
||||
|
||||
++state->custom_packets_received;
|
||||
}
|
||||
|
||||
static void group_custom_packet_large_handler(Tox *tox, uint32_t groupnumber, uint32_t peer_id, const uint8_t *data,
|
||||
size_t length, void *user_data)
|
||||
static void group_custom_packet_large_handler(const Tox_Event_Group_Custom_Packet *event, void *user_data)
|
||||
{
|
||||
AutoTox *autotox = (AutoTox *)user_data;
|
||||
ck_assert(autotox != nullptr);
|
||||
|
||||
const uint8_t *data = tox_event_group_custom_packet_get_data(event);
|
||||
const size_t length = tox_event_group_custom_packet_get_data_length(event);
|
||||
|
||||
ck_assert_msg(length == TEST_CUSTOM_PACKET_LARGE_LEN, "Failed to receive large custom packet. Invalid length: %zu\n", length);
|
||||
|
||||
ck_assert(memcmp(data, TEST_CUSTOM_PACKET_LARGE, length) == 0);
|
||||
|
||||
AutoTox *autotox = (AutoTox *)user_data;
|
||||
ck_assert(autotox != nullptr);
|
||||
|
||||
State *state = (State *)autotox->state;
|
||||
|
||||
++state->custom_packets_received;
|
||||
}
|
||||
|
||||
static void group_message_handler(Tox *tox, uint32_t groupnumber, uint32_t peer_id, TOX_MESSAGE_TYPE type,
|
||||
const uint8_t *message, size_t length, uint32_t pseudo_msg_id, void *user_data)
|
||||
static void group_message_handler(const Tox_Event_Group_Message *event, void *user_data)
|
||||
{
|
||||
AutoTox *autotox = (AutoTox *)user_data;
|
||||
ck_assert(autotox != nullptr);
|
||||
|
||||
const uint32_t groupnumber = tox_event_group_message_get_group_number(event);
|
||||
const uint32_t peer_id = tox_event_group_message_get_peer_id(event);
|
||||
const uint8_t *message = tox_event_group_message_get_message(event);
|
||||
const size_t length = tox_event_group_message_get_message_length(event);
|
||||
const uint32_t pseudo_msg_id = tox_event_group_message_get_message_id(event);
|
||||
|
||||
ck_assert(!(length == IGNORE_MESSAGE_LEN && memcmp(message, IGNORE_MESSAGE, length) == 0));
|
||||
ck_assert_msg(length == TEST_MESSAGE_LEN, "Failed to receive message. Invalid length: %zu\n", length);
|
||||
|
||||
@ -217,25 +244,25 @@ static void group_message_handler(Tox *tox, uint32_t groupnumber, uint32_t peer_
|
||||
message_buf[length] = 0;
|
||||
|
||||
Tox_Err_Group_Peer_Query q_err;
|
||||
size_t peer_name_len = tox_group_peer_get_name_size(tox, groupnumber, peer_id, &q_err);
|
||||
size_t peer_name_len = tox_group_peer_get_name_size(autotox->tox, groupnumber, peer_id, &q_err);
|
||||
|
||||
ck_assert(q_err == TOX_ERR_GROUP_PEER_QUERY_OK);
|
||||
ck_assert(peer_name_len <= TOX_MAX_NAME_LENGTH);
|
||||
|
||||
char peer_name[TOX_MAX_NAME_LENGTH + 1];
|
||||
tox_group_peer_get_name(tox, groupnumber, peer_id, (uint8_t *) peer_name, &q_err);
|
||||
tox_group_peer_get_name(autotox->tox, groupnumber, peer_id, (uint8_t *)peer_name, &q_err);
|
||||
peer_name[peer_name_len] = 0;
|
||||
|
||||
ck_assert(q_err == TOX_ERR_GROUP_PEER_QUERY_OK);
|
||||
ck_assert(memcmp(peer_name, PEER0_NICK, peer_name_len) == 0);
|
||||
|
||||
Tox_Err_Group_Self_Query s_err;
|
||||
size_t self_name_len = tox_group_self_get_name_size(tox, groupnumber, &s_err);
|
||||
size_t self_name_len = tox_group_self_get_name_size(autotox->tox, groupnumber, &s_err);
|
||||
ck_assert(s_err == TOX_ERR_GROUP_SELF_QUERY_OK);
|
||||
ck_assert(self_name_len <= TOX_MAX_NAME_LENGTH);
|
||||
|
||||
char self_name[TOX_MAX_NAME_LENGTH + 1];
|
||||
tox_group_self_get_name(tox, groupnumber, (uint8_t *) self_name, &s_err);
|
||||
tox_group_self_get_name(autotox->tox, groupnumber, (uint8_t *)self_name, &s_err);
|
||||
self_name[self_name_len] = 0;
|
||||
|
||||
ck_assert(s_err == TOX_ERR_GROUP_SELF_QUERY_OK);
|
||||
@ -244,19 +271,24 @@ static void group_message_handler(Tox *tox, uint32_t groupnumber, uint32_t peer_
|
||||
printf("%s sent message to %s:(id:%u) %s\n", peer_name, self_name, pseudo_msg_id, message_buf);
|
||||
ck_assert(memcmp(message_buf, TEST_MESSAGE, length) == 0);
|
||||
|
||||
AutoTox *autotox = (AutoTox *)user_data;
|
||||
ck_assert(autotox != nullptr);
|
||||
|
||||
State *state = (State *)autotox->state;
|
||||
|
||||
state->message_received = true;
|
||||
|
||||
state->pseudo_msg_id = pseudo_msg_id;
|
||||
}
|
||||
|
||||
static void group_private_message_handler(Tox *tox, uint32_t groupnumber, uint32_t peer_id, TOX_MESSAGE_TYPE type,
|
||||
const uint8_t *message, size_t length, void *user_data)
|
||||
static void group_private_message_handler(const Tox_Event_Group_Private_Message *event, void *user_data)
|
||||
{
|
||||
AutoTox *autotox = (AutoTox *)user_data;
|
||||
ck_assert(autotox != nullptr);
|
||||
|
||||
const uint32_t groupnumber = tox_event_group_private_message_get_group_number(event);
|
||||
const uint32_t peer_id = tox_event_group_private_message_get_peer_id(event);
|
||||
const Tox_Message_Type type = tox_event_group_private_message_get_message_type(event);
|
||||
const uint8_t *message = tox_event_group_private_message_get_message(event);
|
||||
const size_t length = tox_event_group_private_message_get_message_length(event);
|
||||
const Tox_Group_Message_Id pseudo_msg_id = tox_event_group_private_message_get_message_id(event);
|
||||
|
||||
ck_assert_msg(length == TEST_PRIVATE_MESSAGE_LEN, "Failed to receive message. Invalid length: %zu\n", length);
|
||||
|
||||
char message_buf[TOX_GROUP_MAX_MESSAGE_LENGTH + 1];
|
||||
@ -264,46 +296,46 @@ static void group_private_message_handler(Tox *tox, uint32_t groupnumber, uint32
|
||||
message_buf[length] = 0;
|
||||
|
||||
Tox_Err_Group_Peer_Query q_err;
|
||||
size_t peer_name_len = tox_group_peer_get_name_size(tox, groupnumber, peer_id, &q_err);
|
||||
size_t peer_name_len = tox_group_peer_get_name_size(autotox->tox, groupnumber, peer_id, &q_err);
|
||||
|
||||
ck_assert(q_err == TOX_ERR_GROUP_PEER_QUERY_OK);
|
||||
ck_assert(peer_name_len <= TOX_MAX_NAME_LENGTH);
|
||||
|
||||
char peer_name[TOX_MAX_NAME_LENGTH + 1];
|
||||
tox_group_peer_get_name(tox, groupnumber, peer_id, (uint8_t *) peer_name, &q_err);
|
||||
tox_group_peer_get_name(autotox->tox, groupnumber, peer_id, (uint8_t *)peer_name, &q_err);
|
||||
peer_name[peer_name_len] = 0;
|
||||
|
||||
ck_assert(q_err == TOX_ERR_GROUP_PEER_QUERY_OK);
|
||||
ck_assert(memcmp(peer_name, PEER0_NICK, peer_name_len) == 0);
|
||||
|
||||
Tox_Err_Group_Self_Query s_err;
|
||||
size_t self_name_len = tox_group_self_get_name_size(tox, groupnumber, &s_err);
|
||||
size_t self_name_len = tox_group_self_get_name_size(autotox->tox, groupnumber, &s_err);
|
||||
ck_assert(s_err == TOX_ERR_GROUP_SELF_QUERY_OK);
|
||||
ck_assert(self_name_len <= TOX_MAX_NAME_LENGTH);
|
||||
|
||||
char self_name[TOX_MAX_NAME_LENGTH + 1];
|
||||
tox_group_self_get_name(tox, groupnumber, (uint8_t *) self_name, &s_err);
|
||||
tox_group_self_get_name(autotox->tox, groupnumber, (uint8_t *)self_name, &s_err);
|
||||
self_name[self_name_len] = 0;
|
||||
|
||||
ck_assert(s_err == TOX_ERR_GROUP_SELF_QUERY_OK);
|
||||
ck_assert(memcmp(self_name, PEER1_NICK, self_name_len) == 0);
|
||||
|
||||
printf("%s sent private action to %s: %s\n", peer_name, self_name, message_buf);
|
||||
printf("%s sent private action to %s:(id: %u) %s\n", peer_name, self_name, pseudo_msg_id, message_buf);
|
||||
ck_assert(memcmp(message_buf, TEST_PRIVATE_MESSAGE, length) == 0);
|
||||
|
||||
ck_assert(type == TOX_MESSAGE_TYPE_ACTION);
|
||||
|
||||
AutoTox *autotox = (AutoTox *)user_data;
|
||||
ck_assert(autotox != nullptr);
|
||||
|
||||
State *state = (State *)autotox->state;
|
||||
|
||||
state->private_message_received = true;
|
||||
state->pseudo_msg_id = pseudo_msg_id;
|
||||
}
|
||||
|
||||
static void group_message_handler_lossless_test(Tox *tox, uint32_t groupnumber, uint32_t peer_id, TOX_MESSAGE_TYPE type,
|
||||
const uint8_t *message, size_t length, uint32_t pseudo_msg_id, void *user_data)
|
||||
static void group_message_handler_lossless_test(const Tox_Event_Group_Message *event, void *user_data)
|
||||
{
|
||||
const uint8_t *message = tox_event_group_message_get_message(event);
|
||||
const size_t length = tox_event_group_message_get_message_length(event);
|
||||
|
||||
AutoTox *autotox = (AutoTox *)user_data;
|
||||
ck_assert(autotox != nullptr);
|
||||
|
||||
@ -325,10 +357,11 @@ static void group_message_handler_lossless_test(Tox *tox, uint32_t groupnumber,
|
||||
state->lossless_check = true;
|
||||
}
|
||||
}
|
||||
static void group_message_handler_wraparound_test(Tox *tox, uint32_t groupnumber, uint32_t peer_id,
|
||||
TOX_MESSAGE_TYPE type,
|
||||
const uint8_t *message, size_t length, uint32_t pseudo_msg_id, void *user_data)
|
||||
static void group_message_handler_wraparound_test(const Tox_Event_Group_Message *event, void *user_data)
|
||||
{
|
||||
const uint8_t *message = tox_event_group_message_get_message(event);
|
||||
const size_t length = tox_event_group_message_get_message_length(event);
|
||||
|
||||
AutoTox *autotox = (AutoTox *)user_data;
|
||||
ck_assert(autotox != nullptr);
|
||||
|
||||
@ -352,11 +385,11 @@ static void group_message_test(AutoTox *autotoxes)
|
||||
{
|
||||
ck_assert_msg(NUM_GROUP_TOXES >= 2, "NUM_GROUP_TOXES is too small: %d", NUM_GROUP_TOXES);
|
||||
|
||||
const Random *rng = system_random();
|
||||
const Random *rng = os_random();
|
||||
ck_assert(rng != nullptr);
|
||||
|
||||
Tox *tox0 = autotoxes[0].tox;
|
||||
Tox *tox1 = autotoxes[1].tox;
|
||||
const Tox *tox1 = autotoxes[1].tox;
|
||||
|
||||
State *state0 = (State *)autotoxes[0].state;
|
||||
State *state1 = (State *)autotoxes[1].state;
|
||||
@ -365,15 +398,15 @@ static void group_message_test(AutoTox *autotoxes)
|
||||
state0->pseudo_msg_id = 0;
|
||||
state1->pseudo_msg_id = 1;
|
||||
|
||||
tox_callback_group_invite(tox1, group_invite_handler);
|
||||
tox_callback_group_join_fail(tox1, group_join_fail_handler);
|
||||
tox_callback_group_peer_join(tox1, group_peer_join_handler);
|
||||
tox_callback_group_join_fail(tox0, group_join_fail_handler);
|
||||
tox_callback_group_peer_join(tox0, group_peer_join_handler);
|
||||
tox_callback_group_message(tox0, group_message_handler);
|
||||
tox_callback_group_custom_packet(tox0, group_custom_packet_handler);
|
||||
tox_callback_group_custom_private_packet(tox0, group_custom_private_packet_handler);
|
||||
tox_callback_group_private_message(tox0, group_private_message_handler);
|
||||
tox_events_callback_group_invite(autotoxes[1].dispatch, group_invite_handler);
|
||||
tox_events_callback_group_join_fail(autotoxes[1].dispatch, group_join_fail_handler);
|
||||
tox_events_callback_group_peer_join(autotoxes[1].dispatch, group_peer_join_handler);
|
||||
tox_events_callback_group_join_fail(autotoxes[0].dispatch, group_join_fail_handler);
|
||||
tox_events_callback_group_peer_join(autotoxes[0].dispatch, group_peer_join_handler);
|
||||
tox_events_callback_group_message(autotoxes[0].dispatch, group_message_handler);
|
||||
tox_events_callback_group_custom_packet(autotoxes[0].dispatch, group_custom_packet_handler);
|
||||
tox_events_callback_group_custom_private_packet(autotoxes[0].dispatch, group_custom_private_packet_handler);
|
||||
tox_events_callback_group_private_message(autotoxes[0].dispatch, group_private_message_handler);
|
||||
|
||||
Tox_Err_Group_Send_Message err_send;
|
||||
|
||||
@ -396,14 +429,15 @@ static void group_message_test(AutoTox *autotoxes)
|
||||
|
||||
if (state1->peer_joined && !state1->message_sent) {
|
||||
state1->pseudo_msg_id = tox_group_send_message(
|
||||
tox1, group_number, TOX_MESSAGE_TYPE_NORMAL, (const uint8_t *)TEST_MESSAGE,
|
||||
TEST_MESSAGE_LEN, &err_send);
|
||||
tox1, group_number, TOX_MESSAGE_TYPE_NORMAL, (const uint8_t *)TEST_MESSAGE,
|
||||
TEST_MESSAGE_LEN, &err_send);
|
||||
ck_assert(err_send == TOX_ERR_GROUP_SEND_MESSAGE_OK);
|
||||
state1->message_sent = true;
|
||||
}
|
||||
}
|
||||
|
||||
ck_assert_msg(state0->pseudo_msg_id == state1->pseudo_msg_id, "id0:%u id1:%u", state0->pseudo_msg_id, state1->pseudo_msg_id);
|
||||
ck_assert_msg(state0->pseudo_msg_id == state1->pseudo_msg_id, "id0:%u id1:%u",
|
||||
state0->pseudo_msg_id, state1->pseudo_msg_id);
|
||||
|
||||
// Make sure we're still connected to each friend
|
||||
Tox_Connection conn_1 = tox_friend_get_connection_status(tox0, 0, nullptr);
|
||||
@ -428,14 +462,23 @@ static void group_message_test(AutoTox *autotoxes)
|
||||
tox_group_set_ignore(tox0, group_number, state0->peer_id, false, &ig_err);
|
||||
ck_assert_msg(ig_err == TOX_ERR_GROUP_SET_IGNORE_OK, "%d", ig_err);
|
||||
|
||||
fprintf(stderr, "Sending private message...\n");
|
||||
fprintf(stderr, "Sending private action...\n");
|
||||
|
||||
// tox0 sends a private action to tox1
|
||||
// tox1 sends a private action to tox0
|
||||
Tox_Err_Group_Send_Private_Message m_err;
|
||||
tox_group_send_private_message(tox1, group_number, state1->peer_id, TOX_MESSAGE_TYPE_ACTION,
|
||||
(const uint8_t *)TEST_PRIVATE_MESSAGE, TEST_PRIVATE_MESSAGE_LEN, &m_err);
|
||||
state1->pseudo_msg_id = tox_group_send_private_message(tox1, group_number, state1->peer_id,
|
||||
TOX_MESSAGE_TYPE_ACTION, (const uint8_t *)TEST_PRIVATE_MESSAGE,
|
||||
TEST_PRIVATE_MESSAGE_LEN, &m_err);
|
||||
|
||||
ck_assert_msg(m_err == TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_OK, "%d", m_err);
|
||||
|
||||
while (!state0->private_message_received) {
|
||||
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL);
|
||||
}
|
||||
|
||||
ck_assert_msg(state0->pseudo_msg_id == state1->pseudo_msg_id, "id0:%u id1:%u",
|
||||
state0->pseudo_msg_id, state1->pseudo_msg_id);
|
||||
|
||||
fprintf(stderr, "Sending custom packets...\n");
|
||||
|
||||
// tox0 sends a lossless and lossy custom packet to tox1
|
||||
@ -464,15 +507,14 @@ static void group_message_test(AutoTox *autotoxes)
|
||||
|
||||
ck_assert_msg(cperr == TOX_ERR_GROUP_SEND_CUSTOM_PRIVATE_PACKET_OK, "%d", cperr);
|
||||
|
||||
while (!state0->private_message_received || state0->custom_packets_received < 2
|
||||
|| state0->custom_private_packets_received < 2) {
|
||||
while (state0->custom_packets_received < 2 || state0->custom_private_packets_received < 2) {
|
||||
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL);
|
||||
}
|
||||
|
||||
// tox0 sends a large max sized lossy custom packet
|
||||
|
||||
// overwrite callback for larger packet
|
||||
tox_callback_group_custom_packet(tox0, group_custom_packet_large_handler);
|
||||
tox_events_callback_group_custom_packet(autotoxes[0].dispatch, group_custom_packet_large_handler);
|
||||
|
||||
tox_group_send_custom_packet(tox1, group_number, false, (const uint8_t *)TEST_CUSTOM_PACKET_LARGE, TEST_CUSTOM_PACKET_LARGE_LEN,
|
||||
&c_err);
|
||||
@ -486,7 +528,7 @@ static void group_message_test(AutoTox *autotoxes)
|
||||
|
||||
fprintf(stderr, "Doing lossless packet test...\n");
|
||||
|
||||
tox_callback_group_message(tox1, group_message_handler_lossless_test);
|
||||
tox_events_callback_group_message(autotoxes[1].dispatch, group_message_handler_lossless_test);
|
||||
state1->last_msg_recv = -1;
|
||||
|
||||
// lossless and packet splitting/reassembly test
|
||||
@ -517,7 +559,7 @@ static void group_message_test(AutoTox *autotoxes)
|
||||
}
|
||||
|
||||
state1->last_msg_recv = -1;
|
||||
tox_callback_group_message(tox1, group_message_handler_wraparound_test);
|
||||
tox_events_callback_group_message(autotoxes[1].dispatch, group_message_handler_wraparound_test);
|
||||
|
||||
fprintf(stderr, "Doing wraparound test...\n");
|
||||
|
@ -19,13 +19,13 @@
|
||||
#define GROUP_NAME_LEN (sizeof(GROUP_NAME) - 1)
|
||||
|
||||
typedef struct Peer {
|
||||
char name[TOX_MAX_NAME_LENGTH];
|
||||
char name[TOX_MAX_NAME_LENGTH + 1];
|
||||
size_t name_length;
|
||||
uint32_t peer_id;
|
||||
} Peer;
|
||||
|
||||
typedef struct State {
|
||||
char self_name[TOX_MAX_NAME_LENGTH];
|
||||
char self_name[TOX_MAX_NAME_LENGTH + 1];
|
||||
size_t self_name_length;
|
||||
|
||||
uint32_t group_number;
|
||||
@ -38,7 +38,6 @@ typedef struct State {
|
||||
char mod_name1[TOX_MAX_NAME_LENGTH];
|
||||
char mod_name2[TOX_MAX_NAME_LENGTH];
|
||||
|
||||
|
||||
bool observer_check;
|
||||
size_t observer_event_count;
|
||||
char observer_name1[TOX_MAX_NAME_LENGTH];
|
||||
@ -53,7 +52,7 @@ typedef struct State {
|
||||
static bool all_peers_connected(AutoTox *autotoxes)
|
||||
{
|
||||
for (size_t i = 0; i < NUM_GROUP_TOXES; ++i) {
|
||||
State *state = (State *)autotoxes[i].state;
|
||||
const State *state = (const State *)autotoxes[i].state;
|
||||
|
||||
if (state->num_peers != NUM_GROUP_TOXES - 1) {
|
||||
return false;
|
||||
@ -146,7 +145,7 @@ static size_t get_state_index_by_nick(const AutoTox *autotoxes, size_t num_peers
|
||||
ck_assert(name != nullptr && name_length <= TOX_MAX_NAME_LENGTH);
|
||||
|
||||
for (size_t i = 0; i < num_peers; ++i) {
|
||||
State *state = (State *)autotoxes[i].state;
|
||||
const State *state = (const State *)autotoxes[i].state;
|
||||
|
||||
if (memcmp(state->self_name, name, name_length) == 0) {
|
||||
return i;
|
||||
@ -156,29 +155,33 @@ static size_t get_state_index_by_nick(const AutoTox *autotoxes, size_t num_peers
|
||||
ck_assert_msg(0, "Failed to find index");
|
||||
}
|
||||
|
||||
static void group_join_fail_handler(Tox *tox, uint32_t group_number, Tox_Group_Join_Fail fail_type, void *user_data)
|
||||
static void group_join_fail_handler(const Tox_Event_Group_Join_Fail *event, void *user_data)
|
||||
{
|
||||
const Tox_Group_Join_Fail fail_type = tox_event_group_join_fail_get_fail_type(event);
|
||||
fprintf(stderr, "Failed to join group: %d", fail_type);
|
||||
}
|
||||
|
||||
static void group_peer_join_handler(Tox *tox, uint32_t group_number, uint32_t peer_id, void *user_data)
|
||||
static void group_peer_join_handler(const Tox_Event_Group_Peer_Join *event, void *user_data)
|
||||
{
|
||||
AutoTox *autotox = (AutoTox *)user_data;
|
||||
ck_assert(autotox != nullptr);
|
||||
|
||||
State *state = (State *)autotox->state;
|
||||
|
||||
const uint32_t group_number = tox_event_group_peer_join_get_group_number(event);
|
||||
const uint32_t peer_id = tox_event_group_peer_join_get_peer_id(event);
|
||||
|
||||
ck_assert(state->group_number == group_number);
|
||||
|
||||
char peer_name[TOX_MAX_NAME_LENGTH + 1];
|
||||
|
||||
Tox_Err_Group_Peer_Query q_err;
|
||||
size_t peer_name_len = tox_group_peer_get_name_size(tox, group_number, peer_id, &q_err);
|
||||
size_t peer_name_len = tox_group_peer_get_name_size(autotox->tox, group_number, peer_id, &q_err);
|
||||
|
||||
ck_assert(q_err == TOX_ERR_GROUP_PEER_QUERY_OK);
|
||||
ck_assert(peer_name_len <= TOX_MAX_NAME_LENGTH);
|
||||
|
||||
tox_group_peer_get_name(tox, group_number, peer_id, (uint8_t *) peer_name, &q_err);
|
||||
tox_group_peer_get_name(autotox->tox, group_number, peer_id, (uint8_t *) peer_name, &q_err);
|
||||
peer_name[peer_name_len] = 0;
|
||||
ck_assert(q_err == TOX_ERR_GROUP_PEER_QUERY_OK);
|
||||
|
||||
@ -193,7 +196,7 @@ static void group_peer_join_handler(Tox *tox, uint32_t group_number, uint32_t pe
|
||||
ck_assert(state->num_peers < NUM_GROUP_TOXES);
|
||||
}
|
||||
|
||||
static void handle_mod(State *state, const char *peer_name, size_t peer_name_len, Tox_Group_Role role)
|
||||
static void handle_mod(State *state, const char *peer_name, size_t peer_name_len)
|
||||
{
|
||||
if (state->mod_event_count == 0) {
|
||||
ck_assert(memcmp(peer_name, state->mod_name1, peer_name_len) == 0);
|
||||
@ -205,10 +208,9 @@ static void handle_mod(State *state, const char *peer_name, size_t peer_name_len
|
||||
|
||||
++state->mod_event_count;
|
||||
state->mod_check = true;
|
||||
ck_assert(role == TOX_GROUP_ROLE_MODERATOR);
|
||||
}
|
||||
|
||||
static void handle_observer(State *state, const char *peer_name, size_t peer_name_len, Tox_Group_Role role)
|
||||
static void handle_observer(State *state, const char *peer_name, size_t peer_name_len)
|
||||
{
|
||||
if (state->observer_event_count == 0) {
|
||||
ck_assert(memcmp(peer_name, state->observer_name1, peer_name_len) == 0);
|
||||
@ -220,10 +222,9 @@ static void handle_observer(State *state, const char *peer_name, size_t peer_nam
|
||||
|
||||
++state->observer_event_count;
|
||||
state->observer_check = true;
|
||||
ck_assert(role == TOX_GROUP_ROLE_OBSERVER);
|
||||
}
|
||||
|
||||
static void handle_user(State *state, const char *peer_name, size_t peer_name_len, Tox_Group_Role role)
|
||||
static void handle_user(State *state, const char *peer_name, size_t peer_name_len)
|
||||
{
|
||||
// event 1: observer1 gets promoted back to user
|
||||
// event 2: observer2 gets promoted to moderator
|
||||
@ -243,23 +244,25 @@ static void handle_user(State *state, const char *peer_name, size_t peer_name_le
|
||||
|
||||
++state->user_event_count;
|
||||
state->user_check = true;
|
||||
ck_assert(role == TOX_GROUP_ROLE_USER);
|
||||
}
|
||||
|
||||
static void group_mod_event_handler(Tox *tox, uint32_t group_number, uint32_t source_peer_id, uint32_t target_peer_id,
|
||||
Tox_Group_Mod_Event mod_type, void *user_data)
|
||||
static void group_mod_event_handler(const Tox_Event_Group_Moderation *event, void *user_data)
|
||||
{
|
||||
AutoTox *autotox = (AutoTox *)user_data;
|
||||
ck_assert(autotox != nullptr);
|
||||
|
||||
State *state = (State *)autotox->state;
|
||||
|
||||
const uint32_t group_number = tox_event_group_moderation_get_group_number(event);
|
||||
const uint32_t target_peer_id = tox_event_group_moderation_get_target_peer_id(event);
|
||||
const Tox_Group_Mod_Event mod_type = tox_event_group_moderation_get_mod_type(event);
|
||||
|
||||
ck_assert(state->group_number == group_number);
|
||||
|
||||
char peer_name[TOX_MAX_NAME_LENGTH + 1];
|
||||
|
||||
Tox_Err_Group_Peer_Query q_err;
|
||||
size_t peer_name_len = tox_group_peer_get_name_size(tox, group_number, target_peer_id, &q_err);
|
||||
size_t peer_name_len = tox_group_peer_get_name_size(autotox->tox, group_number, target_peer_id, &q_err);
|
||||
|
||||
if (q_err == TOX_ERR_GROUP_PEER_QUERY_PEER_NOT_FOUND) { // may occurr on sync attempts
|
||||
return;
|
||||
@ -268,12 +271,13 @@ static void group_mod_event_handler(Tox *tox, uint32_t group_number, uint32_t so
|
||||
ck_assert_msg(q_err == TOX_ERR_GROUP_PEER_QUERY_OK, "error %d", q_err);
|
||||
ck_assert(peer_name_len <= TOX_MAX_NAME_LENGTH);
|
||||
|
||||
tox_group_peer_get_name(tox, group_number, target_peer_id, (uint8_t *) peer_name, &q_err);
|
||||
tox_group_peer_get_name(autotox->tox, group_number, target_peer_id, (uint8_t *) peer_name, &q_err);
|
||||
peer_name[peer_name_len] = 0;
|
||||
ck_assert(q_err == TOX_ERR_GROUP_PEER_QUERY_OK);
|
||||
|
||||
Tox_Group_Role role = tox_group_peer_get_role(tox, group_number, target_peer_id, &q_err);
|
||||
Tox_Group_Role role = tox_group_peer_get_role(autotox->tox, group_number, target_peer_id, &q_err);
|
||||
ck_assert(q_err == TOX_ERR_GROUP_PEER_QUERY_OK);
|
||||
ck_assert(role <= TOX_GROUP_ROLE_OBSERVER);
|
||||
|
||||
fprintf(stderr, "tox%u: got moderator event %d (%s), role = %s\n",
|
||||
autotox->index, mod_type, tox_group_mod_event_to_string(mod_type),
|
||||
@ -281,17 +285,17 @@ static void group_mod_event_handler(Tox *tox, uint32_t group_number, uint32_t so
|
||||
|
||||
switch (mod_type) {
|
||||
case TOX_GROUP_MOD_EVENT_MODERATOR: {
|
||||
handle_mod(state, peer_name, peer_name_len, role);
|
||||
handle_mod(state, peer_name, peer_name_len);
|
||||
break;
|
||||
}
|
||||
|
||||
case TOX_GROUP_MOD_EVENT_OBSERVER: {
|
||||
handle_observer(state, peer_name, peer_name_len, role);
|
||||
handle_observer(state, peer_name, peer_name_len);
|
||||
break;
|
||||
}
|
||||
|
||||
case TOX_GROUP_MOD_EVENT_USER: {
|
||||
handle_user(state, peer_name, peer_name_len, role);
|
||||
handle_user(state, peer_name, peer_name_len);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -314,7 +318,7 @@ static void check_self_role(AutoTox *autotoxes, uint32_t peer_id, Tox_Group_Role
|
||||
Tox_Err_Group_Self_Query sq_err;
|
||||
|
||||
for (size_t i = 0; i < NUM_GROUP_TOXES; ++i) {
|
||||
State *state = (State *)autotoxes[i].state;
|
||||
const State *state = (const State *)autotoxes[i].state;
|
||||
|
||||
uint32_t self_peer_id = tox_group_self_get_peer_id(autotoxes[i].tox, state->group_number, &sq_err);
|
||||
ck_assert(sq_err == TOX_ERR_GROUP_SELF_QUERY_OK);
|
||||
@ -378,13 +382,13 @@ static void voice_state_message_test(AutoTox *autotox, Tox_Group_Voice_State voi
|
||||
static bool all_peers_got_voice_state_change(AutoTox *autotoxes, uint32_t num_toxes,
|
||||
Tox_Group_Voice_State expected_voice_state)
|
||||
{
|
||||
Tox_Err_Group_State_Queries query_err;
|
||||
Tox_Err_Group_State_Query query_err;
|
||||
|
||||
for (uint32_t i = 0; i < num_toxes; ++i) {
|
||||
const State *state = (State *)autotoxes[i].state;
|
||||
|
||||
Tox_Group_Voice_State voice_state = tox_group_get_voice_state(autotoxes[i].tox, state->group_number, &query_err);
|
||||
ck_assert(query_err == TOX_ERR_GROUP_STATE_QUERIES_OK);
|
||||
ck_assert(query_err == TOX_ERR_GROUP_STATE_QUERY_OK);
|
||||
|
||||
if (voice_state != expected_voice_state) {
|
||||
return false;
|
||||
@ -398,10 +402,10 @@ static void check_voice_state(AutoTox *autotoxes, uint32_t num_toxes)
|
||||
{
|
||||
// founder sets voice state to Moderator
|
||||
const State *state = (State *)autotoxes[0].state;
|
||||
Tox_Err_Group_Founder_Set_Voice_State voice_set_err;
|
||||
tox_group_founder_set_voice_state(autotoxes[0].tox, state->group_number, TOX_GROUP_VOICE_STATE_MODERATOR,
|
||||
&voice_set_err);
|
||||
ck_assert(voice_set_err == TOX_ERR_GROUP_FOUNDER_SET_VOICE_STATE_OK);
|
||||
Tox_Err_Group_Set_Voice_State voice_set_err;
|
||||
tox_group_set_voice_state(autotoxes[0].tox, state->group_number, TOX_GROUP_VOICE_STATE_MODERATOR,
|
||||
&voice_set_err);
|
||||
ck_assert(voice_set_err == TOX_ERR_GROUP_SET_VOICE_STATE_OK);
|
||||
|
||||
for (uint32_t i = 0; i < num_toxes; ++i) {
|
||||
do {
|
||||
@ -411,8 +415,8 @@ static void check_voice_state(AutoTox *autotoxes, uint32_t num_toxes)
|
||||
voice_state_message_test(&autotoxes[i], TOX_GROUP_VOICE_STATE_MODERATOR);
|
||||
}
|
||||
|
||||
tox_group_founder_set_voice_state(autotoxes[0].tox, state->group_number, TOX_GROUP_VOICE_STATE_FOUNDER, &voice_set_err);
|
||||
ck_assert(voice_set_err == TOX_ERR_GROUP_FOUNDER_SET_VOICE_STATE_OK);
|
||||
tox_group_set_voice_state(autotoxes[0].tox, state->group_number, TOX_GROUP_VOICE_STATE_FOUNDER, &voice_set_err);
|
||||
ck_assert(voice_set_err == TOX_ERR_GROUP_SET_VOICE_STATE_OK);
|
||||
|
||||
for (uint32_t i = 0; i < num_toxes; ++i) {
|
||||
do {
|
||||
@ -422,8 +426,8 @@ static void check_voice_state(AutoTox *autotoxes, uint32_t num_toxes)
|
||||
voice_state_message_test(&autotoxes[i], TOX_GROUP_VOICE_STATE_FOUNDER);
|
||||
}
|
||||
|
||||
tox_group_founder_set_voice_state(autotoxes[0].tox, state->group_number, TOX_GROUP_VOICE_STATE_ALL, &voice_set_err);
|
||||
ck_assert(voice_set_err == TOX_ERR_GROUP_FOUNDER_SET_VOICE_STATE_OK);
|
||||
tox_group_set_voice_state(autotoxes[0].tox, state->group_number, TOX_GROUP_VOICE_STATE_ALL, &voice_set_err);
|
||||
ck_assert(voice_set_err == TOX_ERR_GROUP_SET_VOICE_STATE_OK);
|
||||
|
||||
for (uint32_t i = 0; i < num_toxes; ++i) {
|
||||
do {
|
||||
@ -447,9 +451,9 @@ static void group_moderation_test(AutoTox *autotoxes)
|
||||
snprintf(state->self_name, sizeof(state->self_name), "peer_%zu", i);
|
||||
state->self_name[name_length] = 0;
|
||||
|
||||
tox_callback_group_join_fail(autotoxes[i].tox, group_join_fail_handler);
|
||||
tox_callback_group_peer_join(autotoxes[i].tox, group_peer_join_handler);
|
||||
tox_callback_group_moderation(autotoxes[i].tox, group_mod_event_handler);
|
||||
tox_events_callback_group_join_fail(autotoxes[i].dispatch, group_join_fail_handler);
|
||||
tox_events_callback_group_peer_join(autotoxes[i].dispatch, group_peer_join_handler);
|
||||
tox_events_callback_group_moderation(autotoxes[i].dispatch, group_mod_event_handler);
|
||||
}
|
||||
|
||||
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL);
|
||||
@ -468,11 +472,11 @@ static void group_moderation_test(AutoTox *autotoxes)
|
||||
ck_assert_msg(err_new == TOX_ERR_GROUP_NEW_OK, "Failed to create group. error: %d\n", err_new);
|
||||
|
||||
/* Founder gets chat ID */
|
||||
Tox_Err_Group_State_Queries id_err;
|
||||
Tox_Err_Group_State_Query id_err;
|
||||
uint8_t chat_id[TOX_GROUP_CHAT_ID_SIZE];
|
||||
tox_group_get_chat_id(tox0, state0->group_number, chat_id, &id_err);
|
||||
|
||||
ck_assert_msg(id_err == TOX_ERR_GROUP_STATE_QUERIES_OK, "Failed to get chat ID. error: %d", id_err);
|
||||
ck_assert_msg(id_err == TOX_ERR_GROUP_STATE_QUERY_OK, "Failed to get chat ID. error: %d", id_err);
|
||||
|
||||
fprintf(stderr, "Peers attemping to join DHT group via the chat ID\n");
|
||||
|
||||
@ -512,7 +516,7 @@ static void group_moderation_test(AutoTox *autotoxes)
|
||||
|
||||
/* all peers should be user role except founder */
|
||||
for (size_t i = 1; i < NUM_GROUP_TOXES; ++i) {
|
||||
State *state = (State *)autotoxes[i].state;
|
||||
const State *state = (const State *)autotoxes[i].state;
|
||||
self_role = tox_group_self_get_role(autotoxes[i].tox, state->group_number, &sq_err);
|
||||
ck_assert(sq_err == TOX_ERR_GROUP_SELF_QUERY_OK);
|
||||
ck_assert(self_role == TOX_GROUP_ROLE_USER);
|
||||
@ -521,9 +525,9 @@ static void group_moderation_test(AutoTox *autotoxes)
|
||||
/* founder sets first peer to moderator */
|
||||
fprintf(stderr, "Founder setting %s to moderator\n", state0->peers[0].name);
|
||||
|
||||
Tox_Err_Group_Mod_Set_Role role_err;
|
||||
tox_group_mod_set_role(tox0, state0->group_number, state0->peers[0].peer_id, TOX_GROUP_ROLE_MODERATOR, &role_err);
|
||||
ck_assert_msg(role_err == TOX_ERR_GROUP_MOD_SET_ROLE_OK, "Failed to set moderator. error: %d", role_err);
|
||||
Tox_Err_Group_Set_Role role_err;
|
||||
tox_group_set_role(tox0, state0->group_number, state0->peers[0].peer_id, TOX_GROUP_ROLE_MODERATOR, &role_err);
|
||||
ck_assert_msg(role_err == TOX_ERR_GROUP_SET_ROLE_OK, "Failed to set moderator. error: %d", role_err);
|
||||
|
||||
// manually flag the role setter because they don't get a callback
|
||||
state0->mod_check = true;
|
||||
@ -537,8 +541,8 @@ static void group_moderation_test(AutoTox *autotoxes)
|
||||
/* founder sets second and third peer to observer */
|
||||
fprintf(stderr, "Founder setting %s to observer\n", state0->peers[1].name);
|
||||
|
||||
tox_group_mod_set_role(tox0, state0->group_number, state0->peers[1].peer_id, TOX_GROUP_ROLE_OBSERVER, &role_err);
|
||||
ck_assert_msg(role_err == TOX_ERR_GROUP_MOD_SET_ROLE_OK, "Failed to set observer. error: %d", role_err);
|
||||
tox_group_set_role(tox0, state0->group_number, state0->peers[1].peer_id, TOX_GROUP_ROLE_OBSERVER, &role_err);
|
||||
ck_assert_msg(role_err == TOX_ERR_GROUP_SET_ROLE_OK, "Failed to set observer. error: %d", role_err);
|
||||
|
||||
state0->observer_check = true;
|
||||
++state0->observer_event_count;
|
||||
@ -548,8 +552,8 @@ static void group_moderation_test(AutoTox *autotoxes)
|
||||
|
||||
fprintf(stderr, "Founder setting %s to observer\n", state0->peers[2].name);
|
||||
|
||||
tox_group_mod_set_role(tox0, state0->group_number, state0->peers[2].peer_id, TOX_GROUP_ROLE_OBSERVER, &role_err);
|
||||
ck_assert_msg(role_err == TOX_ERR_GROUP_MOD_SET_ROLE_OK, "Failed to set observer. error: %d", role_err);
|
||||
tox_group_set_role(tox0, state0->group_number, state0->peers[2].peer_id, TOX_GROUP_ROLE_OBSERVER, &role_err);
|
||||
ck_assert_msg(role_err == TOX_ERR_GROUP_SET_ROLE_OK, "Failed to set observer. error: %d", role_err);
|
||||
|
||||
state0->observer_check = true;
|
||||
++state0->observer_event_count;
|
||||
@ -574,8 +578,8 @@ static void group_moderation_test(AutoTox *autotoxes)
|
||||
|
||||
fprintf(stderr, "%s is promoting %s back to user\n", state1->self_name, state0->peers[1].name);
|
||||
|
||||
tox_group_mod_set_role(tox1, state1->group_number, obs_peer_id, TOX_GROUP_ROLE_USER, &role_err);
|
||||
ck_assert_msg(role_err == TOX_ERR_GROUP_MOD_SET_ROLE_OK, "Failed to promote observer back to user. error: %d",
|
||||
tox_group_set_role(tox1, state1->group_number, obs_peer_id, TOX_GROUP_ROLE_USER, &role_err);
|
||||
ck_assert_msg(role_err == TOX_ERR_GROUP_SET_ROLE_OK, "Failed to promote observer back to user. error: %d",
|
||||
role_err);
|
||||
|
||||
state1->user_check = true;
|
||||
@ -587,8 +591,8 @@ static void group_moderation_test(AutoTox *autotoxes)
|
||||
/* founder assigns third peer to moderator (this triggers two events: user and moderator) */
|
||||
fprintf(stderr, "Founder setting %s to moderator\n", state0->peers[2].name);
|
||||
|
||||
tox_group_mod_set_role(tox0, state0->group_number, state0->peers[2].peer_id, TOX_GROUP_ROLE_MODERATOR, &role_err);
|
||||
ck_assert_msg(role_err == TOX_ERR_GROUP_MOD_SET_ROLE_OK, "Failed to set moderator. error: %d", role_err);
|
||||
tox_group_set_role(tox0, state0->group_number, state0->peers[2].peer_id, TOX_GROUP_ROLE_MODERATOR, &role_err);
|
||||
ck_assert_msg(role_err == TOX_ERR_GROUP_SET_ROLE_OK, "Failed to set moderator. error: %d", role_err);
|
||||
|
||||
state0->mod_check = true;
|
||||
++state0->mod_event_count;
|
||||
@ -600,18 +604,27 @@ static void group_moderation_test(AutoTox *autotoxes)
|
||||
|
||||
/* moderator attempts to demote and kick founder */
|
||||
uint32_t founder_peer_id = get_peer_id_by_nick(state1->peers, NUM_GROUP_TOXES - 1, state0->self_name);
|
||||
tox_group_mod_set_role(tox1, state1->group_number, founder_peer_id, TOX_GROUP_ROLE_OBSERVER, &role_err);
|
||||
ck_assert_msg(role_err != TOX_ERR_GROUP_MOD_SET_ROLE_OK, "Mod set founder to observer");
|
||||
tox_group_set_role(tox1, state1->group_number, founder_peer_id, TOX_GROUP_ROLE_OBSERVER, &role_err);
|
||||
ck_assert_msg(role_err != TOX_ERR_GROUP_SET_ROLE_OK, "Mod set founder to observer");
|
||||
|
||||
Tox_Err_Group_Mod_Kick_Peer k_err;
|
||||
tox_group_mod_kick_peer(tox1, state1->group_number, founder_peer_id, &k_err);
|
||||
ck_assert_msg(k_err != TOX_ERR_GROUP_MOD_KICK_PEER_OK, "Mod kicked founder");
|
||||
Tox_Err_Group_Kick_Peer k_err;
|
||||
tox_group_kick_peer(tox1, state1->group_number, founder_peer_id, &k_err);
|
||||
ck_assert_msg(k_err != TOX_ERR_GROUP_KICK_PEER_OK, "Mod kicked founder");
|
||||
|
||||
/* the moderator about to be kicked changes the topic to trigger the founder to
|
||||
* re-sign and redistribute it after the kick.
|
||||
*/
|
||||
const State *state_x = (const State *)autotoxes[idx].state;
|
||||
Tox *tox_x = autotoxes[idx].tox;
|
||||
Tox_Err_Group_Topic_Set topic_err;
|
||||
tox_group_set_topic(tox_x, state_x->group_number, nullptr, 0, &topic_err);
|
||||
ck_assert(topic_err == TOX_ERR_GROUP_TOPIC_SET_OK);
|
||||
|
||||
/* founder kicks moderator (this triggers two events: user and kick) */
|
||||
fprintf(stderr, "Founder is kicking %s\n", state0->peers[0].name);
|
||||
|
||||
tox_group_mod_kick_peer(tox0, state0->group_number, state0->peers[0].peer_id, &k_err);
|
||||
ck_assert_msg(k_err == TOX_ERR_GROUP_MOD_KICK_PEER_OK, "Failed to kick peer. error: %d", k_err);
|
||||
tox_group_kick_peer(tox0, state0->group_number, state0->peers[0].peer_id, &k_err);
|
||||
ck_assert_msg(k_err == TOX_ERR_GROUP_KICK_PEER_OK, "Failed to kick peer. error: %d", k_err);
|
||||
|
||||
state0->kick_check = true;
|
||||
check_mod_event(autotoxes, NUM_GROUP_TOXES, TOX_GROUP_MOD_EVENT_KICK);
|
||||
@ -619,9 +632,8 @@ static void group_moderation_test(AutoTox *autotoxes)
|
||||
fprintf(stderr, "All peers successfully received kick event\n");
|
||||
|
||||
fprintf(stderr, "Founder is demoting moderator to user\n");
|
||||
|
||||
tox_group_mod_set_role(tox0, state0->group_number, state0->peers[2].peer_id, TOX_GROUP_ROLE_USER, &role_err);
|
||||
ck_assert_msg(role_err == TOX_ERR_GROUP_MOD_SET_ROLE_OK, "Failed to demote peer 3 to User. error: %d", role_err);
|
||||
tox_group_set_role(tox0, state0->group_number, state0->peers[2].peer_id, TOX_GROUP_ROLE_USER, &role_err);
|
||||
ck_assert_msg(role_err == TOX_ERR_GROUP_SET_ROLE_OK, "Failed to demote peer 3 to User. error: %d", role_err);
|
||||
|
||||
state0->user_check = true;
|
||||
++state0->user_event_count;
|
@ -26,17 +26,23 @@ typedef struct State {
|
||||
#define PEER0_NICK_LEN (sizeof(PEER0_NICK) -1)
|
||||
#define NEW_USER_STATUS TOX_USER_STATUS_BUSY
|
||||
|
||||
static void group_invite_handler(Tox *tox, uint32_t friend_number, const uint8_t *invite_data, size_t length,
|
||||
const uint8_t *group_name, size_t group_name_length, void *user_data)
|
||||
static void group_invite_handler(const Tox_Event_Group_Invite *event, void *user_data)
|
||||
{
|
||||
AutoTox *autotox = (AutoTox *)user_data;
|
||||
ck_assert(autotox != nullptr);
|
||||
|
||||
const uint32_t friend_number = tox_event_group_invite_get_friend_number(event);
|
||||
const uint8_t *invite_data = tox_event_group_invite_get_invite_data(event);
|
||||
const size_t length = tox_event_group_invite_get_invite_data_length(event);
|
||||
|
||||
Tox_Err_Group_Invite_Accept err_accept;
|
||||
tox_group_invite_accept(tox, friend_number, invite_data, length, (const uint8_t *)"test2", 5,
|
||||
tox_group_invite_accept(autotox->tox, friend_number, invite_data, length, (const uint8_t *)"test2", 5,
|
||||
nullptr, 0, &err_accept);
|
||||
ck_assert(err_accept == TOX_ERR_GROUP_INVITE_ACCEPT_OK);
|
||||
|
||||
}
|
||||
|
||||
static void group_peer_join_handler(Tox *tox, uint32_t group_number, uint32_t peer_id, void *user_data)
|
||||
static void group_peer_join_handler(const Tox_Event_Group_Peer_Join *event, void *user_data)
|
||||
{
|
||||
AutoTox *autotox = (AutoTox *)user_data;
|
||||
ck_assert(autotox != nullptr);
|
||||
@ -52,28 +58,28 @@ static void group_peer_join_handler(Tox *tox, uint32_t group_number, uint32_t pe
|
||||
*/
|
||||
static int has_correct_group_state(const Tox *tox, uint32_t group_number, const uint8_t *expected_chat_id)
|
||||
{
|
||||
Tox_Err_Group_State_Queries query_err;
|
||||
Tox_Err_Group_State_Query query_err;
|
||||
|
||||
Tox_Group_Privacy_State priv_state = tox_group_get_privacy_state(tox, group_number, &query_err);
|
||||
ck_assert(query_err == TOX_ERR_GROUP_STATE_QUERIES_OK);
|
||||
ck_assert(query_err == TOX_ERR_GROUP_STATE_QUERY_OK);
|
||||
|
||||
if (priv_state != NEW_PRIV_STATE) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
size_t pass_len = tox_group_get_password_size(tox, group_number, &query_err);
|
||||
ck_assert(query_err == TOX_ERR_GROUP_STATE_QUERIES_OK);
|
||||
ck_assert(query_err == TOX_ERR_GROUP_STATE_QUERY_OK);
|
||||
|
||||
uint8_t password[TOX_GROUP_MAX_PASSWORD_SIZE];
|
||||
tox_group_get_password(tox, group_number, password, &query_err);
|
||||
ck_assert(query_err == TOX_ERR_GROUP_STATE_QUERIES_OK);
|
||||
ck_assert(query_err == TOX_ERR_GROUP_STATE_QUERY_OK);
|
||||
|
||||
if (pass_len != PASS_LEN || memcmp(password, PASSWORD, pass_len) != 0) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
size_t gname_len = tox_group_get_name_size(tox, group_number, &query_err);
|
||||
ck_assert(query_err == TOX_ERR_GROUP_STATE_QUERIES_OK);
|
||||
ck_assert(query_err == TOX_ERR_GROUP_STATE_QUERY_OK);
|
||||
|
||||
uint8_t group_name[TOX_GROUP_MAX_GROUP_NAME_LENGTH];
|
||||
tox_group_get_name(tox, group_number, group_name, &query_err);
|
||||
@ -87,17 +93,17 @@ static int has_correct_group_state(const Tox *tox, uint32_t group_number, const
|
||||
}
|
||||
|
||||
Tox_Group_Topic_Lock topic_lock = tox_group_get_topic_lock(tox, group_number, &query_err);
|
||||
ck_assert(query_err == TOX_ERR_GROUP_STATE_QUERIES_OK);
|
||||
ck_assert(query_err == TOX_ERR_GROUP_STATE_QUERY_OK);
|
||||
|
||||
if (topic_lock != TOX_GROUP_TOPIC_LOCK_DISABLED) {
|
||||
return -5;
|
||||
}
|
||||
|
||||
Tox_Err_Group_State_Queries id_err;
|
||||
Tox_Err_Group_State_Query id_err;
|
||||
uint8_t chat_id[TOX_GROUP_CHAT_ID_SIZE];
|
||||
tox_group_get_chat_id(tox, group_number, chat_id, &id_err);
|
||||
|
||||
ck_assert(id_err == TOX_ERR_GROUP_STATE_QUERIES_OK);
|
||||
ck_assert(id_err == TOX_ERR_GROUP_STATE_QUERY_OK);
|
||||
|
||||
if (memcmp(chat_id, expected_chat_id, TOX_GROUP_CHAT_ID_SIZE) != 0) {
|
||||
return -6;
|
||||
@ -120,7 +126,7 @@ static int has_correct_self_state(const Tox *tox, uint32_t group_number, const u
|
||||
return -1;
|
||||
}
|
||||
|
||||
TOX_USER_STATUS self_status = tox_group_self_get_status(tox, group_number, &sq_err);
|
||||
Tox_User_Status self_status = tox_group_self_get_status(tox, group_number, &sq_err);
|
||||
ck_assert(sq_err == TOX_ERR_GROUP_SELF_QUERY_OK);
|
||||
|
||||
if (self_status != NEW_USER_STATUS) {
|
||||
@ -151,8 +157,8 @@ static void group_save_test(AutoTox *autotoxes)
|
||||
ck_assert_msg(NUM_GROUP_TOXES > 1, "NUM_GROUP_TOXES is too small: %d", NUM_GROUP_TOXES);
|
||||
|
||||
for (size_t i = 0; i < NUM_GROUP_TOXES; ++i) {
|
||||
tox_callback_group_invite(autotoxes[i].tox, group_invite_handler);
|
||||
tox_callback_group_peer_join(autotoxes[i].tox, group_peer_join_handler);
|
||||
tox_events_callback_group_invite(autotoxes[i].dispatch, group_invite_handler);
|
||||
tox_events_callback_group_peer_join(autotoxes[i].dispatch, group_peer_join_handler);
|
||||
}
|
||||
|
||||
Tox *tox0 = autotoxes[0].tox;
|
||||
@ -168,9 +174,9 @@ static void group_save_test(AutoTox *autotoxes)
|
||||
|
||||
uint8_t chat_id[TOX_GROUP_CHAT_ID_SIZE];
|
||||
|
||||
Tox_Err_Group_State_Queries id_err;
|
||||
Tox_Err_Group_State_Query id_err;
|
||||
tox_group_get_chat_id(tox0, group_number, chat_id, &id_err);
|
||||
ck_assert(id_err == TOX_ERR_GROUP_STATE_QUERIES_OK);
|
||||
ck_assert(id_err == TOX_ERR_GROUP_STATE_QUERY_OK);
|
||||
|
||||
uint8_t founder_pk[TOX_GROUP_PEER_PUBLIC_KEY_SIZE];
|
||||
|
||||
@ -178,7 +184,6 @@ static void group_save_test(AutoTox *autotoxes)
|
||||
tox_group_self_get_public_key(tox0, group_number, founder_pk, &sq_err);
|
||||
ck_assert(sq_err == TOX_ERR_GROUP_SELF_QUERY_OK);
|
||||
|
||||
|
||||
Tox_Err_Group_Invite_Friend err_invite;
|
||||
tox_group_invite_friend(tox0, group_number, 0, &err_invite);
|
||||
|
||||
@ -195,21 +200,21 @@ static void group_save_test(AutoTox *autotoxes)
|
||||
tox_group_set_topic(tox0, group_number, (const uint8_t *)TOPIC, TOPIC_LEN, &top_err);
|
||||
ck_assert(top_err == TOX_ERR_GROUP_TOPIC_SET_OK);
|
||||
|
||||
Tox_Err_Group_Founder_Set_Topic_Lock lock_set_err;
|
||||
tox_group_founder_set_topic_lock(tox0, group_number, TOX_GROUP_TOPIC_LOCK_DISABLED, &lock_set_err);
|
||||
ck_assert(lock_set_err == TOX_ERR_GROUP_FOUNDER_SET_TOPIC_LOCK_OK);
|
||||
Tox_Err_Group_Set_Topic_Lock lock_set_err;
|
||||
tox_group_set_topic_lock(tox0, group_number, TOX_GROUP_TOPIC_LOCK_DISABLED, &lock_set_err);
|
||||
ck_assert(lock_set_err == TOX_ERR_GROUP_SET_TOPIC_LOCK_OK);
|
||||
|
||||
Tox_Err_Group_Founder_Set_Privacy_State priv_err;
|
||||
tox_group_founder_set_privacy_state(tox0, group_number, NEW_PRIV_STATE, &priv_err);
|
||||
ck_assert(priv_err == TOX_ERR_GROUP_FOUNDER_SET_PRIVACY_STATE_OK);
|
||||
Tox_Err_Group_Set_Privacy_State priv_err;
|
||||
tox_group_set_privacy_state(tox0, group_number, NEW_PRIV_STATE, &priv_err);
|
||||
ck_assert(priv_err == TOX_ERR_GROUP_SET_PRIVACY_STATE_OK);
|
||||
|
||||
Tox_Err_Group_Founder_Set_Password pass_set_err;
|
||||
tox_group_founder_set_password(tox0, group_number, (const uint8_t *)PASSWORD, PASS_LEN, &pass_set_err);
|
||||
ck_assert(pass_set_err == TOX_ERR_GROUP_FOUNDER_SET_PASSWORD_OK);
|
||||
Tox_Err_Group_Set_Password pass_set_err;
|
||||
tox_group_set_password(tox0, group_number, (const uint8_t *)PASSWORD, PASS_LEN, &pass_set_err);
|
||||
ck_assert(pass_set_err == TOX_ERR_GROUP_SET_PASSWORD_OK);
|
||||
|
||||
Tox_Err_Group_Founder_Set_Peer_Limit limit_set_err;
|
||||
tox_group_founder_set_peer_limit(tox0, group_number, PEER_LIMIT, &limit_set_err);
|
||||
ck_assert(limit_set_err == TOX_ERR_GROUP_FOUNDER_SET_PEER_LIMIT_OK);
|
||||
Tox_Err_Group_Set_Peer_Limit limit_set_err;
|
||||
tox_group_set_peer_limit(tox0, group_number, PEER_LIMIT, &limit_set_err);
|
||||
ck_assert(limit_set_err == TOX_ERR_GROUP_SET_PEER_LIMIT_OK);
|
||||
|
||||
// change self state
|
||||
Tox_Err_Group_Self_Name_Set n_err;
|
||||
@ -241,8 +246,8 @@ static void group_save_test(AutoTox *autotoxes)
|
||||
ck_assert(options != nullptr);
|
||||
|
||||
tox_options_set_savedata_type(options, TOX_SAVEDATA_TYPE_TOX_SAVE);
|
||||
|
||||
tox_options_set_savedata_data(options, save, save_length);
|
||||
tox_options_set_experimental_groups_persistence(options, true);
|
||||
|
||||
Tox *new_tox = tox_new_log(options, nullptr, nullptr);
|
||||
|
||||
@ -278,7 +283,11 @@ int main(void)
|
||||
Run_Auto_Options autotest_opts = default_run_auto_options();
|
||||
autotest_opts.graph = GRAPH_COMPLETE;
|
||||
|
||||
run_auto_test(nullptr, NUM_GROUP_TOXES, group_save_test, sizeof(State), &autotest_opts);
|
||||
Tox_Options *opts = tox_options_new(nullptr);
|
||||
ck_assert(opts != nullptr);
|
||||
tox_options_set_experimental_groups_persistence(opts, true);
|
||||
run_auto_test(opts, NUM_GROUP_TOXES, group_save_test, sizeof(State), &autotest_opts);
|
||||
tox_options_free(opts);
|
||||
|
||||
return 0;
|
||||
}
|
@ -60,66 +60,97 @@ static bool all_group_peers_connected(const AutoTox *autotoxes, uint32_t tox_cou
|
||||
return true;
|
||||
}
|
||||
|
||||
static void group_topic_lock_handler(Tox *tox, uint32_t groupnumber, Tox_Group_Topic_Lock topic_lock,
|
||||
static void group_topic_lock_handler(const Tox_Event_Group_Topic_Lock *event,
|
||||
void *user_data)
|
||||
{
|
||||
Tox_Err_Group_State_Queries err;
|
||||
Tox_Group_Topic_Lock current_topic_lock = tox_group_get_topic_lock(tox, groupnumber, &err);
|
||||
const AutoTox *autotox = (const AutoTox *)user_data;
|
||||
ck_assert(autotox != nullptr);
|
||||
|
||||
ck_assert(err == TOX_ERR_GROUP_STATE_QUERIES_OK);
|
||||
const uint32_t groupnumber = tox_event_group_topic_lock_get_group_number(event);
|
||||
const Tox_Group_Topic_Lock topic_lock = tox_event_group_topic_lock_get_topic_lock(event);
|
||||
|
||||
Tox_Err_Group_State_Query err;
|
||||
Tox_Group_Topic_Lock current_topic_lock = tox_group_get_topic_lock(autotox->tox, groupnumber, &err);
|
||||
|
||||
ck_assert(err == TOX_ERR_GROUP_STATE_QUERY_OK);
|
||||
ck_assert_msg(current_topic_lock == topic_lock, "topic locks don't match in callback: %d %d",
|
||||
topic_lock, current_topic_lock);
|
||||
}
|
||||
|
||||
static void group_voice_state_handler(Tox *tox, uint32_t groupnumber, Tox_Group_Voice_State voice_state,
|
||||
static void group_voice_state_handler(const Tox_Event_Group_Voice_State *event,
|
||||
void *user_data)
|
||||
{
|
||||
Tox_Err_Group_State_Queries err;
|
||||
Tox_Group_Voice_State current_voice_state = tox_group_get_voice_state(tox, groupnumber, &err);
|
||||
const AutoTox *autotox = (const AutoTox *)user_data;
|
||||
ck_assert(autotox != nullptr);
|
||||
|
||||
ck_assert(err == TOX_ERR_GROUP_STATE_QUERIES_OK);
|
||||
const uint32_t groupnumber = tox_event_group_voice_state_get_group_number(event);
|
||||
const Tox_Group_Voice_State voice_state = tox_event_group_voice_state_get_voice_state(event);
|
||||
|
||||
Tox_Err_Group_State_Query err;
|
||||
Tox_Group_Voice_State current_voice_state = tox_group_get_voice_state(autotox->tox, groupnumber, &err);
|
||||
|
||||
ck_assert(err == TOX_ERR_GROUP_STATE_QUERY_OK);
|
||||
ck_assert_msg(current_voice_state == voice_state, "voice states don't match in callback: %d %d",
|
||||
voice_state, current_voice_state);
|
||||
}
|
||||
|
||||
static void group_privacy_state_handler(Tox *tox, uint32_t groupnumber, Tox_Group_Privacy_State privacy_state,
|
||||
static void group_privacy_state_handler(const Tox_Event_Group_Privacy_State *event,
|
||||
void *user_data)
|
||||
{
|
||||
Tox_Err_Group_State_Queries err;
|
||||
Tox_Group_Privacy_State current_pstate = tox_group_get_privacy_state(tox, groupnumber, &err);
|
||||
const AutoTox *autotox = (const AutoTox *)user_data;
|
||||
ck_assert(autotox != nullptr);
|
||||
|
||||
ck_assert(err == TOX_ERR_GROUP_STATE_QUERIES_OK);
|
||||
const uint32_t groupnumber = tox_event_group_privacy_state_get_group_number(event);
|
||||
const Tox_Group_Privacy_State privacy_state = tox_event_group_privacy_state_get_privacy_state(event);
|
||||
|
||||
Tox_Err_Group_State_Query err;
|
||||
Tox_Group_Privacy_State current_pstate = tox_group_get_privacy_state(autotox->tox, groupnumber, &err);
|
||||
|
||||
ck_assert(err == TOX_ERR_GROUP_STATE_QUERY_OK);
|
||||
ck_assert_msg(current_pstate == privacy_state, "privacy states don't match in callback");
|
||||
}
|
||||
|
||||
static void group_peer_limit_handler(Tox *tox, uint32_t groupnumber, uint32_t peer_limit, void *user_data)
|
||||
static void group_peer_limit_handler(const Tox_Event_Group_Peer_Limit *event, void *user_data)
|
||||
{
|
||||
Tox_Err_Group_State_Queries err;
|
||||
uint32_t current_plimit = tox_group_get_peer_limit(tox, groupnumber, &err);
|
||||
const AutoTox *autotox = (const AutoTox *)user_data;
|
||||
ck_assert(autotox != nullptr);
|
||||
|
||||
ck_assert(err == TOX_ERR_GROUP_STATE_QUERIES_OK);
|
||||
const uint32_t groupnumber = tox_event_group_peer_limit_get_group_number(event);
|
||||
const uint32_t peer_limit = tox_event_group_peer_limit_get_peer_limit(event);
|
||||
|
||||
Tox_Err_Group_State_Query err;
|
||||
uint32_t current_plimit = tox_group_get_peer_limit(autotox->tox, groupnumber, &err);
|
||||
|
||||
ck_assert(err == TOX_ERR_GROUP_STATE_QUERY_OK);
|
||||
ck_assert_msg(peer_limit == current_plimit,
|
||||
"Peer limits don't match in callback: %u, %u\n", peer_limit, current_plimit);
|
||||
}
|
||||
|
||||
static void group_password_handler(Tox *tox, uint32_t groupnumber, const uint8_t *password, size_t length,
|
||||
static void group_password_handler(const Tox_Event_Group_Password *event,
|
||||
void *user_data)
|
||||
{
|
||||
Tox_Err_Group_State_Queries err;
|
||||
size_t curr_pwlength = tox_group_get_password_size(tox, groupnumber, &err);
|
||||
AutoTox *autotox = (AutoTox *)user_data;
|
||||
ck_assert(autotox != nullptr);
|
||||
|
||||
ck_assert(err == TOX_ERR_GROUP_STATE_QUERIES_OK);
|
||||
const uint32_t groupnumber = tox_event_group_password_get_group_number(event);
|
||||
const uint8_t *password = tox_event_group_password_get_password(event);
|
||||
const size_t length = tox_event_group_password_get_password_length(event);
|
||||
|
||||
Tox_Err_Group_State_Query err;
|
||||
size_t curr_pwlength = tox_group_get_password_size(autotox->tox, groupnumber, &err);
|
||||
|
||||
ck_assert(err == TOX_ERR_GROUP_STATE_QUERY_OK);
|
||||
ck_assert(length == curr_pwlength);
|
||||
|
||||
uint8_t current_password[TOX_GROUP_MAX_PASSWORD_SIZE];
|
||||
tox_group_get_password(tox, groupnumber, current_password, &err);
|
||||
tox_group_get_password(autotox->tox, groupnumber, current_password, &err);
|
||||
|
||||
ck_assert(err == TOX_ERR_GROUP_STATE_QUERIES_OK);
|
||||
ck_assert(err == TOX_ERR_GROUP_STATE_QUERY_OK);
|
||||
ck_assert_msg(memcmp(current_password, password, length) == 0,
|
||||
"Passwords don't match: %s, %s", password, current_password);
|
||||
}
|
||||
|
||||
static void group_peer_join_handler(Tox *tox, uint32_t group_number, uint32_t peer_id, void *user_data)
|
||||
static void group_peer_join_handler(const Tox_Event_Group_Peer_Join *event, void *user_data)
|
||||
{
|
||||
AutoTox *autotox = (AutoTox *)user_data;
|
||||
ck_assert(autotox != nullptr);
|
||||
@ -137,24 +168,24 @@ static int check_group_state(const Tox *tox, uint32_t groupnumber, uint32_t peer
|
||||
Tox_Group_Privacy_State priv_state, Tox_Group_Voice_State voice_state,
|
||||
const uint8_t *password, size_t pass_len, Tox_Group_Topic_Lock topic_lock)
|
||||
{
|
||||
Tox_Err_Group_State_Queries query_err;
|
||||
Tox_Err_Group_State_Query query_err;
|
||||
|
||||
Tox_Group_Privacy_State my_priv_state = tox_group_get_privacy_state(tox, groupnumber, &query_err);
|
||||
ck_assert_msg(query_err == TOX_ERR_GROUP_STATE_QUERIES_OK, "Failed to get privacy state: %d", query_err);
|
||||
ck_assert_msg(query_err == TOX_ERR_GROUP_STATE_QUERY_OK, "Failed to get privacy state: %d", query_err);
|
||||
|
||||
if (my_priv_state != priv_state) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
uint32_t my_peer_limit = tox_group_get_peer_limit(tox, groupnumber, &query_err);
|
||||
ck_assert_msg(query_err == TOX_ERR_GROUP_STATE_QUERIES_OK, "Failed to get peer limit: %d", query_err);
|
||||
ck_assert_msg(query_err == TOX_ERR_GROUP_STATE_QUERY_OK, "Failed to get peer limit: %d", query_err);
|
||||
|
||||
if (my_peer_limit != peer_limit) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
size_t my_pass_len = tox_group_get_password_size(tox, groupnumber, &query_err);
|
||||
ck_assert_msg(query_err == TOX_ERR_GROUP_STATE_QUERIES_OK, "Failed to get password size: %d", query_err);
|
||||
ck_assert_msg(query_err == TOX_ERR_GROUP_STATE_QUERY_OK, "Failed to get password size: %d", query_err);
|
||||
|
||||
if (my_pass_len != pass_len) {
|
||||
return -5;
|
||||
@ -163,10 +194,10 @@ static int check_group_state(const Tox *tox, uint32_t groupnumber, uint32_t peer
|
||||
if (password != nullptr && my_pass_len > 0) {
|
||||
ck_assert(my_pass_len <= TOX_GROUP_MAX_PASSWORD_SIZE);
|
||||
|
||||
uint8_t my_pass[TOX_GROUP_MAX_PASSWORD_SIZE];
|
||||
uint8_t my_pass[TOX_GROUP_MAX_PASSWORD_SIZE + 1];
|
||||
tox_group_get_password(tox, groupnumber, my_pass, &query_err);
|
||||
my_pass[my_pass_len] = 0;
|
||||
ck_assert_msg(query_err == TOX_ERR_GROUP_STATE_QUERIES_OK, "Failed to get password: %d", query_err);
|
||||
ck_assert_msg(query_err == TOX_ERR_GROUP_STATE_QUERY_OK, "Failed to get password: %d", query_err);
|
||||
|
||||
if (memcmp(my_pass, password, my_pass_len) != 0) {
|
||||
return -6;
|
||||
@ -175,7 +206,7 @@ static int check_group_state(const Tox *tox, uint32_t groupnumber, uint32_t peer
|
||||
|
||||
/* Group name should never change */
|
||||
size_t my_gname_len = tox_group_get_name_size(tox, groupnumber, &query_err);
|
||||
ck_assert_msg(query_err == TOX_ERR_GROUP_STATE_QUERIES_OK, "Failed to get group name size: %d", query_err);
|
||||
ck_assert_msg(query_err == TOX_ERR_GROUP_STATE_QUERY_OK, "Failed to get group name size: %d", query_err);
|
||||
|
||||
if (my_gname_len != GROUP_NAME_LEN) {
|
||||
return -7;
|
||||
@ -183,7 +214,7 @@ static int check_group_state(const Tox *tox, uint32_t groupnumber, uint32_t peer
|
||||
|
||||
ck_assert(my_gname_len <= TOX_GROUP_MAX_GROUP_NAME_LENGTH);
|
||||
|
||||
uint8_t my_gname[TOX_GROUP_MAX_GROUP_NAME_LENGTH];
|
||||
uint8_t my_gname[TOX_GROUP_MAX_GROUP_NAME_LENGTH + 1];
|
||||
tox_group_get_name(tox, groupnumber, my_gname, &query_err);
|
||||
my_gname[my_gname_len] = 0;
|
||||
|
||||
@ -192,14 +223,14 @@ static int check_group_state(const Tox *tox, uint32_t groupnumber, uint32_t peer
|
||||
}
|
||||
|
||||
Tox_Group_Topic_Lock current_topic_lock = tox_group_get_topic_lock(tox, groupnumber, &query_err);
|
||||
ck_assert_msg(query_err == TOX_ERR_GROUP_STATE_QUERIES_OK, "Failed to get topic lock: %d", query_err);
|
||||
ck_assert_msg(query_err == TOX_ERR_GROUP_STATE_QUERY_OK, "Failed to get topic lock: %d", query_err);
|
||||
|
||||
if (current_topic_lock != topic_lock) {
|
||||
return -9;
|
||||
}
|
||||
|
||||
Tox_Group_Voice_State current_voice_state = tox_group_get_voice_state(tox, groupnumber, &query_err);
|
||||
ck_assert_msg(query_err == TOX_ERR_GROUP_STATE_QUERIES_OK, "Failed to get voice state: %d", query_err);
|
||||
ck_assert_msg(query_err == TOX_ERR_GROUP_STATE_QUERY_OK, "Failed to get voice state: %d", query_err);
|
||||
|
||||
if (current_voice_state != voice_state) {
|
||||
return -10;
|
||||
@ -213,26 +244,26 @@ static void set_group_state(Tox *tox, uint32_t groupnumber, uint32_t peer_limit,
|
||||
Tox_Group_Topic_Lock topic_lock)
|
||||
{
|
||||
|
||||
Tox_Err_Group_Founder_Set_Peer_Limit limit_set_err;
|
||||
tox_group_founder_set_peer_limit(tox, groupnumber, peer_limit, &limit_set_err);
|
||||
ck_assert_msg(limit_set_err == TOX_ERR_GROUP_FOUNDER_SET_PEER_LIMIT_OK, "failed to set peer limit: %d", limit_set_err);
|
||||
Tox_Err_Group_Set_Peer_Limit limit_set_err;
|
||||
tox_group_set_peer_limit(tox, groupnumber, peer_limit, &limit_set_err);
|
||||
ck_assert_msg(limit_set_err == TOX_ERR_GROUP_SET_PEER_LIMIT_OK, "failed to set peer limit: %d", limit_set_err);
|
||||
|
||||
Tox_Err_Group_Founder_Set_Privacy_State priv_err;
|
||||
tox_group_founder_set_privacy_state(tox, groupnumber, priv_state, &priv_err);
|
||||
ck_assert_msg(priv_err == TOX_ERR_GROUP_FOUNDER_SET_PRIVACY_STATE_OK, "failed to set privacy state: %d", priv_err);
|
||||
Tox_Err_Group_Set_Privacy_State priv_err;
|
||||
tox_group_set_privacy_state(tox, groupnumber, priv_state, &priv_err);
|
||||
ck_assert_msg(priv_err == TOX_ERR_GROUP_SET_PRIVACY_STATE_OK, "failed to set privacy state: %d", priv_err);
|
||||
|
||||
Tox_Err_Group_Founder_Set_Password pass_set_err;
|
||||
tox_group_founder_set_password(tox, groupnumber, password, pass_len, &pass_set_err);
|
||||
ck_assert_msg(pass_set_err == TOX_ERR_GROUP_FOUNDER_SET_PASSWORD_OK, "failed to set password: %d", pass_set_err);
|
||||
Tox_Err_Group_Set_Password pass_set_err;
|
||||
tox_group_set_password(tox, groupnumber, password, pass_len, &pass_set_err);
|
||||
ck_assert_msg(pass_set_err == TOX_ERR_GROUP_SET_PASSWORD_OK, "failed to set password: %d", pass_set_err);
|
||||
|
||||
Tox_Err_Group_Founder_Set_Topic_Lock lock_set_err;
|
||||
tox_group_founder_set_topic_lock(tox, groupnumber, topic_lock, &lock_set_err);
|
||||
ck_assert_msg(lock_set_err == TOX_ERR_GROUP_FOUNDER_SET_TOPIC_LOCK_OK, "failed to set topic lock: %d",
|
||||
Tox_Err_Group_Set_Topic_Lock lock_set_err;
|
||||
tox_group_set_topic_lock(tox, groupnumber, topic_lock, &lock_set_err);
|
||||
ck_assert_msg(lock_set_err == TOX_ERR_GROUP_SET_TOPIC_LOCK_OK, "failed to set topic lock: %d",
|
||||
lock_set_err);
|
||||
|
||||
Tox_Err_Group_Founder_Set_Voice_State voice_set_err;
|
||||
tox_group_founder_set_voice_state(tox, groupnumber, voice_state, &voice_set_err);
|
||||
ck_assert_msg(voice_set_err == TOX_ERR_GROUP_FOUNDER_SET_VOICE_STATE_OK, "failed to set voice state: %d",
|
||||
Tox_Err_Group_Set_Voice_State voice_set_err;
|
||||
tox_group_set_voice_state(tox, groupnumber, voice_state, &voice_set_err);
|
||||
ck_assert_msg(voice_set_err == TOX_ERR_GROUP_SET_VOICE_STATE_OK, "failed to set voice state: %d",
|
||||
voice_set_err);
|
||||
}
|
||||
|
||||
@ -241,12 +272,12 @@ static void group_state_test(AutoTox *autotoxes)
|
||||
ck_assert_msg(NUM_GROUP_TOXES >= 3, "NUM_GROUP_TOXES is too small: %d", NUM_GROUP_TOXES);
|
||||
|
||||
for (size_t i = 0; i < NUM_GROUP_TOXES; ++i) {
|
||||
tox_callback_group_privacy_state(autotoxes[i].tox, group_privacy_state_handler);
|
||||
tox_callback_group_peer_limit(autotoxes[i].tox, group_peer_limit_handler);
|
||||
tox_callback_group_password(autotoxes[i].tox, group_password_handler);
|
||||
tox_callback_group_peer_join(autotoxes[i].tox, group_peer_join_handler);
|
||||
tox_callback_group_voice_state(autotoxes[i].tox, group_voice_state_handler);
|
||||
tox_callback_group_topic_lock(autotoxes[i].tox, group_topic_lock_handler);
|
||||
tox_events_callback_group_privacy_state(autotoxes[i].dispatch, group_privacy_state_handler);
|
||||
tox_events_callback_group_peer_limit(autotoxes[i].dispatch, group_peer_limit_handler);
|
||||
tox_events_callback_group_password(autotoxes[i].dispatch, group_password_handler);
|
||||
tox_events_callback_group_peer_join(autotoxes[i].dispatch, group_peer_join_handler);
|
||||
tox_events_callback_group_voice_state(autotoxes[i].dispatch, group_voice_state_handler);
|
||||
tox_events_callback_group_topic_lock(autotoxes[i].dispatch, group_topic_lock_handler);
|
||||
}
|
||||
|
||||
Tox *tox0 = autotoxes[0].tox;
|
||||
@ -263,11 +294,11 @@ static void group_state_test(AutoTox *autotoxes)
|
||||
(const uint8_t *)PASSWORD, PASS_LEN, TOX_GROUP_TOPIC_LOCK_ENABLED);
|
||||
|
||||
/* Founder gets the Chat ID and implicitly shares it publicly */
|
||||
Tox_Err_Group_State_Queries id_err;
|
||||
Tox_Err_Group_State_Query id_err;
|
||||
uint8_t chat_id[TOX_GROUP_CHAT_ID_SIZE];
|
||||
tox_group_get_chat_id(tox0, groupnum, chat_id, &id_err);
|
||||
|
||||
ck_assert_msg(id_err == TOX_ERR_GROUP_STATE_QUERIES_OK, "tox_group_get_chat_id failed %d", id_err);
|
||||
ck_assert_msg(id_err == TOX_ERR_GROUP_STATE_QUERY_OK, "tox_group_get_chat_id failed %d", id_err);
|
||||
|
||||
/* All other peers join the group using the Chat ID and password */
|
||||
for (size_t i = 1; i < NUM_GROUP_TOXES; ++i) {
|
@ -96,38 +96,42 @@ static void peers_cleanup(Peers *peers)
|
||||
free(peers);
|
||||
}
|
||||
|
||||
static void group_peer_join_handler(Tox *tox, uint32_t group_number, uint32_t peer_id, void *user_data)
|
||||
static void group_peer_join_handler(const Tox_Event_Group_Peer_Join *event, void *user_data)
|
||||
{
|
||||
AutoTox *autotox = (AutoTox *)user_data;
|
||||
ck_assert(autotox != nullptr);
|
||||
|
||||
State *state = (State *)autotox->state;
|
||||
|
||||
const uint32_t peer_id = tox_event_group_peer_join_get_peer_id(event);
|
||||
|
||||
ck_assert(add_peer(state->peers, peer_id) == 0);
|
||||
|
||||
}
|
||||
|
||||
static void group_peer_exit_handler(Tox *tox, uint32_t groupnumber, uint32_t peer_id, Tox_Group_Exit_Type exit_type,
|
||||
const uint8_t *name, size_t name_length, const uint8_t *part_message,
|
||||
size_t length, void *user_data)
|
||||
static void group_peer_exit_handler(const Tox_Event_Group_Peer_Exit *event, void *user_data)
|
||||
{
|
||||
AutoTox *autotox = (AutoTox *)user_data;
|
||||
ck_assert(autotox != nullptr);
|
||||
|
||||
State *state = (State *)autotox->state;
|
||||
|
||||
const uint32_t peer_id = tox_event_group_peer_exit_get_peer_id(event);
|
||||
|
||||
ck_assert(del_peer(state->peers, peer_id) == 0);
|
||||
|
||||
}
|
||||
|
||||
static void group_topic_handler(Tox *tox, uint32_t groupnumber, uint32_t peer_id, const uint8_t *topic,
|
||||
size_t length, void *user_data)
|
||||
static void group_topic_handler(const Tox_Event_Group_Topic *event, void *user_data)
|
||||
{
|
||||
AutoTox *autotox = (AutoTox *)user_data;
|
||||
ck_assert(autotox != nullptr);
|
||||
|
||||
State *state = (State *)autotox->state;
|
||||
|
||||
const uint8_t *topic = tox_event_group_topic_get_topic(event);
|
||||
const size_t length = tox_event_group_topic_get_topic_length(event);
|
||||
|
||||
ck_assert(length <= TOX_GROUP_MAX_TOPIC_LENGTH);
|
||||
|
||||
memcpy(state->callback_topic, (const char *)topic, length);
|
||||
@ -201,7 +205,7 @@ static void role_spam(const Random *rng, AutoTox *autotoxes, uint32_t num_peers,
|
||||
int64_t peer_id = state0->peers->peer_ids[idx];
|
||||
|
||||
if (peer_id >= 0) {
|
||||
tox_group_mod_set_role(tox0, groupnumber, (uint32_t)peer_id, f_role, nullptr);
|
||||
tox_group_set_role(tox0, groupnumber, (uint32_t)peer_id, f_role, nullptr);
|
||||
}
|
||||
|
||||
// mods randomly promote or demote one of the non-mods
|
||||
@ -218,7 +222,7 @@ static void role_spam(const Random *rng, AutoTox *autotoxes, uint32_t num_peers,
|
||||
peer_id = state_j->peers->peer_ids[i];
|
||||
|
||||
if (peer_id >= 0) {
|
||||
tox_group_mod_set_role(autotoxes[j].tox, groupnumber, (uint32_t)peer_id, role, nullptr);
|
||||
tox_group_set_role(autotoxes[j].tox, groupnumber, (uint32_t)peer_id, role, nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -260,14 +264,14 @@ static bool all_peers_have_same_topic(const AutoTox *autotoxes, uint32_t num_pee
|
||||
{
|
||||
uint8_t expected_topic[TOX_GROUP_MAX_TOPIC_LENGTH];
|
||||
|
||||
Tox_Err_Group_State_Queries query_err;
|
||||
Tox_Err_Group_State_Query query_err;
|
||||
size_t expected_topic_length = tox_group_get_topic_size(autotoxes[0].tox, groupnumber, &query_err);
|
||||
|
||||
ck_assert(query_err == TOX_ERR_GROUP_STATE_QUERIES_OK);
|
||||
ck_assert(query_err == TOX_ERR_GROUP_STATE_QUERY_OK);
|
||||
|
||||
tox_group_get_topic(autotoxes[0].tox, groupnumber, expected_topic, &query_err);
|
||||
|
||||
ck_assert(query_err == TOX_ERR_GROUP_STATE_QUERIES_OK);
|
||||
ck_assert(query_err == TOX_ERR_GROUP_STATE_QUERY_OK);
|
||||
|
||||
const State *state0 = (const State *)autotoxes[0].state;
|
||||
|
||||
@ -282,7 +286,7 @@ static bool all_peers_have_same_topic(const AutoTox *autotoxes, uint32_t num_pee
|
||||
for (size_t i = 1; i < num_peers; ++i) {
|
||||
size_t topic_length = tox_group_get_topic_size(autotoxes[i].tox, groupnumber, &query_err);
|
||||
|
||||
ck_assert(query_err == TOX_ERR_GROUP_STATE_QUERIES_OK);
|
||||
ck_assert(query_err == TOX_ERR_GROUP_STATE_QUERY_OK);
|
||||
|
||||
if (topic_length != expected_topic_length) {
|
||||
return false;
|
||||
@ -291,7 +295,7 @@ static bool all_peers_have_same_topic(const AutoTox *autotoxes, uint32_t num_pee
|
||||
uint8_t topic[TOX_GROUP_MAX_TOPIC_LENGTH];
|
||||
tox_group_get_topic(autotoxes[i].tox, groupnumber, topic, &query_err);
|
||||
|
||||
ck_assert(query_err == TOX_ERR_GROUP_STATE_QUERIES_OK);
|
||||
ck_assert(query_err == TOX_ERR_GROUP_STATE_QUERY_OK);
|
||||
|
||||
if (memcmp(expected_topic, (const char *)topic, topic_length) != 0) {
|
||||
return false;
|
||||
@ -331,13 +335,13 @@ static void topic_spam(const Random *rng, AutoTox *autotoxes, uint32_t num_peers
|
||||
static void group_sync_test(AutoTox *autotoxes)
|
||||
{
|
||||
ck_assert(NUM_GROUP_TOXES >= 5);
|
||||
const Random *rng = system_random();
|
||||
const Random *rng = os_random();
|
||||
ck_assert(rng != nullptr);
|
||||
|
||||
for (size_t i = 0; i < NUM_GROUP_TOXES; ++i) {
|
||||
tox_callback_group_peer_join(autotoxes[i].tox, group_peer_join_handler);
|
||||
tox_callback_group_topic(autotoxes[i].tox, group_topic_handler);
|
||||
tox_callback_group_peer_exit(autotoxes[i].tox, group_peer_exit_handler);
|
||||
tox_events_callback_group_peer_join(autotoxes[i].dispatch, group_peer_join_handler);
|
||||
tox_events_callback_group_topic(autotoxes[i].dispatch, group_topic_handler);
|
||||
tox_events_callback_group_peer_exit(autotoxes[i].dispatch, group_peer_exit_handler);
|
||||
|
||||
State *state = (State *)autotoxes[i].state;
|
||||
state->peers = (Peers *)calloc(1, sizeof(Peers));
|
||||
@ -356,11 +360,11 @@ static void group_sync_test(AutoTox *autotoxes)
|
||||
|
||||
fprintf(stderr, "tox0 creats new group and invites all his friends");
|
||||
|
||||
Tox_Err_Group_State_Queries id_err;
|
||||
Tox_Err_Group_State_Query id_err;
|
||||
uint8_t chat_id[TOX_GROUP_CHAT_ID_SIZE];
|
||||
|
||||
tox_group_get_chat_id(tox0, groupnumber, chat_id, &id_err);
|
||||
ck_assert_msg(id_err == TOX_ERR_GROUP_STATE_QUERIES_OK, "%d", id_err);
|
||||
ck_assert_msg(id_err == TOX_ERR_GROUP_STATE_QUERY_OK, "%d", id_err);
|
||||
|
||||
for (size_t i = 1; i < NUM_GROUP_TOXES; ++i) {
|
||||
Tox_Err_Group_Join join_err;
|
||||
@ -375,9 +379,9 @@ static void group_sync_test(AutoTox *autotoxes)
|
||||
|
||||
fprintf(stderr, "%d peers joined the group\n", NUM_GROUP_TOXES);
|
||||
|
||||
Tox_Err_Group_Founder_Set_Topic_Lock lock_set_err;
|
||||
tox_group_founder_set_topic_lock(tox0, groupnumber, TOX_GROUP_TOPIC_LOCK_DISABLED, &lock_set_err);
|
||||
ck_assert_msg(lock_set_err == TOX_ERR_GROUP_FOUNDER_SET_TOPIC_LOCK_OK, "failed to disable topic lock: %d",
|
||||
Tox_Err_Group_Set_Topic_Lock lock_set_err;
|
||||
tox_group_set_topic_lock(tox0, groupnumber, TOX_GROUP_TOPIC_LOCK_DISABLED, &lock_set_err);
|
||||
ck_assert_msg(lock_set_err == TOX_ERR_GROUP_SET_TOPIC_LOCK_OK, "failed to disable topic lock: %d",
|
||||
lock_set_err);
|
||||
|
||||
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL);
|
||||
@ -388,8 +392,8 @@ static void group_sync_test(AutoTox *autotoxes)
|
||||
|
||||
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL);
|
||||
|
||||
tox_group_founder_set_topic_lock(tox0, groupnumber, TOX_GROUP_TOPIC_LOCK_ENABLED, &lock_set_err);
|
||||
ck_assert_msg(lock_set_err == TOX_ERR_GROUP_FOUNDER_SET_TOPIC_LOCK_OK, "failed to enable topic lock: %d",
|
||||
tox_group_set_topic_lock(tox0, groupnumber, TOX_GROUP_TOPIC_LOCK_ENABLED, &lock_set_err);
|
||||
ck_assert_msg(lock_set_err == TOX_ERR_GROUP_SET_TOPIC_LOCK_OK, "failed to enable topic lock: %d",
|
||||
lock_set_err);
|
||||
|
||||
do {
|
||||
@ -398,12 +402,12 @@ static void group_sync_test(AutoTox *autotoxes)
|
||||
&& !all_peers_see_same_roles(autotoxes, NUM_GROUP_TOXES, groupnumber)
|
||||
&& state0->peers->num_peers != NUM_GROUP_TOXES - 1);
|
||||
|
||||
Tox_Err_Group_Mod_Set_Role role_err;
|
||||
Tox_Err_Group_Set_Role role_err;
|
||||
|
||||
for (size_t i = 0; i < state0->peers->num_peers; ++i) {
|
||||
tox_group_mod_set_role(tox0, groupnumber, (uint32_t)state0->peers->peer_ids[i], TOX_GROUP_ROLE_MODERATOR,
|
||||
&role_err);
|
||||
ck_assert_msg(role_err == TOX_ERR_GROUP_MOD_SET_ROLE_OK, "Failed to set moderator. error: %d", role_err);
|
||||
tox_group_set_role(tox0, groupnumber, (uint32_t)state0->peers->peer_ids[i], TOX_GROUP_ROLE_MODERATOR,
|
||||
&role_err);
|
||||
ck_assert_msg(role_err == TOX_ERR_GROUP_SET_ROLE_OK, "Failed to set moderator. error: %d", role_err);
|
||||
}
|
||||
|
||||
fprintf(stderr, "founder enabled topic lock and set all peers to moderator role\n");
|
||||
@ -419,9 +423,9 @@ static void group_sync_test(AutoTox *autotoxes)
|
||||
fprintf(stderr, "founder demoting %u moderators to user\n", num_demoted);
|
||||
|
||||
for (size_t i = 0; i < num_demoted; ++i) {
|
||||
tox_group_mod_set_role(tox0, groupnumber, (uint32_t)state0->peers->peer_ids[i], TOX_GROUP_ROLE_USER,
|
||||
&role_err);
|
||||
ck_assert_msg(role_err == TOX_ERR_GROUP_MOD_SET_ROLE_OK, "Failed to set user. error: %d", role_err);
|
||||
tox_group_set_role(tox0, groupnumber, (uint32_t)state0->peers->peer_ids[i], TOX_GROUP_ROLE_USER,
|
||||
&role_err);
|
||||
ck_assert_msg(role_err == TOX_ERR_GROUP_SET_ROLE_OK, "Failed to set user. error: %d", role_err);
|
||||
}
|
||||
|
||||
do {
|
@ -19,32 +19,43 @@ typedef struct State {
|
||||
uint32_t peer_id[NUM_GROUP_TOXES - 1];
|
||||
} State;
|
||||
|
||||
static void group_invite_handler(Tox *tox, uint32_t friend_number, const uint8_t *invite_data, size_t length,
|
||||
const uint8_t *group_name, size_t group_name_length, void *user_data)
|
||||
static void group_invite_handler(const Tox_Event_Group_Invite *event, void *user_data)
|
||||
{
|
||||
AutoTox *autotox = (AutoTox *)user_data;
|
||||
ck_assert(autotox != nullptr);
|
||||
|
||||
const uint32_t friend_number = tox_event_group_invite_get_friend_number(event);
|
||||
const uint8_t *invite_data = tox_event_group_invite_get_invite_data(event);
|
||||
const size_t length = tox_event_group_invite_get_invite_data_length(event);
|
||||
|
||||
printf("Accepting friend invite\n");
|
||||
|
||||
Tox_Err_Group_Invite_Accept err_accept;
|
||||
tox_group_invite_accept(tox, friend_number, invite_data, length, (const uint8_t *)"test", 4,
|
||||
tox_group_invite_accept(autotox->tox, friend_number, invite_data, length, (const uint8_t *)"test", 4,
|
||||
nullptr, 0, &err_accept);
|
||||
ck_assert(err_accept == TOX_ERR_GROUP_INVITE_ACCEPT_OK);
|
||||
}
|
||||
|
||||
static void group_peer_join_handler(Tox *tox, uint32_t groupnumber, uint32_t peer_id, void *user_data)
|
||||
static void group_peer_join_handler(const Tox_Event_Group_Peer_Join *event, void *user_data)
|
||||
{
|
||||
AutoTox *autotox = (AutoTox *)user_data;
|
||||
ck_assert(autotox != nullptr);
|
||||
|
||||
State *state = (State *)autotox->state;
|
||||
|
||||
const uint32_t peer_id = tox_event_group_peer_join_get_peer_id(event);
|
||||
|
||||
fprintf(stderr, "joined: %zu, %u\n", state->num_peers, peer_id);
|
||||
ck_assert_msg(state->num_peers < NUM_GROUP_TOXES - 1, "%zu", state->num_peers);
|
||||
|
||||
state->peer_id[state->num_peers++] = peer_id;
|
||||
}
|
||||
|
||||
static void group_private_message_handler(Tox *tox, uint32_t groupnumber, uint32_t peer_id, TOX_MESSAGE_TYPE type,
|
||||
const uint8_t *message, size_t length, void *user_data)
|
||||
static void group_private_message_handler(const Tox_Event_Group_Private_Message *event, void *user_data)
|
||||
{
|
||||
const uint8_t *message = tox_event_group_private_message_get_message(event);
|
||||
const size_t length = tox_event_group_private_message_get_message_length(event);
|
||||
|
||||
AutoTox *autotox = (AutoTox *)user_data;
|
||||
ck_assert(autotox != nullptr);
|
||||
|
||||
@ -58,9 +69,11 @@ static void group_private_message_handler(Tox *tox, uint32_t groupnumber, uint32
|
||||
state->got_code = true;
|
||||
}
|
||||
|
||||
static void group_message_handler(Tox *tox, uint32_t groupnumber, uint32_t peer_id, TOX_MESSAGE_TYPE type,
|
||||
const uint8_t *message, size_t length, uint32_t message_id, void *user_data)
|
||||
static void group_message_handler(const Tox_Event_Group_Message *event, void *user_data)
|
||||
{
|
||||
const uint8_t *message = tox_event_group_message_get_message(event);
|
||||
const size_t length = tox_event_group_message_get_message_length(event);
|
||||
|
||||
AutoTox *autotox = (AutoTox *)user_data;
|
||||
ck_assert(autotox != nullptr);
|
||||
|
||||
@ -133,12 +146,12 @@ static void group_tcp_test(AutoTox *autotoxes)
|
||||
State *state1 = (State *)autotoxes[1].state;
|
||||
|
||||
for (size_t i = 0; i < NUM_GROUP_TOXES; ++i) {
|
||||
tox_callback_group_peer_join(autotoxes[i].tox, group_peer_join_handler);
|
||||
tox_callback_group_private_message(autotoxes[i].tox, group_private_message_handler);
|
||||
tox_events_callback_group_peer_join(autotoxes[i].dispatch, group_peer_join_handler);
|
||||
tox_events_callback_group_private_message(autotoxes[i].dispatch, group_private_message_handler);
|
||||
}
|
||||
|
||||
tox_callback_group_message(autotoxes[1].tox, group_message_handler);
|
||||
tox_callback_group_invite(autotoxes[1].tox, group_invite_handler);
|
||||
tox_events_callback_group_message(autotoxes[1].dispatch, group_message_handler);
|
||||
tox_events_callback_group_invite(autotoxes[1].dispatch, group_invite_handler);
|
||||
|
||||
Tox_Err_Group_New new_err;
|
||||
uint32_t groupnumber = tox_group_new(autotoxes[0].tox, TOX_GROUP_PRIVACY_STATE_PUBLIC, (const uint8_t *)"test", 4,
|
||||
@ -147,11 +160,11 @@ static void group_tcp_test(AutoTox *autotoxes)
|
||||
|
||||
iterate_group(autotoxes, NUM_GROUP_TOXES, GROUP_ITERATION_INTERVAL);
|
||||
|
||||
Tox_Err_Group_State_Queries id_err;
|
||||
Tox_Err_Group_State_Query id_err;
|
||||
uint8_t chat_id[TOX_GROUP_CHAT_ID_SIZE];
|
||||
|
||||
tox_group_get_chat_id(autotoxes[0].tox, groupnumber, chat_id, &id_err);
|
||||
ck_assert_msg(id_err == TOX_ERR_GROUP_STATE_QUERIES_OK, "%d", id_err);
|
||||
ck_assert_msg(id_err == TOX_ERR_GROUP_STATE_QUERY_OK, "%d", id_err);
|
||||
|
||||
printf("Tox 0 created new group...\n");
|
||||
|
||||
@ -168,7 +181,6 @@ static void group_tcp_test(AutoTox *autotoxes)
|
||||
printf("%d peers successfully joined. Waiting for code...\n", NUM_GROUP_TOXES);
|
||||
printf("Tox 0 sending secret code to all peers\n");
|
||||
|
||||
|
||||
for (size_t i = 0; i < NUM_GROUP_TOXES - 1; ++i) {
|
||||
|
||||
Tox_Err_Group_Send_Private_Message perr;
|
@ -55,8 +55,11 @@ static bool all_group_peers_connected(const AutoTox *autotoxes, uint32_t tox_cou
|
||||
return true;
|
||||
}
|
||||
|
||||
static void group_peer_join_handler(Tox *tox, uint32_t groupnumber, uint32_t peer_id, void *user_data)
|
||||
static void group_peer_join_handler(const Tox_Event_Group_Peer_Join *event, void *user_data)
|
||||
{
|
||||
//const uint32_t group_number = tox_event_group_peer_join_get_group_number(event);
|
||||
const uint32_t peer_id = tox_event_group_peer_join_get_peer_id(event);
|
||||
|
||||
AutoTox *autotox = (AutoTox *)user_data;
|
||||
ck_assert(autotox != nullptr);
|
||||
|
||||
@ -65,28 +68,41 @@ static void group_peer_join_handler(Tox *tox, uint32_t groupnumber, uint32_t pee
|
||||
state->peer_id = peer_id;
|
||||
}
|
||||
|
||||
static void group_topic_handler(Tox *tox, uint32_t groupnumber, uint32_t peer_id, const uint8_t *topic,
|
||||
size_t length, void *user_data)
|
||||
static void group_topic_handler(const Tox_Event_Group_Topic *event, void *user_data)
|
||||
{
|
||||
ck_assert(length <= TOX_GROUP_MAX_TOPIC_LENGTH);
|
||||
AutoTox *autotox = (AutoTox *)user_data;
|
||||
ck_assert(autotox != nullptr);
|
||||
|
||||
Tox_Err_Group_State_Queries query_err;
|
||||
const uint32_t group_number = tox_event_group_topic_get_group_number(event);
|
||||
//const uint32_t peer_id = tox_event_group_topic_get_peer_id(event);
|
||||
const uint8_t *topic = tox_event_group_topic_get_topic(event);
|
||||
const uint32_t topic_length = tox_event_group_topic_get_topic_length(event);
|
||||
|
||||
ck_assert(topic_length <= TOX_GROUP_MAX_TOPIC_LENGTH);
|
||||
|
||||
Tox_Err_Group_State_Query query_err;
|
||||
uint8_t topic2[TOX_GROUP_MAX_TOPIC_LENGTH];
|
||||
tox_group_get_topic(tox, groupnumber, topic2, &query_err);
|
||||
ck_assert(query_err == TOX_ERR_GROUP_STATE_QUERIES_OK);
|
||||
tox_group_get_topic(autotox->tox, group_number, topic2, &query_err);
|
||||
ck_assert(query_err == TOX_ERR_GROUP_STATE_QUERY_OK);
|
||||
|
||||
size_t topic_length = tox_group_get_topic_size(tox, groupnumber, &query_err);
|
||||
ck_assert(query_err == TOX_ERR_GROUP_STATE_QUERIES_OK);
|
||||
ck_assert_msg(topic_length == length && memcmp(topic, topic2, length) == 0,
|
||||
size_t topic_length_getter = tox_group_get_topic_size(autotox->tox, group_number, &query_err);
|
||||
ck_assert(query_err == TOX_ERR_GROUP_STATE_QUERY_OK);
|
||||
ck_assert_msg(topic_length_getter == topic_length && memcmp(topic, topic2, topic_length) == 0,
|
||||
"topic differs in callback: %s, %s", topic, topic2);
|
||||
}
|
||||
|
||||
static void group_topic_lock_handler(Tox *tox, uint32_t groupnumber, Tox_Group_Topic_Lock topic_lock, void *user_data)
|
||||
static void group_topic_lock_handler(const Tox_Event_Group_Topic_Lock *event, void *user_data)
|
||||
{
|
||||
Tox_Err_Group_State_Queries err;
|
||||
Tox_Group_Topic_Lock current_lock = tox_group_get_topic_lock(tox, groupnumber, &err);
|
||||
const AutoTox *autotox = (const AutoTox *)user_data;
|
||||
ck_assert(autotox != nullptr);
|
||||
|
||||
ck_assert(err == TOX_ERR_GROUP_STATE_QUERIES_OK);
|
||||
const uint32_t group_number = tox_event_group_topic_lock_get_group_number(event);
|
||||
const Tox_Group_Topic_Lock topic_lock = tox_event_group_topic_lock_get_topic_lock(event);
|
||||
|
||||
Tox_Err_Group_State_Query err;
|
||||
Tox_Group_Topic_Lock current_lock = tox_group_get_topic_lock(autotox->tox, group_number, &err);
|
||||
|
||||
ck_assert(err == TOX_ERR_GROUP_STATE_QUERY_OK);
|
||||
ck_assert_msg(topic_lock == current_lock, "topic locks differ in callback");
|
||||
}
|
||||
|
||||
@ -107,10 +123,10 @@ static bool set_topic(Tox *tox, uint32_t groupnumber, const char *topic, size_t
|
||||
*/
|
||||
static int check_topic(const Tox *tox, uint32_t groupnumber, const char *expected_topic, size_t expected_length)
|
||||
{
|
||||
Tox_Err_Group_State_Queries query_err;
|
||||
Tox_Err_Group_State_Query query_err;
|
||||
size_t topic_length = tox_group_get_topic_size(tox, groupnumber, &query_err);
|
||||
|
||||
if (query_err != TOX_ERR_GROUP_STATE_QUERIES_OK) {
|
||||
if (query_err != TOX_ERR_GROUP_STATE_QUERY_OK) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -121,7 +137,7 @@ static int check_topic(const Tox *tox, uint32_t groupnumber, const char *expecte
|
||||
uint8_t topic[TOX_GROUP_MAX_TOPIC_LENGTH];
|
||||
tox_group_get_topic(tox, groupnumber, topic, &query_err);
|
||||
|
||||
if (query_err != TOX_ERR_GROUP_STATE_QUERIES_OK) {
|
||||
if (query_err != TOX_ERR_GROUP_STATE_QUERY_OK) {
|
||||
return -3;
|
||||
}
|
||||
|
||||
@ -140,9 +156,9 @@ static void wait_topic_lock(AutoTox *autotoxes, uint32_t groupnumber, Tox_Group_
|
||||
uint32_t count = 0;
|
||||
|
||||
for (size_t i = 0; i < NUM_GROUP_TOXES; ++i) {
|
||||
Tox_Err_Group_State_Queries err;
|
||||
Tox_Err_Group_State_Query err;
|
||||
Tox_Group_Topic_Lock topic_lock = tox_group_get_topic_lock(autotoxes[i].tox, groupnumber, &err);
|
||||
ck_assert(err == TOX_ERR_GROUP_STATE_QUERIES_OK);
|
||||
ck_assert(err == TOX_ERR_GROUP_STATE_QUERY_OK);
|
||||
|
||||
if (topic_lock == expected_lock) {
|
||||
++count;
|
||||
@ -205,17 +221,18 @@ static void group_topic_test(AutoTox *autotoxes)
|
||||
{
|
||||
ck_assert_msg(NUM_GROUP_TOXES >= 3, "NUM_GROUP_TOXES is too small: %d", NUM_GROUP_TOXES);
|
||||
|
||||
const Random *rng = system_random();
|
||||
const Random *rng = os_random();
|
||||
ck_assert(rng != nullptr);
|
||||
|
||||
Tox *tox0 = autotoxes[0].tox;
|
||||
Tox_Dispatch *dispatch0 = autotoxes[0].dispatch;
|
||||
const State *state0 = (const State *)autotoxes[0].state;
|
||||
|
||||
tox_callback_group_peer_join(tox0, group_peer_join_handler);
|
||||
tox_events_callback_group_peer_join(dispatch0, group_peer_join_handler);
|
||||
|
||||
for (size_t i = 0; i < NUM_GROUP_TOXES; ++i) {
|
||||
tox_callback_group_topic(autotoxes[i].tox, group_topic_handler);
|
||||
tox_callback_group_topic_lock(autotoxes[i].tox, group_topic_lock_handler);
|
||||
tox_events_callback_group_topic(autotoxes[i].dispatch, group_topic_handler);
|
||||
tox_events_callback_group_topic_lock(autotoxes[i].dispatch, group_topic_lock_handler);
|
||||
}
|
||||
|
||||
/* Tox1 creates a group and is the founder of a newly created group */
|
||||
@ -233,11 +250,11 @@ static void group_topic_test(AutoTox *autotoxes)
|
||||
ck_assert_msg(s_ret, "Founder failed to set topic");
|
||||
|
||||
/* Founder gets the Chat ID and implicitly shares it publicly */
|
||||
Tox_Err_Group_State_Queries id_err;
|
||||
Tox_Err_Group_State_Query id_err;
|
||||
uint8_t chat_id[TOX_GROUP_CHAT_ID_SIZE];
|
||||
tox_group_get_chat_id(tox0, groupnumber, chat_id, &id_err);
|
||||
|
||||
ck_assert_msg(id_err == TOX_ERR_GROUP_STATE_QUERIES_OK, "tox_group_get_chat_id failed %d", id_err);
|
||||
ck_assert_msg(id_err == TOX_ERR_GROUP_STATE_QUERY_OK, "tox_group_get_chat_id failed %d", id_err);
|
||||
|
||||
/* All other peers join the group using the Chat ID */
|
||||
for (size_t i = 1; i < NUM_GROUP_TOXES; ++i) {
|
||||
@ -257,9 +274,9 @@ static void group_topic_test(AutoTox *autotoxes)
|
||||
wait_state_topic(autotoxes, groupnumber, TOPIC, TOPIC_LEN);
|
||||
|
||||
/* Founder disables topic lock */
|
||||
Tox_Err_Group_Founder_Set_Topic_Lock lock_set_err;
|
||||
tox_group_founder_set_topic_lock(tox0, groupnumber, TOX_GROUP_TOPIC_LOCK_DISABLED, &lock_set_err);
|
||||
ck_assert_msg(lock_set_err == TOX_ERR_GROUP_FOUNDER_SET_TOPIC_LOCK_OK, "failed to disable topic lock: %d",
|
||||
Tox_Err_Group_Set_Topic_Lock lock_set_err;
|
||||
tox_group_set_topic_lock(tox0, groupnumber, TOX_GROUP_TOPIC_LOCK_DISABLED, &lock_set_err);
|
||||
ck_assert_msg(lock_set_err == TOX_ERR_GROUP_SET_TOPIC_LOCK_OK, "failed to disable topic lock: %d",
|
||||
lock_set_err);
|
||||
|
||||
fprintf(stderr, "Topic lock disabled\n");
|
||||
@ -273,9 +290,9 @@ static void group_topic_test(AutoTox *autotoxes)
|
||||
ck_assert_msg(change_count == NUM_GROUP_TOXES, "%u peers changed the topic with topic lock disabled", change_count);
|
||||
|
||||
/* founder silences the last peer he saw join */
|
||||
Tox_Err_Group_Mod_Set_Role merr;
|
||||
tox_group_mod_set_role(tox0, groupnumber, state0->peer_id, TOX_GROUP_ROLE_OBSERVER, &merr);
|
||||
ck_assert_msg(merr == TOX_ERR_GROUP_MOD_SET_ROLE_OK, "Failed to set %u to observer role: %d", state0->peer_id, merr);
|
||||
Tox_Err_Group_Set_Role merr;
|
||||
tox_group_set_role(tox0, groupnumber, state0->peer_id, TOX_GROUP_ROLE_OBSERVER, &merr);
|
||||
ck_assert_msg(merr == TOX_ERR_GROUP_SET_ROLE_OK, "Failed to set %u to observer role: %d", state0->peer_id, merr);
|
||||
|
||||
fprintf(stderr, "Random peer is set to observer\n");
|
||||
|
||||
@ -287,8 +304,8 @@ static void group_topic_test(AutoTox *autotoxes)
|
||||
ck_assert_msg(change_count == NUM_GROUP_TOXES - 1, "%u peers changed the topic with a silenced peer", change_count);
|
||||
|
||||
/* Founder enables topic lock and sets topic back to original */
|
||||
tox_group_founder_set_topic_lock(tox0, groupnumber, TOX_GROUP_TOPIC_LOCK_ENABLED, &lock_set_err);
|
||||
ck_assert_msg(lock_set_err == TOX_ERR_GROUP_FOUNDER_SET_TOPIC_LOCK_OK, "failed to enable topic lock: %d",
|
||||
tox_group_set_topic_lock(tox0, groupnumber, TOX_GROUP_TOPIC_LOCK_ENABLED, &lock_set_err);
|
||||
ck_assert_msg(lock_set_err == TOX_ERR_GROUP_SET_TOPIC_LOCK_OK, "failed to enable topic lock: %d",
|
||||
lock_set_err);
|
||||
|
||||
fprintf(stderr, "Topic lock enabled\n");
|
@ -18,13 +18,17 @@ typedef struct State {
|
||||
|
||||
#define LOSSLESS_PACKET_FILLER 160
|
||||
|
||||
static void handle_lossless_packet(Tox *tox, uint32_t friend_number, const uint8_t *data, size_t length, void *user_data)
|
||||
static void handle_lossless_packet(const Tox_Event_Friend_Lossless_Packet *event, void *user_data)
|
||||
{
|
||||
//const uint32_t friend_number = tox_event_friend_lossless_packet_get_friend_number(event);
|
||||
const uint8_t *data = tox_event_friend_lossless_packet_get_data(event);
|
||||
const uint32_t data_length = tox_event_friend_lossless_packet_get_data_length(event);
|
||||
|
||||
uint8_t *cmp_packet = (uint8_t *)malloc(tox_max_custom_packet_size());
|
||||
ck_assert(cmp_packet != nullptr);
|
||||
memset(cmp_packet, LOSSLESS_PACKET_FILLER, tox_max_custom_packet_size());
|
||||
|
||||
if (length == tox_max_custom_packet_size() && memcmp(data, cmp_packet, tox_max_custom_packet_size()) == 0) {
|
||||
if (data_length == tox_max_custom_packet_size() && memcmp(data, cmp_packet, tox_max_custom_packet_size()) == 0) {
|
||||
const AutoTox *autotox = (AutoTox *)user_data;
|
||||
State *state = (State *)autotox->state;
|
||||
state->custom_packet_received = true;
|
||||
@ -35,7 +39,7 @@ static void handle_lossless_packet(Tox *tox, uint32_t friend_number, const uint8
|
||||
|
||||
static void test_lossless_packet(AutoTox *autotoxes)
|
||||
{
|
||||
tox_callback_friend_lossless_packet(autotoxes[1].tox, &handle_lossless_packet);
|
||||
tox_events_callback_friend_lossless_packet(autotoxes[1].dispatch, &handle_lossless_packet);
|
||||
const size_t packet_size = tox_max_custom_packet_size() + 1;
|
||||
uint8_t *packet = (uint8_t *)malloc(packet_size);
|
||||
ck_assert(packet != nullptr);
|
@ -18,13 +18,17 @@ typedef struct State {
|
||||
|
||||
#define LOSSY_PACKET_FILLER 200
|
||||
|
||||
static void handle_lossy_packet(Tox *tox, uint32_t friend_number, const uint8_t *data, size_t length, void *user_data)
|
||||
static void handle_lossy_packet(const Tox_Event_Friend_Lossy_Packet *event, void *user_data)
|
||||
{
|
||||
//const uint32_t friend_number = tox_event_friend_lossy_packet_get_friend_number(event);
|
||||
const uint8_t *data = tox_event_friend_lossy_packet_get_data(event);
|
||||
const uint32_t data_length = tox_event_friend_lossy_packet_get_data_length(event);
|
||||
|
||||
uint8_t *cmp_packet = (uint8_t *)malloc(tox_max_custom_packet_size());
|
||||
ck_assert(cmp_packet != nullptr);
|
||||
memset(cmp_packet, LOSSY_PACKET_FILLER, tox_max_custom_packet_size());
|
||||
|
||||
if (length == tox_max_custom_packet_size() && memcmp(data, cmp_packet, tox_max_custom_packet_size()) == 0) {
|
||||
if (data_length == tox_max_custom_packet_size() && memcmp(data, cmp_packet, tox_max_custom_packet_size()) == 0) {
|
||||
const AutoTox *autotox = (AutoTox *)user_data;
|
||||
State *state = (State *)autotox->state;
|
||||
state->custom_packet_received = true;
|
||||
@ -35,7 +39,7 @@ static void handle_lossy_packet(Tox *tox, uint32_t friend_number, const uint8_t
|
||||
|
||||
static void test_lossy_packet(AutoTox *autotoxes)
|
||||
{
|
||||
tox_callback_friend_lossy_packet(autotoxes[1].tox, &handle_lossy_packet);
|
||||
tox_events_callback_friend_lossy_packet(autotoxes[1].dispatch, &handle_lossy_packet);
|
||||
const size_t packet_size = tox_max_custom_packet_size() + 1;
|
||||
uint8_t *packet = (uint8_t *)malloc(packet_size);
|
||||
ck_assert(packet != nullptr);
|
@ -20,7 +20,7 @@ static void test_addr_resolv_localhost(void)
|
||||
errno = 0;
|
||||
#endif
|
||||
|
||||
const Network *ns = system_network();
|
||||
const Network *ns = os_network();
|
||||
ck_assert(ns != nullptr);
|
||||
|
||||
const char localhost[] = "localhost";
|
@ -37,7 +37,7 @@ static void do_onion(Mono_Time *mono_time, Onion *onion)
|
||||
static int handled_test_1;
|
||||
static int handle_test_1(void *object, const IP_Port *source, const uint8_t *packet, uint16_t length, void *userdata)
|
||||
{
|
||||
Onion *onion = (Onion *)object;
|
||||
const Onion *onion = (const Onion *)object;
|
||||
|
||||
const char req_message[] = "Install Gentoo";
|
||||
uint8_t req_packet[1 + sizeof(req_message)];
|
||||
@ -99,7 +99,7 @@ static uint8_t test_3_pub_key[CRYPTO_PUBLIC_KEY_SIZE];
|
||||
static uint8_t test_3_ping_id[CRYPTO_SHA256_SIZE];
|
||||
static int handle_test_3(void *object, const IP_Port *source, const uint8_t *packet, uint16_t length, void *userdata)
|
||||
{
|
||||
Onion *onion = (Onion *)object;
|
||||
const Onion *onion = (const Onion *)object;
|
||||
|
||||
if (length < ONION_ANNOUNCE_RESPONSE_MIN_SIZE || length > ONION_ANNOUNCE_RESPONSE_MAX_SIZE) {
|
||||
return 1;
|
||||
@ -118,7 +118,6 @@ static int handle_test_3(void *object, const IP_Port *source, const uint8_t *pac
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
if (memcmp(packet + 1, sb_data, ONION_ANNOUNCE_SENDBACK_DATA_LENGTH) != 0) {
|
||||
return 1;
|
||||
}
|
||||
@ -135,7 +134,7 @@ static int handle_test_3(void *object, const IP_Port *source, const uint8_t *pac
|
||||
static int handle_test_3_old(void *object, const IP_Port *source, const uint8_t *packet, uint16_t length,
|
||||
void *userdata)
|
||||
{
|
||||
Onion *onion = (Onion *)object;
|
||||
const Onion *onion = (const Onion *)object;
|
||||
|
||||
if (length < ONION_ANNOUNCE_RESPONSE_MIN_SIZE || length > ONION_ANNOUNCE_RESPONSE_MAX_SIZE) {
|
||||
return 1;
|
||||
@ -154,7 +153,6 @@ static int handle_test_3_old(void *object, const IP_Port *source, const uint8_t
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
if (memcmp(packet + 1, sb_data, ONION_ANNOUNCE_SENDBACK_DATA_LENGTH) != 0) {
|
||||
return 1;
|
||||
}
|
||||
@ -171,7 +169,7 @@ static uint8_t nonce[CRYPTO_NONCE_SIZE];
|
||||
static int handled_test_4;
|
||||
static int handle_test_4(void *object, const IP_Port *source, const uint8_t *packet, uint16_t length, void *userdata)
|
||||
{
|
||||
Onion *onion = (Onion *)object;
|
||||
const Onion *onion = (const Onion *)object;
|
||||
|
||||
if (length != (1 + CRYPTO_NONCE_SIZE + CRYPTO_PUBLIC_KEY_SIZE + sizeof("Install gentoo") +
|
||||
CRYPTO_MAC_SIZE)) {
|
||||
@ -223,11 +221,11 @@ static Networking_Core *new_networking(const Logger *log, const Memory *mem, con
|
||||
static void test_basic(void)
|
||||
{
|
||||
uint32_t index[] = { 1, 2, 3 };
|
||||
const Network *ns = system_network();
|
||||
const Network *ns = os_network();
|
||||
ck_assert(ns != nullptr);
|
||||
const Memory *mem = system_memory();
|
||||
const Memory *mem = os_memory();
|
||||
ck_assert(mem != nullptr);
|
||||
const Random *rng = system_random();
|
||||
const Random *rng = os_random();
|
||||
ck_assert(rng != nullptr);
|
||||
|
||||
Logger *log1 = logger_new();
|
||||
@ -288,7 +286,7 @@ static void test_basic(void)
|
||||
networking_registerhandler(onion1->net, NET_PACKET_ANNOUNCE_RESPONSE, &handle_test_3, onion1);
|
||||
networking_registerhandler(onion1->net, NET_PACKET_ANNOUNCE_RESPONSE_OLD, &handle_test_3_old, onion1);
|
||||
ck_assert_msg((onion1_a != nullptr) && (onion2_a != nullptr), "Onion_Announce failed initializing.");
|
||||
uint8_t zeroes[64] = {0};
|
||||
const uint8_t zeroes[64] = {0};
|
||||
random_bytes(rng, sb_data, sizeof(sb_data));
|
||||
uint64_t s;
|
||||
memcpy(&s, sb_data, sizeof(uint64_t));
|
||||
@ -407,7 +405,7 @@ static Onions *new_onions(const Memory *mem, const Random *rng, uint16_t port, u
|
||||
{
|
||||
IP ip = get_loopback();
|
||||
ip.ip.v6.uint8[15] = 1;
|
||||
const Network *ns = system_network();
|
||||
const Network *ns = os_network();
|
||||
Onions *on = (Onions *)malloc(sizeof(Onions));
|
||||
|
||||
if (!on) {
|
||||
@ -576,9 +574,9 @@ static void test_announce(void)
|
||||
{
|
||||
uint32_t index[NUM_ONIONS];
|
||||
Onions *onions[NUM_ONIONS];
|
||||
const Random *rng = system_random();
|
||||
const Random *rng = os_random();
|
||||
ck_assert(rng != nullptr);
|
||||
const Memory *mem = system_memory();
|
||||
const Memory *mem = os_memory();
|
||||
ck_assert(mem != nullptr);
|
||||
|
||||
for (uint32_t i = 0; i < NUM_ONIONS; ++i) {
|
@ -11,9 +11,13 @@ typedef struct State {
|
||||
|
||||
#define NUM_MSGS 40000
|
||||
|
||||
static void handle_friend_message(Tox *tox, uint32_t friend_number, Tox_Message_Type type,
|
||||
const uint8_t *message, size_t length, void *user_data)
|
||||
static void handle_friend_message(const Tox_Event_Friend_Message *event, void *user_data)
|
||||
{
|
||||
//const uint32_t friend_number = tox_event_friend_message_get_friend_number(event);
|
||||
//const Tox_Message_Type type = tox_event_friend_message_get_type(event);
|
||||
//const uint8_t *message = tox_event_friend_message_get_message(event);
|
||||
//const uint32_t message_length = tox_event_friend_message_get_message_length(event);
|
||||
|
||||
const AutoTox *autotox = (AutoTox *)user_data;
|
||||
State *state = (State *)autotox->state;
|
||||
state->recv_count++;
|
||||
@ -21,7 +25,7 @@ static void handle_friend_message(Tox *tox, uint32_t friend_number, Tox_Message_
|
||||
|
||||
static void net_crypto_overflow_test(AutoTox *autotoxes)
|
||||
{
|
||||
tox_callback_friend_message(autotoxes[0].tox, handle_friend_message);
|
||||
tox_events_callback_friend_message(autotoxes[0].dispatch, handle_friend_message);
|
||||
|
||||
printf("sending many messages to tox0\n");
|
||||
|
@ -24,10 +24,10 @@ static bool try_bootstrap(Tox *tox1, Tox *tox2, Tox *tox3, Tox *tox4)
|
||||
tox_self_get_connection_status(tox3) != TOX_CONNECTION_NONE &&
|
||||
tox_self_get_connection_status(tox4) != TOX_CONNECTION_NONE) {
|
||||
printf("%d %d %d %d\n",
|
||||
tox_self_get_connection_status(tox1),
|
||||
tox_self_get_connection_status(tox2),
|
||||
tox_self_get_connection_status(tox3),
|
||||
tox_self_get_connection_status(tox4));
|
||||
tox_self_get_connection_status(tox1),
|
||||
tox_self_get_connection_status(tox2),
|
||||
tox_self_get_connection_status(tox3),
|
||||
tox_self_get_connection_status(tox4));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -38,10 +38,10 @@ static bool try_bootstrap(Tox *tox1, Tox *tox2, Tox *tox3, Tox *tox4)
|
||||
|
||||
if (i % 10 == 0) {
|
||||
printf("%d %d %d %d\n",
|
||||
tox_self_get_connection_status(tox1),
|
||||
tox_self_get_connection_status(tox2),
|
||||
tox_self_get_connection_status(tox3),
|
||||
tox_self_get_connection_status(tox4));
|
||||
tox_self_get_connection_status(tox1),
|
||||
tox_self_get_connection_status(tox2),
|
||||
tox_self_get_connection_status(tox3),
|
||||
tox_self_get_connection_status(tox4));
|
||||
}
|
||||
|
||||
c_sleep(tox_iteration_interval(tox1));
|
@ -51,7 +51,7 @@ static bool all_disconnected_from(uint32_t tox_count, AutoTox *autotoxes, uint32
|
||||
|
||||
static void test_reconnect(AutoTox *autotoxes)
|
||||
{
|
||||
const Random *rng = system_random();
|
||||
const Random *rng = os_random();
|
||||
ck_assert(rng != nullptr);
|
||||
const time_t test_start_time = time(nullptr);
|
||||
|
||||
@ -67,7 +67,12 @@ static void test_reconnect(AutoTox *autotoxes)
|
||||
do {
|
||||
for (uint16_t i = 0; i < TOX_COUNT; ++i) {
|
||||
if (i != disconnect) {
|
||||
tox_iterate(autotoxes[i].tox, &autotoxes[i]);
|
||||
Tox_Err_Events_Iterate err = TOX_ERR_EVENTS_ITERATE_OK;
|
||||
Tox_Events *events = tox_events_iterate(autotoxes[i].tox, true, &err);
|
||||
ck_assert(err == TOX_ERR_EVENTS_ITERATE_OK);
|
||||
tox_dispatch_invoke(autotoxes[i].dispatch, events, &autotoxes[i]);
|
||||
tox_events_free(events);
|
||||
|
||||
autotoxes[i].clock += 1000;
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user