single_test.go raw

   1  package verify
   2  
   3  import (
   4  	"encoding/json"
   5  	"testing"
   6  )
   7  
   8  // TestOneSourceIsAWarningNotARefusal: the forked chain has one public indexer today. The verdict
   9  // must say so plainly and still let the caller proceed, because the alternative is a product that
  10  // pretends it has three sources when it has one.
  11  func TestOneSourceIsAWarningNotARefusal(t *testing.T) {
  12  	body := oneSourceDossier(t)
  13  
  14  	out, err := AdjudicateJSON(body)
  15  
  16  	if err != nil {
  17  		t.Fatal(err)
  18  	}
  19  
  20  	var report Report
  21  
  22  	if err := json.Unmarshal(out, &report); err != nil {
  23  		t.Fatal(err)
  24  	}
  25  
  26  	if report.Verdict != VerdictWarn {
  27  		failed, unverifiable := report.Unverified()
  28  
  29  		for _, check := range append(failed, unverifiable...) {
  30  			t.Logf("%s: %s", check.Name, check.Detail)
  31  		}
  32  
  33  		t.Fatalf("verdict %s, want warn", report.Verdict)
  34  	}
  35  
  36  	if err := report.Gate(); err != nil {
  37  		t.Fatalf("a warning blocked the gate: %v", err)
  38  	}
  39  
  40  	found := false
  41  
  42  	for _, check := range report.Checks {
  43  		if check.Name == "source_independence" && check.Status == Warn {
  44  			found = true
  45  		}
  46  	}
  47  
  48  	if !found {
  49  		t.Fatal("the single source was not reported as a warning")
  50  	}
  51  }
  52