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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/auction.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func positiveZero(price float64) float64 {
// non-finite deal floor panics in floor enforcement.
//
// Returns:
// - AuctionResult containing winner, runner-up, eligible bids, rejected bids, and full ranking
// - AuctionResult containing winner, runner-up, eligible bids, and rejected bids
//
// Processing flow:
// 1. Validate bid prices (reject negative prices, and zero prices unless the bid names a listed deal)
Expand Down
2 changes: 1 addition & 1 deletion core/floorenforcement_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func TestBidMeetsFloor(t *testing.T) {
{"negative bid below floor", -1.0, 2.5, false},
{"negative bid with zero floor", -1.0, 0.0, false},
{"decimal precision edge case - passes", 2.499999999, 2.5, true},
{"decimal precision edge case - fails", 2.4999, 2.5, false},
{"decimal precision edge case - fails", 2.49994, 2.5, false},
{"very small difference - passes", 2.5001, 2.5, true},
{"very small difference - fails", 2.4999, 2.5, false},
}
Expand Down
6 changes: 6 additions & 0 deletions validation/cmd/key-validator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ func outputText(result *validation.KeyValidationResult) {
fmt.Printf(" Signature Valid: %v\n", result.SignatureValid)
fmt.Printf(" Public Key Match: %v\n", result.PublicKeyMatch)

fmt.Println()
fmt.Println("Details:")
for _, detail := range result.ValidationDetails {
fmt.Printf(" - %s\n", detail)
}

fmt.Println()
fmt.Println("=============================")
if result.IsValid() {
Expand Down
29 changes: 29 additions & 0 deletions validation/cmd/key-validator/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@ package main

import (
"errors"
"io"
"os"
"os/exec"
"slices"
"strings"
"testing"

"github.com/peterldowns/testy/assert"
"github.com/peterldowns/testy/check"

"github.com/cloudx-io/openauction/validation"
)

// TestMissingInputExitCode runs main in a child process, because main calls os.Exit.
Expand All @@ -33,3 +37,28 @@ func TestMissingInputExitCode(t *testing.T) {
})
}
}

func TestOutputTextPrintsDetails(t *testing.T) {
result := &validation.KeyValidationResult{
BaseValidationResult: validation.BaseValidationResult{
ValidationDetails: []string{"Missing certificate", "Public key mismatch: provided key does not match attested key"},
},
}

r, w, err := os.Pipe()
assert.NoError(t, err)
t.Cleanup(func() { _ = r.Close() })
stdout := os.Stdout
t.Cleanup(func() { os.Stdout = stdout })
os.Stdout = w
outputText(result)
os.Stdout = stdout
assert.NoError(t, w.Close())
out, err := io.ReadAll(r)
assert.NoError(t, err)

want := "Details:\n - Missing certificate\n - Public key mismatch: provided key does not match attested key\n"
if !check.True(t, strings.Contains(string(out), want)) {
t.Logf("output:\n%s", out)
}
}
Loading