aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRasmus Dahlberg <rasmus.dahlberg@kau.se>2020-11-30 19:31:17 +0100
committerRasmus Dahlberg <rasmus.dahlberg@kau.se>2020-11-30 19:31:17 +0100
commitd2a37fc8afe359fc9bca6f5f67d9d976a8675803 (patch)
treebd2d2158878878b248f6f8aeb50efcdd4abf8e39
parent317b64b20bb44c37f6aef0008e65b18ab806cd51 (diff)
made a few tests more robust and found error
-rw-r--r--crypto_test.go3
-rw-r--r--trillian_test.go9
-rw-r--r--type_test.go4
3 files changed, 10 insertions, 6 deletions
diff --git a/crypto_test.go b/crypto_test.go
index b6c168b..6233613 100644
--- a/crypto_test.go
+++ b/crypto_test.go
@@ -51,6 +51,7 @@ func TestBuildChainFromDerList(t *testing.T) {
maxChain: 3,
anchors: testdata.RootCertificate,
chain: mustMakeDerList(t, testdata.ExpiredChain),
+ wantErr: false, // TODO: should be true! fixme
},
{
description: "bad chain: too large",
@@ -280,8 +281,6 @@ func TestGenV1Sth(t *testing.T) {
}
}
-// TODO: test that metrics are updated correctly?
-
// mustMakeDerList must parse a PEM-encoded list of certificates to DER
func mustMakeDerList(t *testing.T, pem []byte) [][]byte {
certs, err := x509util.NewCertificateList(pem)
diff --git a/trillian_test.go b/trillian_test.go
index 749f22a..179d03c 100644
--- a/trillian_test.go
+++ b/trillian_test.go
@@ -35,11 +35,11 @@ func TestCheckQueueLeaf(t *testing.T) {
},
{
description: "ok response: duplicate leaf",
- rsp: makeTrillianQueueLeafResponse(t, testPackage, testdata.RootChain, testdata.EndEntityPrivateKey, true),
+ rsp: makeTrillianQueueLeafResponse(t, testPackage, testdata.IntermediateChain, testdata.EndEntityPrivateKey, true),
},
{
description: "ok response: new leaf",
- rsp: makeTrillianQueueLeafResponse(t, testPackage, testdata.RootChain, testdata.EndEntityPrivateKey, false),
+ rsp: makeTrillianQueueLeafResponse(t, testPackage, testdata.IntermediateChain, testdata.EndEntityPrivateKey, false),
},
} {
if err := checkQueueLeaf(table.rsp, table.err); (err != nil) != table.wantErr {
@@ -58,15 +58,18 @@ func TestCheckGetLeavesByRange(t *testing.T) {
}{
{
description: "bad response: trillian error",
+ req: &GetEntriesRequest{Start: 0, End: 1},
err: fmt.Errorf("backend error"),
wantErr: true,
},
{
description: "bad response: empty",
+ req: &GetEntriesRequest{Start: 0, End: 1},
wantErr: true,
},
{
description: "bad response: no leaves",
+ req: &GetEntriesRequest{Start: 0, End: 1},
rsp: func(rsp *trillian.GetLeavesByRangeResponse) *trillian.GetLeavesByRangeResponse {
rsp.Leaves = nil
return rsp
@@ -75,6 +78,7 @@ func TestCheckGetLeavesByRange(t *testing.T) {
},
{
description: "bad response: no signed log root",
+ req: &GetEntriesRequest{Start: 0, End: 1},
rsp: func(rsp *trillian.GetLeavesByRangeResponse) *trillian.GetLeavesByRangeResponse {
rsp.SignedLogRoot = nil
return rsp
@@ -83,6 +87,7 @@ func TestCheckGetLeavesByRange(t *testing.T) {
},
{
description: "bad response: no log root",
+ req: &GetEntriesRequest{Start: 0, End: 1},
rsp: func(rsp *trillian.GetLeavesByRangeResponse) *trillian.GetLeavesByRangeResponse {
rsp.SignedLogRoot.LogRoot = nil
return rsp
diff --git a/type_test.go b/type_test.go
index e8dce00..abfc280 100644
--- a/type_test.go
+++ b/type_test.go
@@ -20,8 +20,8 @@ var (
testTreeSizeLarger = uint64(256)
testTimestamp = uint64(0)
testProof = [][]byte{
- make([]byte, 32),
- make([]byte, 32),
+ testNodeHash,
+ testNodeHash,
}
testIndex = uint64(0)
testSignatureScheme = tls.Ed25519