From 601ef895f3385a5b251eec00e6d6b9b746d9f1a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= Date: Wed, 5 Nov 2025 23:26:46 +0100 Subject: [PATCH 1/2] DO NOT MERGE: Trying to debug TestContext_Verify MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Miloslav Trmač --- .github/workflows/go.yml | 10 +++++----- data.go | 4 ++++ gpgme_test.go | 8 +++++++- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 20096c81c..9e69a94c8 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -16,8 +16,8 @@ jobs: - run: sudo apt-get install -y libgpgme-dev - uses: actions/setup-go@v3 with: - go-version: '1.17.12' - - run: go test -v ./... + go-version: '1.25.4' + - run: go test -v -v ./... ubuntu-ppe64le: runs-on: ubuntu-latest @@ -32,7 +32,7 @@ jobs: apt-get update -q -y apt-get install -y libgpgme-dev golang run: | - go test -v ./... + go test -v -v ./... macos: runs-on: macos-latest @@ -41,5 +41,5 @@ jobs: - run: brew install gpgme gnupg@1.4 - uses: actions/setup-go@v3 with: - go-version: '1.17.12' - - run: go test -v ./... + go-version: '1.25.4' + - run: GPGME_DEBUG=9 go test -v -v ./... diff --git a/data.go b/data.go index 0e81c36d6..4e512c573 100644 --- a/data.go +++ b/data.go @@ -11,6 +11,7 @@ import ( "os" "runtime" "runtime/cgo" + "strings" "unsafe" ) @@ -45,6 +46,9 @@ func gogpgme_writefunc(handle, buffer unsafe.Pointer, size C.size_t) C.ssize_t { d := h.Value().(*Data) n, err := d.w.Write(unsafe.Slice((*byte)(buffer), size)) if err != nil && err != io.EOF { + if !strings.Contains(err.Error(), "a special error") { + panic("UNEXPECTED WRITE ERROR: " + err.Error()) + } d.err = err C.gpgme_err_set_errno(C.EIO) return -1 diff --git a/gpgme_test.go b/gpgme_test.go index 49ea5bdf3..1ecfacf6c 100644 --- a/gpgme_test.go +++ b/gpgme_test.go @@ -246,8 +246,14 @@ func TestContext_Verify(t *testing.T) { ctx, err := New() checkError(t, err) - _, err = ctx.GetKey("test@example.com", false) + key, err := ctx.GetKey("test@example.com", false) checkError(t, err) + if key == nil { + t.Fatal("Expected key, got nil") + } + if key.Fingerprint() != "44B646DC347C31E867FF4F450327FFB0229F6136" { + t.Fatalf("Unexpected fingerprint %q", key.Fingerprint()) + } signed, err := NewDataBytes([]byte(testSignedText)) checkError(t, err) From da702f4e75456bb914dfb5b7dbf6e11091152727 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= Date: Thu, 6 Nov 2025 20:29:33 +0100 Subject: [PATCH 2/2] Update from very old GnuPG 1.4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Miloslav Trmač --- .github/workflows/go.yml | 2 +- gpgme_test.go | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 9e69a94c8..9bfaf3f03 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -38,7 +38,7 @@ jobs: runs-on: macos-latest steps: - uses: actions/checkout@v3 - - run: brew install gpgme gnupg@1.4 + - run: brew install gpgme gnupg - uses: actions/setup-go@v3 with: go-version: '1.25.4' diff --git a/gpgme_test.go b/gpgme_test.go index 1ecfacf6c..ee1f4cba4 100644 --- a/gpgme_test.go +++ b/gpgme_test.go @@ -118,10 +118,12 @@ func TestGetDirInfo(t *testing.T) { } func ctxWithCallback(t *testing.T) *Context { - ensureVersion(t, "1.", "can only set password callback for GPG v1.x") + //ensureVersion(t, "1.", "can only set password callback for GPG v1.x") ctx, err := New() checkError(t, err) + ctx.SetPinEntryMode(PinEntryLoopback) + checkError(t, err) checkError(t, ctx.SetCallback(func(uid_hint string, prev_was_bad bool, f *os.File) error { if prev_was_bad {