Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Go Tests

on:
pull_request:
push:
branches:
- master

concurrency:
group: ci-${{ github.ref }}-test
cancel-in-progress: true

jobs:
test:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
golang: ['1.13.15', '1.25.5']

runs-on: ${{ matrix.os }}
env:
DBGSYNCLOG: trace
DBGSYNCON: true

steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v5
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0

- name: Set up Go ${{ matrix.golang }}
uses: actions/setup-go@v6
with:
go-version: ${{ matrix.golang }}
check-latest: false

- name: Run tests
run: |
make test
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
*~
protobuf-fuzz.zip
workdir
workdir
.idea/**
18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
tidy:
go mod tidy

# Coding style static check.
lint: tidy
# keep this in sync with .github/workflows/golangci-lint.yml
go install github.com/golangci/golangci-lint/v2/cmd/[email protected]
go mod tidy
golangci-lint run

test: tidy
export GOARCH='amd64' && go test ./...
export GOARCH='386' && go test ./...

# target to run all the possible checks; it's a good habit to run it before
# pushing code
check: lint test
echo "check done"
3 changes: 2 additions & 1 deletion array_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package protobuf

import (
"encoding/hex"
"math"
"reflect"
"testing"

Expand All @@ -26,7 +27,7 @@ type ArrayTest3 struct {

func TestArray(t *testing.T) {
// largest int32 is 2147483647
var large int = 3147483647
var large int = math.MaxInt32 - 1

a0 := ArrayTest0{[]int{1, 1, large}}
a1 := ArrayTest1{[]int64{1, 1, 1}}
Expand Down
31 changes: 30 additions & 1 deletion encoding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ func TestArrayKey(t *testing.T) {
assert.False(t, t1.M[k3])
}

func TestInterface(t *testing.T) {
func TestPointInterface(t *testing.T) {
type Points struct {
P1 kyber.Point
P2 kyber.Point
Expand All @@ -254,6 +254,35 @@ func TestInterface(t *testing.T) {
require.Equal(t, pp.P2.String(), dpp.P2.String())
}

func TestScalarInterface(t *testing.T) {
ed25519 := suites.MustFind("ed25519")

RegisterInterface(func() interface{} { return ed25519.Scalar() })
// RegisterInterface(func() interface{} { return ed25519.ScalarLen() })

type BasicSig struct {
C kyber.Scalar
R kyber.Scalar
}

pseudoRand := ed25519.XOF([]byte("test scalar interface"))

sig := BasicSig{
C: ed25519.Scalar().Pick(pseudoRand),
R: ed25519.Scalar().Pick(pseudoRand),
}

buf, err := Encode(&sig)
require.NoError(t, err)

var dsig BasicSig
err = Decode(buf, &dsig)
require.NoError(t, err)

require.Equal(t, sig.C.String(), dsig.C.String())
require.Equal(t, sig.R.String(), dsig.R.String())
}

type dummyInterface interface {
String() string
encoding.BinaryUnmarshaler
Expand Down
1 change: 0 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
go.dedis.ch/fixbuf v1.0.3 h1:hGcV9Cd/znUxlusJ64eAlExS+5cJDIyTyEG+otu5wQs=
go.dedis.ch/fixbuf v1.0.3/go.mod h1:yzJMt34Wa5xD37V5RTdmp38cz3QhMagdGoem9anUalw=
go.dedis.ch/kyber/v3 v3.0.4 h1:FDuC/S3STkvwxZ0ooo3gcp56QkUKsN7Jy7cpzBxL+vQ=
go.dedis.ch/kyber/v3 v3.0.4/go.mod h1:OzvaEnPvKlyrWyp3kGXlFdp7ap1VC6RkZDTaPikqhsQ=
go.dedis.ch/kyber/v3 v3.0.9 h1:i0ZbOQocHUjfFasBiUql5zVeC7u/vahFd96DFA8UOWk=
go.dedis.ch/kyber/v3 v3.0.9/go.mod h1:rhNjUUg6ahf8HEg5HUvVBYoWY4boAafX8tYxX+PS+qg=
Expand Down
Loading